SoftICE - Tutorial
SoftICE - Tutorial
doc
CHAPTER 1 - Introduction
NOTE : Soft-ICE will work with real address mode programs only. It
will not work with programs that use 80286 or 80386 protected mode
instructions.
Soft-ICE can be used for most debugging problems after reading Section
I, Learning Soft-ICE, and a little experimentation. Soft-ICE's
user-friendly on-line help can be used to reference command
descriptions and syntax.
The Advanced Topics section covers topics such as using Soft-ICE with
DOS loadable drivers and using Soft-ICE with non-DOS operating
systems.
Soft-ICE works with the IBM Series II Model 70 and 80, Compaq 80386
and 80386SX computers, AT compatible and 80386 co-processor cards.
Soft-ICE will only work with 80386 XT co-processors if they are AT
compatible.
Soft-ICE works best with extended memory, but works fine with
conventional memory systems.
Soft-ICE does not use DOS or ROM BIOS for its video output and
keystroke input. Therefore the video must be compatible with one of
the following: MDA, Hercules, CGA, EGA, or VGA. Soft-ICE also has
support for a two- monitor configuration, which can be very helpful
when debugging video- intensive programs.
When you run Soft-ICE, the name of the person that your copy of
Soft-ICE is licensed to is displayed on the screen as a deterrent to
software pirates. The Soft-ICE diskette is not physically
copy-protected for your convenience. For our convenience, we
appreciate your high regard for our licensing agreement. It is
important to make a duplicate copy to be used only for backup in case
the original diskette is damaged.
Note : If you do not have extended memory, Soft-ICE can NOT loaded as
a device driver. Instead, it must be run from the DOS prompt.
Loading Soft-ICE with extended memory can be done in one of two ways:
* Sharing memory with program that use extended memory by using ROM
BIOS calls (VDISK.SYS, RAMDRIVE.SYS, HIMEM.SYS, cache programs,
etc.)
* Using Soft-ICE's EMM 4,0 capability,
* Using Soft-ICE for symbolic or source level debugging.
* Using back trace ranges.
* Using Soft-ICE with other Nu-Mega products such as Magic CV.
device=drive:\path\S-ICE.EXE /SYM 50
Drive and path specify the directory where S-ICE.EXE is located. This
statement will load Soft-ICE at system initialization and will be
adequate for the tutorial. However, Soft-ICE will not be installed for
some of its more powerful features such as EMM 4.0. You can
reconfigure Soft-ICE with those features enabled after you have
experimented a bit. If you already have experience with Soft-ICE or
would like to set up Soft-ICE with those features immediately, please
read chapter 6 (Soft-ICE Initialization Options).
Caution : When installing any new device driver for the first time on
your system, it is advisable to have a boot diskette available This
precautionary measure is for the unlikely event that The default setup
of the device driver is not compatible with your system.
If you are not sure how to edit your CONFIG.SYS file, refer to your
system user's guide or your text editor user's guide for instructions.
After you have modified your CONFIG.SYS file, you must reboot your
system to have the changes take effect.
2. Run Soft-ICE from the DOS Prompt by typing S-ICE. Before actually
loading, Soft-ICE will display a loading message and prompt. To
prevent this prompt, place the word EXTENDED in the S-ICE.DAT file.
See section 6.4 for more information on the S-ICE.DAT file. Using this
method, S-ICE.EXE is automatically loaded into the top of extended
memory, whether or not anything else is already there. If you know you
will not have any other programs using extended memory, this method is
acceptable. When loaded with this method, Soft-ICE occupies ZERO bytes
of conventional memory. The command you use is:
S-ICE
Notes : You can NOT enable all of Soft-ICE's features when Loading
from the command line. If you will be using Soft-ICE as a stand-alone
debugger, it is recommended to Load Soft-ICE from CONFIG.SYS.
S-ICE /U
This command places the machine back in real address mode. If Soft-ICE
was initially loaded from CONFIG.SYS When the memory is still reserved
for Soft-ICE and can not be used by other software. If Soft-ICE was
initially loaded from the command line, unloading frees up the memory
consumed by S- ICE.EXE.
S-ICE
03.01 Introduction
03.02 Popping Up the Window
03.03 Returning From the Window
03.04 Changing the Window Size
03.05 Moving the Window
03.06 Line Editing Keystrokes
03.07 Interactive Status Line
03.08 Command Syntax
03.08.01 Specifying Memory Addresses
03.09 Function Keys
03.10 Help
03.11 Tutorial
03.01 Introduction
All interaction with Soft-ICE takes place through a window that can be
popped up at any time. All Soft-ICE commands fit in a small window,
but the window can be enlarged to full screen. You will typically use
the small window when using Soft-ICE as an assistant to another
debugger, and the large window when using Soft-ICE in stand-alone
mode.
The window initially comes up in full screen mode if you are using the
Soft-ICE configuration file (S-ICE DAT) that was included on the
distribution diskette.
You can bring up the window at any time after installing Soft-ICE. You
initially bring up Soft-ICE by pressing the CTRL D keys. However, this
sequence can be changed by using the ALTKEY command (see section 5.8).
You can modify both the width and the height of the Soft-ICE window.
Changing the window size is particularly useful in stand-alone mode
when you are displaying code memory.
The window height can vary from 8 to 25 lines tall. To change the
window height, use the following key sequences:
To change the window width, use the WIN command (see section 5.9).
Entering WIN with no parameters toggles between the following two
modes:
There are special key assignments when the cursor is in the data
window or the code window. These are described in the sections for the
E and EC command respectively. One special assignment of note is the
SHIFT UP and SHIFT DOWN keys while the cursor is in the code window.
These keys are re-assigned so they have the functions that UP and DOWN
normally have. This way you can recall previous commands while the
cursor is in the code window.
All commands are text strings that are one to six characters in length
and are case insensitive. AlI parameters are either ASCII strings or
expressions.
12 : byte parameter
10FF : word parameter
E000:0100 : double word parameter
$ : Current CS:IP.
@address : Double Word Indirection
.number : Source Line Number
The $ character can be used in place of CS:IP when typing the address
of the current instruction pointer.
Function keys can be assigned to any command string that can be typed
into Soft-ICE. Function keys can be assigned from the command line or
pre-initialized through the Soft-ICE definition file S-ICE.DAT.
FKEY
03.10 Help
03.11 Tutorial
Since Soft-ICE is very flexible, it allows you to load in the way that
is best for your system. Go through the installation procedures in
section 2.2 before continuing with the tutorial.
If you do not have extended memory on your system, you must load
Soft-ICE from the command line. When loading Soft-ICE from the command
line you can not load symbols or source files. In this case you must
improvise in the last section of the tutorial where Soft-ICE is used
as a stand-alone debugger.
The "Soft-ICE is loaded ..." message tells you the exact area of
memory that Soft-ICE and its components are occupying. If you are on a
Compaq or Compaq clone and have included the word COMPAQ in your
S-ICE.DAT file you would also see a message saying "Using high memory
from XXXXXXXX to 00FE0000H".
The next line tells you how much symbol space has been reserved. This
space is used for both symbols and source files.
The next line tells you how much memory has been reserved for back
trace history. This amount defaults to 10K. This memory area is used
by the SNAP command and the BPR command with the T or TW options.
The last line tells you how much memory is left for regular extended
memory. This memory can be used by other programs, such as HIMEM,
SMARTDRIVE, VDISK, etc.
Change directories to the hard drive directory where you loaded all
the files from your distribution diskette. Remember, this directory
must be accessible from your alternate path list.
Before we get into heavy debugging, let's bring the Soft-ICE window up
and give it a test drive. Clear the screen by entering : CLS and bring
up the Soft-ICE window by pressing : CTRL D.
The Soft-ICE window is now on the screen. If you have file S-ICE.DAT
accessible from your path then the Soft-ICE window will occupy the
entire screen. It will be divided into four sections. From top to
bottom, these sections are the register window, the data window, the
code window, and the command window. If S-ICE.DAT was not found then
you will have a small window in the center of the screen. This also
means that other components needed for the tutorial have not been
loaded.
We will now switch to the small window. The small window is very
convenient for using Soft-ICE as an assistant to another debugger.
Enter : WIN
This will make a small command window in the center of the screen.
Several Soft-ICE commands are visible on this screen. These are
remnants of the initialization string in S-ICE.DAT that originally set
up Soft-ICE in the full screen mode. You will notice a prompt symbol
(:) and a status line at the bottom of the window.
The Soft-ICE window can be moved around on the screen, and the window
size can be adjusted. Move the window around the screen by pressing:
Change the window size so that it fills the whole screen by entering :
WIN. You will notice that the original screen is back. Change back to
the small window by entering WIN again. Make the window taller or
shorter by pressing :
Now try what comes naturally when you're in front of a new program and
you don't have the foggiest notion of what to do next, ask for help.
Get a help display by entering : ?
Notice how the display stops and waits for a keystroke before
scrolling any information off the screen. Look at the status line at
the bottom of the window. The status line displays the instructions:
"Any Key To Continue, ESC to Cancel ". Now press any key to continue
displaying more the help information. Continue pressing the key until
the prompt (:) reappears.
For example, ? ALTKEY. Pay attention to the status line prompts on the
bottom line of the screen if you get confused.
We brought up the window with the CTRL D key sequence. That's all
right for some, but you may prefer to use another key sequence. We are
now going to enter a command to change the key sequence required to
bring up the window. We'll do this one step at a time, so you can get
used to the status line at the bottom of the window.
Type the letter 'A'. The status line displays a list of all the
commands starting with the letter 'A'. Finish typing the word
'ALTKEY'. The status line now displays a short description of the
/ALTKEY command Press the space bar. The status line now shows the
required syntax for the /ALTKEY command. Type the letters 'ALT D' then
press ENTER to enter the entire command : ALTKEY ALTD
You just changed the window pop up key sequence to ALT D. From now on,
you must press the ALT D key sequence to pop up the window. This is
assumed throughout the remainder of the tutorial. Now let's test the
previous command. To exit from the window, press : ALT D
To see some previous commands, press: the UP key a few times. Notice
that Soft-ICE remembers commands that have been entered. Try editing
one just for fun. Some of the editing keys are:
When insert mode is on, notice that the cursor is in a block shape.
Now that you are somewhat familiar with the environment let's try some
more commands. Erase the command you were editing by pressing the HOME
key, then pressing the DEL key until the command is gone. Enter : WR.
The WR command makes the register window visible. The register window
displays the contents of the 8086 registers. Notice that the register
values reflect the location where the code was executing when you
invoked Soft-ICE.
Extend the vertical size of the Soft-ICE window by holding down the
ALT and the until the window is the entire length of the screen.
Notice the values of the CS and IP registers in the register window,
then enter : MAP
The MAP command displays a system memory map. The area of the current
instruction pointer (CS:IP) is highlighted. If you have a complex
memory map you may have to press a key a few times until the until the
prompt reappears.
Now try the following sequence a few times, noticing the (CS:IP)
registers in the register window. ALT D, release ALT and D, ALT D
Each time you bring the Soft-ICE window back up you will notice that
the CS and IP registers have changed. When CS and IP change you can
enter the MAP command again to see if the instruction pointer now
points to a different area. This little exercise demonstrates that
Soft-ICE is a system level debugger that pops up wherever the
instruction pointer happens to be when you press the Soft-ICE hot key
sequence. The instruction pointer is continuously changing because
there is a lot of activity happening behind the scenes even when you
are at the DOS prompt, such as timer interrupts, DOS device driver
polling, DOS busy waiting other interrupts, etc.
Press the F12 function key. The F12 function key defaults to be
assigned to the Soft-ICE VER command. It displays the Soft-ICE
copyright message and the version number.
We will now assign the F12 function key to the Soft-ICE RS command.
Enter : RS. This will temporarily show the program screen without the
Soft-ICE window. Press the space bar to get back to get back the
Soft-ICE window. Enter : FKEY F12 RS;
This assigns the RS command to the F12 key. The semi-colon represents
the ENTER key. Press the F12 key. Repeat this a few times to toggle
between the Soft-ICE window and the program screen. Now make sure the
Soft-ICE window is displayed, by pressing the F12 key if necessary.
You will notice RS displayed several times in the window. There is one
occurrence for each time you pressed the F12 key to show the program
screen.
Clear the Soft-ICE window by entering : CLS. Enter : FKEY F12 ^RS;.
The ^ symbol assigns the RS command to the F12 key, but makes it an
invisible command. Press the F12 key several times. Notice that the RS
command no longer displays in the Soft-ICE window. You can also assign
a sequence of Soft-ICE commands to a function key. Remember to place a
carriage return between each command.
This command tells Soft-ICE to generate interrupt 3's when break point
conditions are met. That's how Soft-ICE will communicate with DEBUG.
The default setting is HERE. ACTION HERE will cause control to return
directly to Soft-ICE. Use ACTION HERE when using Soft-ICE as a
stand-alone debugger.
For those of you not using DEBUG with this tutorial you might have to
improvise now. CODEVIEW works with ACTION NMI. Most other debuggers
will work with ACTION set to INT3. If your debugger doesn't, and you
need help improvising, refer to the complete description ACTION (see
section 5.4).
Now that you are familiar with some of the basics of using Soft-ICE,
let's learn some details by debugging the sample program (SAMPLE.ASM).
SAMPLE.ASM is a simple program written in assembly language by a
programmer named Jed. The program reads a keystroke from DOS and
displays a message telling whether the keystroke was a space.
Now press the space bar. Press several keys. Jed's program obviously
has a problem! Jed has spent hours studying this source code and is
certain there are no flaws in his logic. However, Jed borrowed some
'helper' routines from his friend Jake (get_key, is_space?). Jed is
somewhat suspect these routines but he cannot find the bug. The source
code for Jed's program looks like this:
Page 55,80
Title Sample
start:
mov ax,DATA ; Set up segments
mov es,ax
mov ds,ax
;----------------------------------------------------------;
; JAKE'S ROUTINES ;
;----------------------------------------------------------;
; Get Key Routine (one of Jake's routines)
get_key proc
mov ah,8
int 21H
mov char,al
ret
get_key endp
CODE Ends
End.
Jed has been using DEBUG but has not been able to pinpoint the
problem. As a recommendation from his nephew Jethro, Jed has purchased
Soft-ICE. He was somewhat reluctant to use it because he had tried a
hardware-assisted debugger but could never get it working quite right.
He was willing to try Soft-ICE because he could continue to use DEBUG
-- the only debugger he really understood.
In the hours Jed has spent trying to find this elusive bug, he has had
the suspicion that something is overwriting his code in some subtle
way. With Soft-ICE, Jed decides to set a range break point across his
code segment. Press : ALT D. The Soft-ICE window is back. Move the
window (by using CTRL and the Arrow keys) until DEBUG's register
display is visible.
It's time to set our first break point. Enter : BPR code-seg:0
code-seg:25 W
The BPR command sets a memory-range break point. The length of Jed's
code segment is 25H bytes, so the memory range specified goes from the
beginning of his code segment to the end. The W tells Soft-ICE to
break on a write. We want to catch any unexpected writes to Jed's
code.
Enter : BL
The BL command displays all break points. The display from BL looks
similar to the following display :
The 0 is the identifier for this break point. The range and W are
displayed as they were entered, and the count (since none was
specified) defaults to one. Now comes the moment of truth. Press ALT D
The window disappears again. To run SAMPLE from DEBUG, enter : G.
Press the space bar. Ok so far. Now press a non-space key. Our break
point just woke up DEBUG. The registers and single unassembled
instruction are displayed. Enter : U cs:address
CS:
MOV BYTE PTR [13],0
Jed says,"There it is! I just knew Jake's helper routines were the
problem! His code segment override instruction is writing a zero byte
right over my code! Who knows what that's doing!". Enter : U 0
Now we will take a quick look at how this problem would be solved
using Soft-ICE as a stand-alone debugger. But first we must exit from
debug.
Before exiting the debugger, it's always a good idea to disable all
the break points, unless ACTION is set to HERE. If you do not do this,
when a break point occurs and ACTION tries to return to a debugger
that is not loaded, the results are unpredictable. We've changed the
ACTION to INT3, so we have to disable the break point. To bring up the
window, press : ALT D. List the break point by entering : BL
List the break point again by entering : BL. The asterisk (*) after
the break point number shows that the break point is disabled. To
clear the break point, enter : BC 0
Enter BL again. Notice that there are no break point lines displayed.
Exit from Soft-ICE, then exit from the debugger, by entering :
X
Q
The next part of the tutorial demonstrates how Soft-ICE can be used to
find the same problem as a stand-alone debugger. Soft-ICE will be used
as a source level debugger. To prepare Soft-ICE to debug at source
level it must have been installed in your CONFIG.SYS file, and
extended memory allocated for symbols and source files. Soft-ICE can
only be used as a source level debugger if you have extended memory on
your system. If you do not have extended memory you may still want to
read through the rest of the tutorial to see the capabilities of
Soft-ICE with extended memory. If you have not loaded S-ICE.EXE in
your CONFIG.SYS file with memory reserved for symbols, do so at this
time.
You are now in Soft-ICE with SAMPLE.EXE loaded into memory. Notice
that Soft-ICE occupies the full screen. Soft-ICE switches to its wide
mode whenever a program loaded. The source from SAMPLE.ASM should be
visible in the code window. In addition, the register window and the
DATA windows are visible.
Step through one instruction by pressing F10. Notice that the reverse
video bar moves to the next instruction to be executed after a program
step.
Press F6. This places the cursor in the code window. Now experiment
with the Up, Down, pageUp, and pageDn keys to move the cursor and
scroll the source file. Move the cursor down to line 42 with the DOWN
key. Press F9.
We have just set an execution break point on line 42. The line should
be highlighted, showing you that a break point has been set on it.
Enter : BL. This shows the break point that we have just set.
Now press ALT D. This exits Soft-ICE, and causes the sample program to
execute until it encounters the break point on line 42. Soft-ICE
should immediately come back, with the reverse video bar on line 42.
Press F6 again. This will bring the cursor back to the command window.
Now enter : BC *. This will clear all the break points (there should
only be one set). Now exit from Soft-ICE by pressing ALT D. You are
back to the sample program. Type a few keys just to make sure it is
still broken.
Now pop Soft-ICE back up with ALT D. Since the bug has already
occurred, we want to restart the program. Enter : EXIT RD. This
command forces the sample program to exit. The R tells Soft-ICE to
restore the interrupt vectors to the state they were when the sample
program was loaded with LDR. The D tells Soft-ICE to delete any
currently pending break points. The R and the D are not necessary in
this case, but it is good to get in the habit of specifying them when
exiting a program that was loaded with LDR.EXE.
You are now back at the DOS prompt. Reload the program by entering :
LDR SAMPLE.EXE
Notice the suffix.EXE was specified this time. When the suffix is
specified, Soft-ICE does not attempt to load a symbol file or source
file. In this case the symbol file and source file are already in
memory. Enter : SYM. This displays the public symbols of the sample
program. Press Esc to get back to the prompt.
We will now set a range break point similar to the one we set while
using Soft-ICE as an assistant to debug. This time we will use symbols
to set the break point. Enter : BPR START .82 W. This will set a range
break point in our code segment from the symbol START to line 82 of
the source file. Enter : BL. You can verify that the break point has
been set properly.
To see the actual code press the F3 key. This places Soft-ICE in mixed
mode. Notice that the reverse video bar covers 2 lines. This is the
actual code line and the source code line of the current instruction.
Press the F3 key again. We are now in code mode. No source lines are
visible. The instruction above the reverse video bar is the
instruction that caused the range break point to go off. Press the F3
key again to get back to source mode.
Now we will fix the bug in the sample program. Exit the sample program
and go back to the DOS prompt by entering : EXIT RD. Re-load the
sample program by entering : LDR SAMPLE. EXE. Set the code window in
code mode by pressing the F3 key twice.
We will now use the Soft-ICE interactive assembler to fix the problem.
Enter: A not_space. Soft-ICE will prompt you with the address. Enter:
NOP
Press ENTER to exit from the assembler. Notice in the code window that
there is a NOP instruction in place of the CS over-ride at offset
003BH. Press the F3 key to get back to source mode, (the source code
of course is not modified). Press ALT D to run the mended sample
program. Enter spaces and some non-spaces characters. It works! You
fixed the bug! To get out of Jed's program, and return to DOS, press :
CTRL C
CLI
JMP $
Notice that the jump instruction jumps to itself. This infinite loop
would normally hang the system in an unrecoverable fashion. Enter :
BREAK ON. We have just turned on BREAK mode. BREAK mode will cause the
system to run slightly slower, but will allow Soft-ICE to come up even
when the system would normal be hung.
Exit from Soft-ICE by pressing ALT D. Your system is now hung. For
those non-believers, press : CTRL ALT DEL
[ ]
Brackets enclose an optional syntax item.
< >
Angle brackets enclose a list of items or choices.
x | y
Vertical bars separate alternatives. Use item x or item y.
count
Count is a byte value that specifies the number of time break
point conditions must be met before the actual break point
occurs. If no count is specified, the default value is 1. Each
time the Soft-ICE window is brought up, the counts are reset to
the values originally specified.
verb
Verb is a value that specifies what type access the break point
will apply to. It can be set to 'R' for reads, 'W' for write RW'
for reads and writes, or 'X' for execute.
address
Address is a value that is made of two 16-bit words, separated by
a colon. The first word is the segment address, and the second
word is the segment offset. The addresses can be constructed of
registers expressions, and symbols. The address may also contain
the special characters "$", ".", and "@". See section 3-8
(Command Syntax) for a description of these special characters.
break-#
Break-number is an identification number that identifies the
break point to use when you are manipulating break points e.g.,
editing, deleting, enabling, or disabling them). The break-number
can be a hexadecimal digit from 0 to F.
list
List is a series of break-# separated by commas or spaces.
mask
Mask is a bitmask that is represented as: combination of 1's,
0's, and X's. X's are don't-care bits.
GT, LT GT and LT
Command qualifiers that unsigned comparisons of values.
This command will cause a break point to occur if port 21H is written
to with the high order bit set.
04.01 Introduction
Soft-ICE has break point capability that has traditionally only been
available with hardware debuggers. The power and flexibility of the
80386 chip allows advanced break point capability without additional
hardware.
Break points can be set on memory location reads and writes, memory
range reads and writes, program execution and port accesses. Soft-ICE
assigns a one-digit hexadecimal number (0-F) to each break point. This
break-number is used to identify break points when you set delete,
disable, enable, or edit them.
All of Soft-ICE's break points are sticky. That means they don't
disappear automatically after they've been used; you must
intentionally clear or disable them using the BC or the BD commands.
Soft-ICE can handle 16 break points at one time. You can have up to
ten break points of a single type except for break points on memory
location (BPMs), of which you can only have four, due to restrictions
of the 80386 processor.
BPM, BPMB, BPMW, BPMD Set break point on memory access or execution
BPR Set break point on memory range
BPIO Set break point on I/O port access
BPINT Set break point on interrupt
BPX Set/clear break point on execution
CSIP Set CS:IP range qualifier
BPAND Wait for multiple break points to occur
Syntax :
BPM[size]address[verb][qualifier value][C=count]
Size :
B(yte), W(ord), D(oubleword)
The size is actually a range covered by this break point.
For example, if double word is used, and the third byte of
the double is modified, then a break point will occur. The
size is also important if the optional qualifier is
specified (see below).
Verb :
R, W, RW, or X
Qualifier :
EQ(ual), NE (Not Equal), GT (Greater than), LT (Less Than),
M (Mask)
These qualifiers are only applicable to the read and write
break points.
Value
A byte, word, or double word value, depending on the size
specified.
Comments :
The BPM commands allow you to set a break point on memory reads
or writes or execution.
All of the verb types except X cause the program to execute the
instruction that caused the break point. The current CS:IP will
be the instruction after the break point. If the verb type is X,
the current CS:IP will be the instruction where the break point
was set.
Notes :
Example :
BPM CS:1235 X
BPM DS:1000 W GT 5
Syntax :
Start-address, end-address :
start-address and end-address specify memory range.
Verb :
R, W, RW, T or TW
Comments :
The BPR command allows you to set a break point across a range of
memory.
Example :
Syntax :
Port :
A byte or word value.
Verb :
R (IN), W (OUT), or RW
Qualifier :
EQ(ual), NE (Not Equal), GT (Greater than), LT (Less Than),
M (Mask)
Comments :
The BPIO command allows you to set a break point on I/O port
reads or writes.
Example :
BPIO 21 W NE FF
This command defines a break point on I/O port access. The break
point will occur if the interrupt controller one mask register is
written with a value other than FFH.
This command defines a byte break point on I/O port read. The
break point action will occur the first time that I/0 port 3FE is
read with a value that has the two high order bits set to 1. The
other bits can be any value.
Syntax :
Int-number :
Interrupt number from 0 - FF hex
Value :
A byte or a word value
Comments :
Example :
BPINT 21 AH=4C
Syntax :
Comments :
Technical Note :
Example :
BPX.1234
Syntax :
NOT :
When NOT is specified, the break point will only occur if
the CS:IP pointer is outside the specified range.
OFF :
Turns off CS:IP checking
Comments :
When break point conditions are met, the CS:IP registers are
compared with a specified range. If they are within the range,
the break point is activated. To activate the break point when
CS:IP is outside the range, use the NOT parameter.
Example :
This command causes the break points to occur only the CS:IP is
NOT in the ROM BIOS when the break point conditions are met.
Syntax :
List :
A series of break-numbers separated by commas or spaces
* :
ANDs together all break points
Comments :
The BPAND command does a logical AND of two or more break points,
activating the break point only when conditions for all break
points are met.
Each time the BPAND command is used, the specified break point
numbers are added to the list until BPAND OFF is used.
Once break points have been ANDed together, each remains ANDed
until it is cleared, or until BPAND is turned off.
Example :
BPAND 0,2,3
Syntax :
BD list | *
List :
A series of break-numbers separated by commas or spaces
* :
Disables all break points
Comments :
Example :
BD 1,3
Syntax :
BE list | *
List :
A series of break-numbers separated by commas or spaces
* :
Enables all break points
Comments :
Example :
Syntax :
BL
Comments :
The BL command displays all break points that are currently set.
For each break point, BL lists the break-number, break point
conditions, break point state, and count.
Example :
BL
This command displays all the break points that have been
defined. A sample display, which shows four break points,
follows:
Syntax :
BPE break-number
Comments :
The BPE command loads the break point description into the edit
line for modification. The command can then be edited using the
editing keys, and re-entered by pressing the ENTER . This command
offers a quick way to modify the parameters of an existing break
point.
Example :
BPE 1
Syntax :
BPT break-number
Comments :
Example :
BPT 3
Syntax :
BC list | *
List :
A series of break-numbers separated by commas or spaces
* :
ANDs together all break points
Comments :
Example :
BC *
Syntax :
U [address] [L[=]length]
Length :
The number of instructions to be unassembled
Comments :
Example :
U $-10
U .499
Syntax :
R register-name [ [ = ]value] ]
Register-name :
Any register (FL for flags)
Value :
If register-name is any name other than FL, value is a hex
value or an expression. If register-name is FL, value is a
series of one or more of the following flag symbols, each
optionally preceded by a plus or minus sign : O (Overflow
flag), D (Direction flag), I (Interrupt flag), S (Sign
flag), Z (Zero flag), A (Auxiliary carry flag), P (Parity
flag), C (Carry flag).
Comments :
Examples :
RAH 5
R FL = OZP
R FL
This command displays the current flag values, and allows them to
be changed.
RFL O + A-C
This command toggles the O flag value, turns on the flag value,
and turns off the C flag value.
Syntax :
MAP
Comments :
Use the MAP command when A break point occurs and CS:IP is not in
a known memory region. You want to get control within a resident
program or system program. A range break point can be set based
on the starting address and size reflected by MAP. You suspect a
program or system component of writing over code outside of its
memory space. MAP is used to obtain the memory address of the
region to use with the CSIP command. You need to find out which
resident program owns certain interrupt vectors.
Example :
MAP
Start Length
0000:0000 0040 Interrupt Vector Table
0040:0000 0030 ROM BIOS Variables
0070:0000 00FE I/O System
016E:0000 06B7 DOS
0842:0000 02CE DOS File Table & Buffers
A000:0000 5E00 System BUS
F000:0000 1000 ROM BIOS
Display memory
Syntax :
Size :
B(yte), W(ord), D(ouble)
Length :
The number of bytes to be displayed.
Comments :
Example :
DW DS:00 L=8
Edit memory
Syntax :
Size :
B(yte), W(ord), D(ouble)
Data-list :
list of data objects of the specified size (Bytes, Words or
Double Words) or quoted strings separated by commas or
spaces. The quoted string can begin with a single quote or a
double quote.
Comments :
UP Move cursor up
DOWN Move cursor down
LEFT Move cursor right
RIGHT Move cursor left
SPACE Move cursor to next element
TAB Toggle between numeric and ASCII areas
ESC or ENTER Exit memory editor
As values are input, the actual memory locations are updated. All
numeric values are hex numbers. To toggle between the ASCII and
numeric display areas, press the TAB key.
Examples :
EB 1000:0
EB 8000:0 "Hello",0D
Syntax :
INT?
Comments :
The INT? command displays the address and the number the last
interrupt that happened.
Example :
INT?
Last Interrupt: 16
At: 0070:0255
Syntax :
Comments :
Examples :
? ALTKEY
H 10 + 14*2
This command displays: 0038 00056 "8". These are the hexadecimal,
decimal and ASCII representations of value of the expression "10
+ 14*2".
Syntax :
VER
Example :
VER
Syntax :
I [size] port
Size :
B(yte), W(ord), D(ouble)
Port :
A byte or word value
Comments :
The input from port commands are used to read and display a value
from a hardware port. Input can be done From byte or word ports.
If no size is specified, the default is byte.
Example :
I 21
Syntax :
O [size] port
Size :
B(yte), W(ord), D(ouble)
Port :
A byte or word value
Value :
A byte for a byte port or a word for a word port
Comments :
Example :
O 21 FF
Syntax :
Comments :
Example :
Go to address
Syntax :
G [=start-address] [break-address]
Comments :
Example :
G CS:1234
Syntax :
T [=start-address] [count]
Comments :
Example :
T = 1284 3
Program step
Syntax :
Comments :
Example :
Syntax :
HERE
Comments :
The HERE command executes until the program reaches the current
cursor line. HERE is only available when the cursor is in the
code window. If the code window is not visible or the cursor is
not in the code window, use the G command instead.
Example :
HERE
Force an interrupt
Syntax :
Interrupt-number :
a number in the range 00 - FF
Comments :
Example :
GENINT NMI
Syntax :
R :
Restore the interrupt vector table
D :
Delete all break points
Comments :
This function does NOT do any system resetting other than the
interrupt table when the R option is used. This means that BIOS
variables, video modes and other systems level data are not
restored.
Note :
EXIT R
LDR prog.EXE
The EXIT command will restore the interrupt table to the values
it contained before the program was loaded, then exit to the
command processor. By running the LDR utility and specifying the
.EXE suffix, the program is loaded back in without re-loading
symbols and source. The symbols and source will remain in memory.
Caution :
The EXIT command should be used with care. Since Soft-ICE can be
popped up at any time, a situation can occur where the DOS is not
in a state to accept an exit function call. Also, the EXIT
command does not do any program specific resetting. For instance,
the EXIT command does not reset the video mode. If your program
has placed the video BIOS and hardware in a particular video
mode, it will stay in that mode after the EXIT command.
Example :
EXIT R
Restores the interrupt table and exits the current program. The R
option should be used if exiting from a program loaded with the
Soft-ICE program loader LDR.EXE.
Syntax :
BOOT
Comments :
The BOOT command resets the system and retains Soft-ICE. BOOT is
required to debug boot sequences, DOS loadable drivers, and
non-DOS operating systems.
Example :
BOOT
Syntax :
HBOOT
Comments :
Example :
HBOOT
Syntax :
Int-number :
Any valid interrupt number (0-FFH). Use this option only if
a user-supplied break point qualification routine has taken
over that interrupt vector (see section 11.2).
Comments :
Example :
ACTION HERE
Syntax :
Comments :
If WARN ON is set, and ACTION is not HERE, then control will come
to Soft- ICE before the actual action occurs. The system displays
the current CS:IP and gives you the choice of continuing or
returning to Soft-ICE. Generally, you should choose to return to
Soft-ICE to continue your debugging. Only continue with the host
debugger if you know your debugger will not cause DOS or ROM BIOS
to be re-entered.
Example :
WARN ON
Syntax :
Comments :
The BREAK command allows popping up the Soft-ICE window when the
system is hung with interrupts disabled. Break mode can be used
for the entire debugging session, or it can be turned on and off
when it is required.
Example :
BREAK ON
This command turns on break mode. This means that the Soft-ICE
window can be brought up at any time, even if interrupts are
disabled.
Syntax :
Comments :
The I3HERE command lets you specify that any Interrupt 3 will
bring up the Soft-ICE window. This feature is useful for stopping
your program in a specific location.
Example :
I3HERE ON
This command turns on 13HERE mode. Any INT 3's generated after
this point will bring up the Soft-ICE window.
A Assemble code
S Search for data
F Fill memory with data
M Move data
C Compare two data blocks
Assemble code
Syntax :
A [address]
Comments :
WORD PTR and BYTE PTR are used to determine data size if there is
no register argument, for example: MOV BYTE PTR ES:[ 1234],1.
Use FAR and NEAR to explicitly assemble far and near jumps and
calls. If FAR or NEAR is not specified then all jumps and calls
are near.
Example :
A CS:1234
Syntax :
Data-list :
list of bytes or quoted strings separated by commas or
spaces. A quoted string can begin with a single quote or a
double quote.
Length :
length in bytes
Comments :
Example :
S DS:SI+10 L CX 'Hello',12,34
Syntax :
Data-list :
list of bytes or quoted strings separated by commas or
spaces. A quoted string can begin with a single quote or a
double quote.
Length :
length in bytes
Comments :
Example :
Move data
Syntax :
Length :
length in bytes
Comments :
Example :
Syntax :
Length :
length in bytes
Comments :
Example :
C 5000:100 L 10 6000:100
Syntax :
SHOW [B | start]
B :
This tells the show command to start the display with the
oldest instruction in the back trace buffer.
start :
The number of instructions back from the buffer end (last
instruction captured) to begin display.
Comments :
SHOW allows scrolling through the back trace buffer with the up,
down, Pageup and PaqeDn keys. To exit from SHOW you must press
the Esc key.
Note :
Before using the SHOW command, instructions must have been logged
with a back trace range. See chapter 9 for more information on
back trace ranges.
Hints :
Using SHOW in conjunction with the TRACE command will allow you
to see the instructions in the back trace history buffer from two
different points of view.
Example :
SHOW 40
Syntax :
start :
The number of instructions back from the buffer end (last
instruction captured) to begin trace simulation.
OFF :
Exit trace simulation mode.
Comments :
Note :
Hints :
Example :
TRACE 40
Syntax :
XT [R]
R :
Single step in reverse direction.
Comments :
Note :
Hint :
Example :
XT
Syntax :
XP
Comments :
Note :
Hint :
Example :
XP
Syntax :
XG [R] address
R :
Search for address in reverse direction.
Address :
Address to go to in the back trace history buffer.
Comments :
Note :
Example :
XG 273:1030
Syntax :
XRSET
Comments :
The XRSET command resets the back trace history buffer. This
command should be executed before setting a back trace range if
there is unwanted instruction information in the back trace
buffer.
Example :
XRSET
Syntax :
VECS [C|S|R]
C :
Compare current table with stored table
S :
Save current interrupt table to buffer
R :
Restore interrupt table from buffer
Comments :
The VECS command allows you to save and restore the interrupt
table to an internal Soft-ICE buffer. The actual table can also
be compared to the stored table with the differences displayed.
Example :
VECS C
This command compares the actual interrupt vector table with one
that had been previously stored in the Soft-ICE internal VECS
buffer.
Syntax :
C :
Compare buffer with address range
S :
Save address range to buffer
R :
Restore buffer to address range
Comments :
The SNAP command takes a snap shot of a memory block for later
comparison. The S option copies a block of memory to a buffer in
extended memory. The C option displays differences between the
buffer in extended memory and the actual memory specified by the
address range. The R option copies the buffer in extended memory
to the address range in conventional memory.
When the C option is used to compare the buffer with the address
range the output is in the following format :
Notes :
To use the SNAP command you must have specified the /TRA XXXX
switch on the S-ICE.EXE line in CONFIG.SYS.
The SNAP command saves data in the back trace history buffer. If
you are using back trace then you will have a conflict with SNAP.
Specifically, SNAP will overwrite back trace information if you
do a SNAP S when instruction history is in the back trace buffer.
Conversely, if you have saved a region with SNAP, then enabling a
back trace range will overwrite the SNAP buffer.
Example :
This command stores the data block from 2000:0 to 4000:0 in the
Soft-ICE back trace buffer.
Syntax :
EMMMAP
Comments :
Note :
Example :
EMMMAP
Three window types may be created with Soft-ICE: register, data, and
code. Any of these windows can be toggled on or off at any time. The
data and code windows can be of variable size; the register window is
fixed in size. The windows always remain in a fixed order. Starting
from the top of the screen, the order is register window, data window,
then code window.
Syntax :
WR
Comments :
The register window displays the 8086 register set and the
processor flags. Default Function: F2
Syntax :
WC [window-size]
Window-size :
a decimal number between one and 21.
Comments :
Note :
If you wish to move the cursor to the code window use the EC
command. See description of the EC command for more details.
Example :
WC 12
Syntax :
WD [window-size]
Window-size :
a decimal number between one and 21.
Comments :
Example :
WD 1
Syntax :
EC
Comments :
Note :
Syntax :
Comments :
When the code window is visible, the . command makes the current
source line or current instruction visible.
Syntax :
Comments :
Example :
PAUSE ON
Syntax :
Letter :
Any letter (A - Z)
Comments :
Example :
ALTKEY ALT Z
This command specifies that the key sequence ALT Z will now be
used to pop up the Soft-ICE window.
Syntax :
function-key-name :
F1, F2... F12
string :
The string consists of any valid Soft-ICE commands and the
special character ^ (caret) and ; (semicolon). A ^ is placed
in the string to make a command invisible. A ; is placed in
the string to denote a carriage return.
Comments :
Note :
Soft-ICE now has a definition file named S-ICE.DAT. You can place
function key assignments in this file so that function keys will
be automatically assigned when Soft-ICE is loaded. The syntax for
assigning a function key in the configuration file is:
function-key-name = "string"
FKEY F2 ^WR;
S-ICE.DAT example:
Syntax :
Comments :
The BASE command sets the current radix to base 10 or base 16.
Base 10 is of limited use in the narrow window because of window
width limitations. It also limits the amount of information
displayed in some commands in the wide mode.
When the current radix is base 10, all numbers and addresses
typed into and displayed by Soft-ICE are in decimal, When the
current radix is base 16, all numbers and addresses typed into
Soft-ICE are in hexadecimal except for the source line numbers
and the screen coordinates and sizes in the WIN command
Example :
BASE 16
Syntax :
CTRL-P
Comments :
Syntax :
Print-Screen
Comments :
Syntax :
x :
a decimal number between 1 and 4.
Comments :
The PRN command allows you to send output from the CTRL-P and
Print-Screen commands to a different printer port.
Example :
PRN COM 1
Syntax :
Comments :
The FLASH command lets you specify whether the screen will be
restored during any Trace and Program step commands. If you
specify that the screen is to be restored it is restored for the
brief time period that the P or T command is executing. This
feature is needed to debug sections of code that access video
memory.
Example :
FLASH ON
Syntax :
Comments :
With some EGA cards, colors will not be restored properly when
you exit from Soft-ICE. This is a problem with virtualizing EGA
video. The port 3DA is a video port used for two purposes. The
first is old CGA software polling 3DA for hsync and vsync. This
allows them to have flicker free output on some old CGA
controller cards. The second is that it is used to reset a
palette latch on EGA cards. Soft-ICE has an algorithm to avoid
having to constantly watch this port, which would slow down old
programs that think they are on a CGA. However, there can
occasional be circumstances where this algorithm does not work.
If you are using Soft- ICE on an EGA screen and you notice that
the colors are not restored correctly, then turn FLICK ON and
Soft-ICE will watch the 3DA port, fixing the problem.
Example :
FLICK ON
Syntax :
Comments :
Example :
WATCHV ON
Syntax :
RS
Comments :
Example :
RS
Clear window
Syntax :
CLS
Comments :
The CLS command clears the Soft-ICE window and moves the prompt
and the cursor to the upper left-hand corner the window.
Example :
CLS
Syntax :
Comments :
Example :
ALTSCR ON
Syntax :
N :
When N is specified, the window will be set to the narrow
width : 46 characters.
W :
When W is specified, the window will be set to full screen
width
start-row :
Number from 0 to 17 specifying row where window display
starts.
length :
Number from 8 to 25 specifying how many lines tall you want
the window to be.
start-column :
Column position of the left side of narrow window. The
start-row and start-column specify the upper left hand
corner of the narrow window. The start-column is ignored if
applied to the wide window.
Comments :
The WIN command allows you to modify the width and height of the
Soft-ICE display window.
Examples :
WIN N 4 9 30
WIN
This command toggles the window display width from its current
state (either wide or narrow) to the opposite state.
WIN W 10 8
This command causes the window display to start at row 10, and to
be 8 rows tall and go the width of the screen.
Display/set symbol
Syntax :
symbol-name :
A valid symbol name. The symbol name can end with an *
(asterisk). This allows searching if only the first part of
the symbol name is known. The , (comma) character can be
used as a wild card character in place of character in the
symbol-name.
value :
This is a word value that is used if you want to set a
symbol to a specific value.
Comments :
The SYM command is often useful for finding a symbol name when
you can only remember a portion of the name Two wild card methods
are available for locating symbols. If symbol-name ends with an
*, then all symbols that match the actual characters typed prior
to the * will be displayed regardless of their ending characters.
If a , is used in place of a specific character in symbol-name,
that character is a wild card character.
Examples :
SYM FOO*
All symbols that start with FOO are given the value 6000.
Syntax :
SYMLOC segment-address
Comments :
The MAP command will display at least two entries for each
program. The first is typically the environment and the second is
typically the program. The base address of the program is the
relocation value.
Example :
SYMLOC 1244 + 10
Syntax :
SRC [?]
Comments :
The SRC command toggles between source mode, mixed mode and code
mode in the code window.
Example :
SRC
This command changes the current mode of the code window. If the
mode was source, it becomes mixed. the mode was mixed, it becomes
code. If the mode was code, it becomes source. Default-Function
Key: F3
Syntax :
FILE [file-name]
Comments :
Note :
Only source files that have been loaded into extended memory with
LDR.EXE are available with the FILE command.
Example :
FILE MAIN.C
Syntax :
Line-number :
a decimal number
String :
a character string surrounded by quotes. The quotes can be
either single quotes or double quotes.
Comments :
The SS command searches the current source file for the specified
character string. If there is a match, the line that the string
was located in will be displayed as the top line in the code
window.
Note :
The code window must be visible and in source mode before using
the SS command.
Example :
SS 1 'if (i = = 3)'
06.01 Introduction
06.02 Loading Soft-ICE from the DOS Prompt
06.03 Loading Soft-ICE as a Loadable Device Driver
06.03.01 Soft-ICE Loading Switches
06.04 The Soft-ICE Initialization File S-ICE.DAT
06.04.01 Special Configuration Options
06.04.02 Function Key Assignments
06.04.03 Initialization Command Sequence
06.01 Introduction
* You do not have extended memory in your system Soft-ICE can only
load as a loadable device driver if you have extended memory.
* You only need to use Soft-ICE occasionally and there are no other
programs using extended memory. In some cases you may need some
of the features that require Soft-ICE to be loaded in CONFIG.SYS
but do not want Soft-ICE to be resident all of the time. In this
case Soft-ICE can be loaded in CONFIG.SYS to reserve extended
memory, and then disabled, by using the /UN switch, until Soft-
ICE is required. See section 6.3.1 for more information about the
/UN switch.
You can NOT enable all of Soft-ICE's features when loading from the
DOS prompt. If you will be using Soft-ICE as a stand-alone debugger,
it is recommended you load Soft-ICE in the CONFIG.SYS file.
S-ICE
In systems with extended memory, you should only load Soft-ICE from
the DOS prompt if you are not using extended memory for anything else
(e.g., VDISK, CACHE, HIMEM...). When you initially load Soft-ICE from
the command line or from a batch file, Soft-ICE will prompt you with a
warning message. This warning message is just to remind you that
Soft-ICE will overwrite the highest portion of extended memory when it
loads. You can suppress this warning prompt with the EXTENDED option
in the Soft-ICE configuration file S-ICE.DAT. For more information
about the EXTENDED option, see section 6.4.1.
In order to use all of the Soft-ICE features, you must first load
Soft-ICE as a loadable device driver in your CONFIG.SYS file. The
features this makes possible are:
* Back trace ranges and the SNAP command Loading as a device driver
allows Soft-ICE to allocate an extended memory buffer for a back
trace buffer. This buffer is also used for the Soft-ICE SNAP
command.
Any of the following configuration options that are needed should each
be placed on a separate line in the S-ICE.DAT file.
* COMPAQ: Compaq 386 and 386SX computer and some Compaq compatible
computers (including computers containing Micronix motherboards)
have 384K of non-contiguous extended memory. The COMPAQ option is
necessary if you want Soft-ICE to use this memory. Note that the
COMPAQ option is the same as the /C command line parameter in
Soft-ICE 1.X.
* NOLEDS: The NOLEDS option tells Soft-ICE not to set and clear the
keyboard LEDs while the Soft-ICE window is up. On some keyboards
the are timing problems that will cause Soft-ICE to lose
synchronization with the keyboard. If Soft-ICE hangs when you are
in the Soft-ICE window use this option. Note that the NOLEDS
option is the same as the /L command line parameter in Soft-ICE
1.X.
Function-key-name = "string"
String : The string may consist of any valid Soft-ICE commands and the
special characters ^ and ;. A ^ is placed in the string to make a
command invisible. A ; is placed in the string denote a carriage
return. The string must be enclosed in double quotes.
This will assign the Soft-ICE dump command to function key 12. When
F12 is pressed Soft-ICE will dump at offset 100H in the current data
segment. The semi-colon following the 100 represents the ENTER key.
INIT = "assignment-string"
Assignment string : The string consists of any valid SoftICE cmd and
the special characters ^ and ;. A ^ is placed in the string to make a
command invisible. A; is placed in the string denote a carriage
return. The string must be enclosed in double quotes.
This example will put the Soft-ICE window in full screen mode, create
a register window, create a data window one line long, create a code
window 12 lines long, and change the hot key sequence to CTRL X.
07.01 Introduction
07.02 Preparing for Symbolic or Source Debugging
07.02.01 Preparing for Symbolic Debugging Only
07.02.02 Preparing for Symbolic and Source Level Debugging
07.03 Reserving Memory for Symbols and Source Files
07.04 Loading Programs and Symbol Files
07.04.01 Loading Program, Symbols and Source
07.04.02 Loading Only Symbols and Source Files
07.04.03 Loading a Program With No Symbols or Source
07.05 Debugging With Symbols
07.06 Debugging With Source
07.06.01 Using Line Numbers
07.06.02 Using Source Mode in the Code Window
07.01 Introduction
Soft-ICE can load programs, symbol tables and source files for
enhanced debugging. Symbolic debugging allows you to set break points
and reference variables with symbol names rather than specifying
numeric addresses. Source level debugging allows you to step through
your program at the source code level rather than assembly code level.
Symbol and source line number information is extracted from the link
map file. The link map must be compatible with Microsoft's linker
version 3.60 or greater.
Symbols and source files reside in extended memory. You must have
sufficient extended memory for the symbols and source files. Source
files are not paged from the disk as in many debuggers. This allows
Soft-ICE to provide complete system debugging in source level, You can
debug T&SR's interrupt routines and other systems level code at the
source level.
2. Link your program with the proper switches to create a .MAP file
that contains a list of public symbols. If you are using Microsoft's
linker, the /MA switch is the proper switch to use. This .MAP file
must be identical to the .MAP file produced by Microsoft's linker,
version 3.60 or greater.
To prepare a program for both symbolic and source debugging, you must
do the following steps:
1. Compile or assemble each module that you wish debug at the source
level with the appropriate switch to put line number information into
the object files. With Microsoft languages you can use either the /Zi
or the /Zd switches. You may not want to do this with all files,
because the combined file sizes of the symbol file and all the source
files compiled with these switches must fit into the amount of
extended memory you have reserved with the /SYM loading switch in
CONFIG.SYS.
2. Link your program with the proper switches to create a .MAP file
that contains source line numbers and a list of public symbols. If you
are using Microsoft's linker, the /LI and /MA switches are the proper
switches to use. This .MAP file must be identical to the.MAP file
produced by Microsoft's linker, version 3.60 or greater.
Before loading programs, symbol files and source files you must
reserve extended memory for them. Extended memory is reserved when you
load Soft- ICE in CONFIG.SYS. Before reserving extended memory you may
want to add up the file sizes of the .SYM file and all of the source
files that you want to load. You must reserve at least this much
extended memory. You must use the
To load your program, symbols and source files in one step, you must
use LDR.EXE in the form:
LDR program-name
2. Load source files into extended memory. This step is done only if
source records exist in the .SYM file.
If you wish to load only symbols and source files (for debugging a
loadable device driver for example) you must use LDR.EXE in the form:
LDR program-name.SYM
Notice that the.SYM extension is specified. This will load the .SYM
file and source files into extended memory. When symbols are loaded by
this method your program or device driver symbols are assumed to be
referenced from 0:0. Since this is rarely the case you will need to
use the Soft-ICE command SYMLOC to locate the symbols. See the
description of the SYMLOC command in section 5.10 for a complete
description. An example of loading a symbol file called DRIVER.SYM is:
LDR DRIVER.SYM
To load a program file without loading the associated symbol file you
must use LDR.EXE in the form:
LDR program-name.extension
LDR TEST.EXE
If LDR.EXE does not find your source files on the same directory as
the program you are loading, LDR.EXE will prompt you for the path
names where it can find the source files. If you have source files on
several directories or are loading a program frequently this becomes
cumbersome. You can eliminate the need for prompting by using the DOS
environment variable SRC. LDR.EXE uses this environment variable to
find source files before prompting the user. The syntax for setting
the environment variable from the DOS prompt is:
After you have loaded your program and.SYM file you can begin
debugging your program symbolically. In general a symbol can be used
in any command in place of an address.
Symbols are also used by several Soft-ICE commands when addresses are
displayed. For example, the U command displays symbol names of labels
and procedures as it encounters them. There are two commands that are
helpful when you are symbolically debugging:
SYM: Use the SYM command to get a listing of symbol names and values,
or to change the value a symbol.
SYMLOC: Use the SYMLOC command to relocate the base of all of your
symbols. You would need to use the SYMLOC command when:
When source files are loaded, Soft-ICE allows you to view and step
through your source code as you are debugging. Soft-ICE offers two
different modes of source level debugging: mixed mode and source mode.
Use the SRC command to switch between modes.
Mixed mode shows source lines and the assembly language produced by
those source lines intermixed on the display. Mixed mode is useful
when you must debug at the assembly level, but use the source lines
for reference. Mixed mode is allowed whether the code window visible
or not.
Source mode strictly shows source lines on the display. Source level
debugging requires the code window to be visible.
BPX .450
The code window must be visible to enter source mode. If not visible,
use the WC command to make it visible. Once you are in source mode you
can use Soft-ICE commands switch to a different source file, view
source at any location in the file, scroll through the file, search
for strings in the file, and set break points in the file. For a
complete description of the following commands see their command
descriptions in chapters 4 and 5. The following list is a brief
overview of commands that are useful when debugging source code:
Make the code window visible (if it is not already) with WC command.
Toggle between source, mixed, and code modes with the SRC command.
Place a source file in the code window with the FILE command. For
example change from the current file to file MAIN.C enter:
FILE MAIN.C
Display source at a specific location within the source file with the
U command. To change the view to a specific line number or memory
address use the U command. You can specify actual addresses or line
numbers as a parameter to the command. For example, to view source in
the code window starting at source line 450 enter:
U .450
Locate the current instruction in the code window with the . (period)
command.
Move the cursor to the code window (if it is not) with the EC command.
Scroll the source with the keys up, down, PaqeUp, PageDn.
Set point-and-shoot break points with the BPX command. Simply place
the cursor on the source line that you wish to break on, then enter:
BPX
08.01 Introduction
08.02 Configuring the EMM Environment
08.02.01 Default EMM Pages
08.02.02 Customizing the EMM Page Map
08.02.02.01 Including and Excluding Areas from EMM
08.03 Other EMM Features
08.03.01 Increasing Conventional Memory
08.03.02 Automatic Page Frame Locating
08.04 EMM Debugging
08.01 Introduction
Soft-ICE has an expanded memory manager built into its kernel. The
Soft- ICE expanded memory manager supports the Lotus-Intel-Microsoft
4.0 specification. This Soft-ICE feature is useful if you are using
programs that support the EMM specification, or if you must backfill
your conventional memory to extend your conventional memory to 640K or
more.
Other 386 control programs that provide EMM capability (such as QEMM
or 386-to-the-MAX) will not co-exist with Soft-ICE. If you are using
those programs for EMM capability or backfilling, you can use the
Soft-ICE EMM manager in their place.
This will reserve 2 megabytes of extended memory for EMM use. See
section 6.3 (Loading Soft-ICE as a Loadable Device Driver) for details
of installing Soft-ICE in CONFIG.SYS.
* You may have a device such as a network that I the D000H area of
memory.
* You may want to fill more holes above 640K with EMM pages. This will
increase performance and usability of programs like Microsoft Windows.
To get maximum performance from Microsoft Windows you should fill
every available page with expanded memory.
To configure the EMM map you must use the utility EMMSETUP.EXE.
EMMSETUP.EXE allows the page map to be altered, then modifies
S-ICE.EXE with the changes. EMMSETUP makes its best guess on
automatically configuring the EMM map. EMMSETUP will try to fill much
of the address space as possible with mappable pages while working
around video cards and ROMS. If its guess is not good enough or not to
your liking you can override it. Overriding may be necessary if you
have a network, a special video adapter or a memory-mapped option
adapter. To configurethe EMM map enter :
EMMSETUP
If you are satisfied with EMMSETUP's guesses, press the F10 key and S-
ICE.EXE will be modified with these parameters. You must reboot before
any changes made to S-ICE.EXE will take effect. If you wish to
override EMMSETUP's guesses, do so at this time.
To include an area as EMM 4.0 memory simply guide the cursor to the
desired block, then type E. Conversely, to exclude an area from EMM
4.0 memory, guide the cursor to the block and type X. When you are
satisfied with your changes, press F10 to exit the program. All
changes are automatically stored in the S-ICE.EXE file. If you wish to
exit without modifying S-ICE.EXE press ESC. You must reboot before any
changes made to S-ICE.EXE will take effect.
S-ICE.EXE with the /EMM switch has two features that are automatically
enabled depending on your system configuration. These features are
backfilling and relocating the page frame.
When debugging EMM programs, the EMMMAP command may also be very
useful. See section 5.6 for more information.
DB H1 P3 0
where handle and page are the same as above. offset1 is a number from
0 to 4000H, specifying the offset from the beginning of the page,
where the first data block to be compared is located. offset2 is a
number from 0 to 4000H, specifying the offset from the beginning of
the page, where the second data block to be compared is located.
Example:
C H2 P4 00 L10 1000
D 0:0
09.01 Introduction
09.02 Using Back Trace Ranges
09.03 Special Notes
09.01 Introduction
2. Back trace ranges degrade system performance while they are active.
By limiting the range to an area that you are interested in, you can
improve system performance greatly.
1. The SHOW command allows you to display instructions from the back
trace history buffer. You must specify how many instructions you wish
to go back in the buffer.
The T and TW verbs do not cause break points instead they log
instruction information that can be displayed later with the SHOW or
TRACE commands.
SHOW 50
TRACE 50
7. After you have entered trace simulation mode, you can trace through
the sequence of instructions by using the XT, XP, or XG commands. This
allows you to re-enact the program flow. For example, you can single
step through the sequence of instructions in the buffer, starting at
the instruction specified by the TRACE command, by typing:
XT
XT
.
.
.
XT
The XT command single steps through the back trace history buffer.
The XP command program steps through the back trace history buffer.
TRACE OFF
As you peruse instructions from the back trace history buffer with the
SHOW and TRACE commands, you may notice peculiarities in instruction
execution. These are caused by jumps in and out of the specified
range. These usually occur at jumps, calls, returns and entry points.
When you have a hang problem or other difficult bug that requires back
trace ranges, you must often use very large ranges in order to narrow
the scope of the problem. Once you have a better idea of the specific
problem area, you go to smaller ranges.
Large back trace ranges are often very slow. When using large ranges
you are usually trying to get a general idea where the problem is.
Soft-ICE has a special 'COARSE' mode for doing large ranges. This
speeds up the ranges a factor of three or more, but limits the amount
of instructions in the history buffer.
Coarse ranges work best for large ranges and tend to be less effective
for small ranges.
To enable a 'coarse' back trace range, use the BPR command with the TW
verb instead of the T verb. For example:
10.01 Introduction
10.02 Running Soft-ICE with MagicCV or MagicCVW
10.03 Special Considerations
10.04 The Soft-ICE ACTION command
10.01 Introduction
In the rest of this chapter, statements about MCV will apply to both
MagicCV and MagicCVW, and statements about CV will apply to both
CodeView and CodeView for Windows.
To use Soft-ICE 2.0 and MCV together, you must install S-ICE.EXE as a
loadable device driver. S-ICE.EXE comes on the Soft-ICE diskette. S-
ICE.EXE replaces NUMEGA.SYS in CONFIG.SYS. Use the /MCV, /EMM, and the
/EXT switches as if using MagicCV or MagicCVW alone. There are
additional switches that you may want to use for Soft-ICE. Refer to
chapter 6 for information about these switches.
Two Virtual Machines : When you are using both Soft-ICE and MCV
together, you must keep in mind that CV is in a separate virtual
machine from the target environment. You can pop Soft-ICE up from
either virtual machine, i.e., when CV is running, or when the target
program is running.
CodeView's SHELL command : If you run the DOS shell from within the
CodeView virtual machine, the DOS shell is part of the virtual
machine. Because of this, you should not run any TSRs when you are in
the DOS shell. If you do, when you exit CodeView the TSRs will
disappear along with the virtual machine. This is dangerous, because
any interrupt vectors that were not restored could hang your machine.
Soft-ICE was designed to work well with other debuggers. Each debugger
offers different features, and therefore can require special
treatment. This section will describe some ways to use several
debuggers effectively.
Many debuggers use DOS and ROM BIOS to perform their display and
keyboard I/O. Special consideration must be taken when using these
debuggers with Soft-ICE (e.g., DEBUG, SYMDEB, and CODEVIEW), because
DOS and ROM BIOS are not fully re-entrant. If a break point occurs
while code is executing in DOS or BIOS, a re-entrancy problem can
occur.
Note that Soft-ICE itself does not use DOS or ROM BIOS calls in its
debugging commands. This means that you can use Soft-ICE any time,
without the worry of re-entrancy problems.
In most cases, the action that should be taken after a break point is
reached is INT3. For instance, DEBUG and SYMDEB will work best with
ACTION set to INT3.
If INT3 doesn't work with your debugger, try INT1 or NMI. CODEVIEW
works best with ACTION set to NMI.
When a break point is set, you must be careful not to set off the
break point unintentionally. For instance, if you set a memory break
point at 0:0, then use your debugger to dump memory location 0:0,
Soft-ICE will be triggered. If ACTION is set to go to your debugger,
then your debugger will be triggered by itself. Since some debuggers
cannot be re-entrant, this could be a fatal problem. This problem can
also occur with other debugging functions, such as editing or
unassembling.
The 80386 has 4 break point registers that are available for use by
debuggers. Soft-ICE uses these for its memory byte, word and double
word break points. If the debugger you are using Soft-ICE with uses
these debug registers there will be a conflict. There are two ways to
handle this problem.
1. Disable the use of 80386 break point registers in the debugger you
are using Soft-ICE with. Check the documentation of your other
debugger for a description of how to do this.
* Bring up the Soft-ICE window before you start the other debugger.
* Turn on Soft-ICE's break mode with the BREAK command (you may want to
do this in the INIT statement of S-ICE.DAT if you are doing this
frequently).
* Start up your other debugger.
* You may now pop up the Soft-ICE window and turn the Soft-ICE break
mode off if desired.
Occasionally you may have the need for a very specific set of break
point conditions. If the special conditions require qualifying
register values or memory values, you can write a break point
qualification routine.
All registers are identical to the values when the Soft-ICE break
point occurred. It is the responsibility of the qualification routine
to save and restore the registers. If your qualification routine
detects a match of break point conditions, it can do a variety of
activities. Some examples of useful activities that a routine can do
when a match is found are:
5. Set the Soft-ICE general break point conditions. When any of these
break point conditions are met, your qualification routine will be
called.
A 9000:0
9000:0 CMP AX,3
9000:3 JNE 10
9000:5 CMP BX,4
9000:7 JNE 10
9000:A CMP CX,5
9000:D JNE 10
9000:F INT3
9000:10 IRET
Now that the routine is in memory, you must point an interrupt vector
to the routine. For this example, we arbitrarily pick INT 99H. To
place 9000:0H in the INT 99H vector enter:
ED 0:99*4 9000:0
Set the ACTION command so that Soft-ICE will call your break point
qualification routine on every break point.
ACTION 99
I3HERE ON
Now you need to set the break points. For this example, we are just
interested when the registers are: AX = 3, BX = 4, CX = 5 in a
specific program, and we do not want any further qualification. To do
this, use a range break point on memory read :
When Soft-ICE pops up, the instruction pointer will be pointing at the
INT3 in your qualification routine (9OOO:FH in our example). To get to
the instruction after the one that caused the break point, you must
change the instruction pointer to point to the IRET instruction
(F000:10H in the example) and single step one time. This is
accomplished with the following Soft-ICE commands
RIP IP + 1
T
After your break conditions have gone off, remember to change the
ACTION command back to ACTION HERE that subsequent break points do not
go through your qualification routine.
When debugging EMM programs, the EMMMAP command may also be very
useful. See section 5.6 for more information.
DB H1 P3 0
where handle and page are the same as above. offset1 is a number from
0 to 4000H, specifying the offset from the beginning of the page,
where the first data block to be compared is located. offset2 is a
number from 0 to 4000H, specifying the offset from the beginning of
the page, where the second data block to be compared is located.
Example :
C H2 P4 00 L10 1000
D 0:0
DB M 2 0:0
This command will dump bytes from start of the megabyte starting at
linear address 200000H.
where megabyte and address1 are the same as above. address2 specifies
the address in the specified megabyte, where the second data block to
be compared is located.Example:
D M 0
SoftICE Tutorial
Introduction
Loading SoftICE
Building the GDIDEMO Sample Application
Loading the GDIDEMO Sample Application
Controlling the SoftICE Screen
Tracing and Stepping through Source Code
Viewing Local Data
Setting Point-and-Shoot Breakpoints
Setting a One-Shot Breakpoint
Setting a Sticky Breakpoint
Using SoftICE Informational Commands
Using Symbols and Symbol Tables
Setting a Conditional Breakpoint
Setting a BPX Breakpoint
Editing a Breakpoint
Setting a Read-Write Memory Breakpoint
Introduction
* Load SoftICE
* Build an application
* Load the application source and symbol files
* Trace and step through source code and assembly language
* View local data and structures
* Set point-and-shoot breakpoints
* Use SoftICE informational commands to explore the state of the
application
* Work with symbols and symbol tables
* Modify a breakpoint to use a conditional expression
Each section in the tutorial builds upon the previous sections, so you
should perform them in order.
Note: The examples is this tutorial are based on Windows NT. If you
are using Windows 95, your output may vary slightly.
Loading SoftICE
To load SoftICE for Windows 95, enter the command WINICE. To load
SoftICE for Windows NT, do one of the following:
Note: Once you load SoftICE, you cannot deactivate it until you reboot
your PC.
To verify that SoftICE is loaded, press the SoftICE hot key sequence
Ctrl-D. The SoftICE screen should appear. To return to the Windows
operating system, use the X (exit) or G (go to) command (F5).
C:\MSTOOLS\SAMPLES\WIN32\GDIDEMO>NMAKE
2. Either choose OPEN MODULE from the File menu or click the OPEN
button : The Open window appears.
4. Either choose LOAD from the Module menu or click the LOAD button to
load GDIDEMO.
The SoftICE screen is your central location for viewing and debugging
code. It provides up to seven windows and one help line to let you
view and control various aspects of your debugging session. By
default, it displays the following:
Help line: Provides information about SoftICE commands and shows the
active address context.
2. To see all the source files that SoftICE loaded, enter the FILE
command with the wild card character:
:FILE *
3. Many SoftICE windows can be scrolled. If you have a mouse, you can
click on the scroll arrows. If not, SoftICE provides key sequences
that let you scroll specific windows. Try these methods for scrolling
the Code window:
:U EIP
You can also use the . (dot) command to accomplish the same thing:
:.
The following steps show you how to use SoftICE to trace through
source code:
:T
Execution proceeds to the next source line and highlights it. At this
point, the following source line should be highlighted:
if(!hPrevInst)
:SRC
Hint: The T command does not trace into a function call if the source
code is not available. A good example of this is Win32 API calls. To
trace into a function call when source code is not available, use the
SRC command (F3) to switch into mixed or assembly mode.
The Locals window displays the current stack frame. In this case, it
contains the local data for the WinMain function. The following steps
illustrate how to use the Locals window:
2. Enter the T command again. The Locals window contains the parameter
passed to the RegisterAppClass (hInstance) and a local structure
wndClass. The structure tag wndClass is marked with a plus sign (+).
This plus sign indicates that you can expand the structure to view its
contents.
This section shows you how to set two handy types of point-and-shoot
breakpoints: one-shot and sticky breakpoints.
1. To shift focus to the Code window, either use your mouse to click
in the window or press Alt-C.
If you wanted to shift focus back to the Command window you could
press Alt-C again. Setting Point-and-Shoot Breakpoints
2. Either use the Down arrow key, the down scroll arrow, or the U
command to place the cursor on line 61, the first call to the Win32
API function RegisterClass. If you use the U command, specify the
source line 61 as follows:
:U .61
3. Use the HERE command (F7) to execute to line 61. The HERE command
executes from the current instruction to the instruction that contains
the cursor. The HERE command sets a one-shot breakpoint on the
specified address or source line and continues execution until that
breakpoint triggers. When the breakpoint is triggered, SoftICE
automatically clears the breakpoint so that it does not trigger again.
if(!RegisterClass(&wndClass))
Note: You can do the same thing by using the G (go) command and
specifying the line number or address to which to execute:
:G .61
1. Find the next call to RegisterClass that appears on source line 74.
With the cursor on line 74, enter the BPX command (F9) to set an
execution breakpoint. The BPX command sets an execution breakpoint by
inserting an INT3 instruction into the code. Note that the line is
highlighted when you set a breakpoint.
:G
When the INT3 instruction is executed, SoftICE pops up. Unlike the
HERE command, which sets a one-shot breakpoint, the BPX command sets a
sticky breakpoint. A sticky breakpoint remains until you clear it.
:BL
00) BPX #0137:00402442
:? .74
void * = 0x00402442
:P RET
msg.wParam = 1;
7. Enter the BC command with the wild card parameter to clear all the
breakpoints:
BC *
1. The H and Class commands work best when you have more room to
display information, so use the WL command to close the Locals window.
Closing this window automatically increases the size of the Command
window.
:H CLASS
Display window class information
CLASS [-x] [process | thread | module | class-name]
ex: CLASS USER
:CLASS GDIDEMO
The output of the CLASS command provides summary information for each
window class registered on behalf of the GDIDEMO process. This
includes the class name, the address of the internal WINCLASS data
structure, the module which registered the class, the address of the
default window procedure for the class, and the value of the class
style flags.
:CLASS -X
Class Name Handle Owner WndwProc Styles
---------------Application Private---------------
BOUNCEDEMO A018A3B0 GDIDEMO 004015A4 00000003
DRAWDEMO A018A318 GDIDEMO 00403CE4 00000003
MAZEDEMO A018A280 GDIDEMO 00403A94 00000003
XFORMDEMO A018A1E8 GDIDEMO 00403764 00000003
POLYDEMO A018A150 GDIDEMO 00402F34 00000003
GDIDEMO A018A0C0 GDIDEMO 004010B5 00000003
Now that you are familiar with using SoftICE to step, trace, and
create point-and-shoot style breakpoints, it is time to explore
symbols and tables. When you load symbols for an application, SoftICE
creates a symbol table that contains all the symbols defined for that
module.
1. Use the TABLE command to see all the symbol tables that are loaded:
:TABLE
GDIDEMO [NM32]
964657 Bytes Of Symbol Memory Available
:TABLE GDIDEMO
2. Use the SYM command to display the symbols from the current symbol
table. With the current table set to GDIDEMO, the SYM command produces
output similar to the following abbreviated output:
:SYM
.text(001B)
001B:00401000 WinMain
001B:004010B5 WndProc
001B:004011DB CreateProc
001B:00401270 CommandProc
001B:00401496 PaintProc
001B:004014D2 DestroyProc
001B:004014EA lRandom
001B:00401530 CreateBounceWindow
001B:004015A4 BounceProc
001B:004016A6 BounceCreateProc
001B:00401787 BounceCommandProc
001B:0040179C BouncePaintProc
This list of symbol names is from the .text section of the executable.
The .text section is typically used for procedures and functions. The
symbols displayed in this example are all functions of GDIDEMO.
:BPX LockWindowInfo
Editing a Breakpoint
From the LockWindowInfo function prototype on source line 47, you can
see that the function accepts one parameter of type HWND and returns a
void pointer type. The HWND parameter is the handle to the window that
is attempting to draw information within its client area. At this
point, you want to modify the existing breakpoint, adding a
conditional breakpoint to isolate a specific HWND value.
1. Before you can set the conditional expression, you need to obtain
the HWND value for the POLYDEMO window. The HWND command provides
information about application windows. Use the HWND command and
specify the GDIDEMO process:
:HWND GDIDEMO
The following example illustrates what you should see if you are using
Windows NT. If you are using Windows 95, your output will vary.
The POLYDEMO window handle is bold and underlined. This is the window
handle you want to use to form a conditional expression. If the
POLYDEMO window does not appear in the HWND output, exit SoftICE using
the G or X commands (F5) and repeat Step 1 until the window is
created.
The value used in this example is probably not the same value that
appears in your output. For the exercise to work correctly, you must
use the HWND command to obtain the actual HWND value on your system.
Using the POLYDEMO window handle, you can set a conditional expression
to monitor calls to LockWindowInfo looking for a matching handle
value. When the LockWindowInfo function is called with the POLYDEMO
window handle, SoftICE pops up.
:BPE 0
When you use the BPE command to modify an existing breakpoint, SoftICE
places the definition of that breakpoint onto the command line so that
it can be easily edited. The output of the BPE command appears:
:BPX LockWindowInfo
The cursor appears at the end of the command line and is ready for you
to type in the conditional expression.
Note: Win32 applications pass parameters on the stack and at the entry
point of a function; the first parameter has a positive offset of 4
from the ESP register. Using the SoftICE expression evaluator, this is
expressed in the following form: ESP->4. ESP is the CPU stack pointer
register and the "->" operator causes the lefthand side of the
expression (ESP) to be indirected at the offset specified on the
righthand side of the expression (4). For more information on the
SoftICE expression evaluator refer to Chapter 8: Using Expressions on
page 125 and for referencing the stack in conditional expressions
refer to Conditional Breakpoints on page 114.
1. Obtain the pointer value for the windows instance data by executing
up to the return statement on source line 57:
:G .57
:BPMD EAX
The BPMD command uses the hardware debug registers provided by Intel
CPUs to monitor reads and writes to the Dword value at a linear
address. In this case, you are using BPMD to trap read and write
accesses to the first Dword of the window instance data.
:BL
00) BPX LockWindowInfo IF ((ESP->4)==0x100172)
01) BPMD #0023:001421F8 RW DR3
:BD 0
:BL
00) * BPX _LockWindowInfo IF ((ESP->4)==0x100172)
01) BPMD #0023:001421F8 RW DR3
:BE breakpoint-index-number
When SoftICE pops up due to the memory breakpoint, you are in the
PolyRedraw or PolyDrawBez function. Both functions access the
nBezTotal field at offset 0 of the POLYDRAW window instance data.
:BC *
Note: You can use the wildcard character (*) with the BC, BD, and BE
commands to clear, disable, and enable all breakpoints.
Using Breakpoints
Introduction
Types of Breakpoints Supported by SoftICE
Breakpoint Options
Execution Breakpoints
Memory Breakpoints
Interrupt Breakpoints
I/O Breakpoints
Window Message Breakpoints
Understanding Breakpoint Contexts
Virtual Breakpoints
Setting a Breakpoint Action
Conditional Breakpoints
Conditional Breakpoint Count Functions
Using Local Variables in Conditional Expressions
Referencing the Stack in Conditional Breakpoints
Performance
Duplicate Breakpoints
Elapsed Time
Breakpoint Statistics
Referring to Breakpoints in Expressions
Manipulating Breakpoints
Using Embedded Breakpoints
Introduction
All SoftICE breakpoints are sticky, which means that SoftICE tracks
and maintains a breakpoint until you intentionally clear or disable it
using the BC or the BD command. After you clear breakpoints, you can
recall them with the BH command, which displays a breakpoint history.
You can set up to 256 breakpoints at one time in SoftICE. However, the
number of breakpoints you can set on memory location (BPMs) and I/O
ports (BPIOs) is a total of four, due to restrictions of the x86
processors.
* Memory Breakpoints: SoftICE uses the x86 debug registers to break when
a certain byte/word/dword of memory is read, written, or executed. You
can use the BPM command to set memory breakpoints.
Breakpoint Options
You can qualify each type of breakpoint with the following two
options:
Execution Breakpoints
If you are using a Pentium processor and a mouse, you can use the
mouse to set or clear point-and-shoot (sticky) and one-shot
breakpoints. To set a sticky breakpoint, double-click the line on
which you want to set the breakpoint. SoftICE highlights the line to
indicate that you set a breakpoint. Double-click the line again to
clear the breakpoint. To set a one-shot breakpoint, click the line on
which you want to set the breakpoint and use the HERE command (F7) to
execute to that line.
Use the BPX command with any of the following parameters to set an
execution breakpoint:
IF expression:
Refer to Conditional Breakpoints.
DO "command1;command2;":
Refer to Setting a Breakpoint Action.
Example:
BPX WinMain
Memory Breakpoints
A memory breakpoint uses the debug registers found on the 386 CPUs and
later models to monitor access to a certain memory location. This type
of breakpoint is extremely useful for finding out when and where a
program variable is modified, and for setting an execution breakpoint
in read-only memory. You can only set four memory breakpoints at one
time, because the CPU contains only four debug registers.
Example:
Interrupt Breakpoints
interrupt-number:
Number ranging from 0 to 255 (0 to FF hex).
IF expression:
Refer to Conditional Breakpoints.
DO "command1;command2;":
Refer to Setting a Breakpoint Action.
Example:
BPINT 2E IF EAX==1E
You can use the BPINT command to trap software interrupts, for
example, INT 21 made by 16-bit Windows programs. Note that software
interrupts issued from V86 mode do not pass through the IDT vector
that they specify. INT instructions executed in V86 generate processor
general protection faults (GPF), which are handled by vector 0xD in
the IDT. The Windows GPF handler realizes the cause of the fault and
passes control to a handler dedicated to specific V86 interrupt types.
The types may end up reflecting the interrupt down to V86 mode by
calling the interrupt handler entered in the V86 mode Interrupt Vector
Table (IVT). In some cases, a real-mode interrupt is reflected
(simulated) by calling the real-mode interrupt vector.
Example:
BPX *($0:(21*4))
I/O Breakpoints
Notes: Under Windows 95, SoftICE relies on the I/O permission bitmap,
which restricts I/O trapping to ring 3 code.
R, W, and RW :
Break on reads (IN instructions), writes (OUT instructions), or
both, respectively.
IF expression:
Refer to Conditional Breakpoints.
DO "command1;command2;":
Refer to Setting a Breakpoint Action.
When an I/O breakpoint triggers and SoftICE pops up, the current
instruction is the instruction following the IN or OUT that caused the
breakpoint to trigger. Unlike BPM breakpoints, there is no size
specification; any access to the port-number, whether byte, word, or
dword, triggers the breakpoint. Any I/O that spans the I/O breakpoint
will also trigger the breakpoint. For example, if you set an I/O
breakpoint on port 2FF, a word I/O to port 2FE would trigger the
breakpoint.
Example:
window-handle:
Value returned when the window was created; you can use the HWND
command to get a list of windows with their handles.
L:
Signifies that the window message should be printed to the
Command window without popping into SoftICE.
begin-message:
Single Windows message or the lower message number in a range of
Windows messages. If you do not specify a range with an
end-message, then only the begin-message will cause a break. For
both begin-message and end-message, the message numbers can be
specified either in hexadecimal or by using the actual ASCII
names of the messages, for example, WM_QUIT.
end-message:
Higher message number in a range of Windows messages.
IF expression:
Refer to Conditional Breakpoints.
DO "command1;command2;":
Refer to Setting a Breakpoint Action.
When specifying a message or a message range, you can use the symbolic
name, for example, WM_NCPAINT. Use the WMSG command to get a list of
the window messages that SoftICE understands. If no message or message
range is specified, any message will trigger the breakpoint.
Example:
Virtual Breakpoints
DO "command1;command2;"
Conditional Breakpoints
All SoftICE breakpoint commands (BPX, BPM, BPIO, BMSG, and BPINT)
accept conditional expressions using the following syntax:
Many of the previous examples use the thread and process intrinsic
functions provided by SoftICE. These functions refer to the active
thread or process in the operating system. In some cases, the examples
precede the function name with an underscore "_". This is a special
feature that makes it easier to refer to a dynamic value such as a
register's contents or the currently running thread or process as a
constant. The following examples should help to clarify this concept:
? EAX
00010022
bpx eip IF (eax == 10022)
? tid
8
bpx eip IF (tid == 8)
* BPCOUNT
* BPMISS
* BPTOTAL
* BPLOG
* BPINDEX
BPCOUNT
The value for the BPCOUNT function is the current number of times that
the breakpoint has been evaluated as TRUE.
Example:
Once the full expression returns TRUE, SoftICE pops up, and all
instance counts (BPCOUNT and BPMISS) are reset to 0.
BPMISS
The value for the BPMISS expression function is the current number of
times that the breakpoint was evaluated as FALSE.
Example:
BPTOTAL
The value for the BPTOTAL expression function is the total number of
times that the breakpoint was triggered.
Example:
if (!(bptotal%COUNT))
The COUNT is the frequency with which you want the breakpoint to
trigger. If COUNT is 4, SoftICE pops up every fourth time the
breakpoint triggers.
BPLOG
Use the BPLOG expression function to log the breakpoint to the history
buffer. SoftICE does not pop up when logged breakpoints trigger.
Note: Actions only execute when SoftICE pops up, so using actions with
the BPLOG function is pointless.
Example:
Any time the breakpoint triggers and the value of EAX equals 1,
SoftICE logs the breakpoint in the history buffer. SoftICE will
not popup.
BPINDEX
Example:
Foobar Function
Source code lines 1 and 2 are outside the function body. These lines
execute the prologue code. If you use a local variable at this point,
you receive the following symbol error:
Set the conditional on the source code line 3 where the local variable
fooTmp is declared and initialized, as follows:
:BPX .3 if(foo==0)
Source code line 13 marks the end of the function body. It also begins
epilogue code execution; thus, local variables and parameters are out
of scope. To set a conditional at the end of the foobar function, use
source line 12, as follows:
:BPX.12 if(fooTmp==1)
If you create your symbol file with full symbol information, you can
access function parameters and local variables through their symbolic
names, as described in Using Local Variables in Conditional
Expressions. If, however, you are debugging without full symbol
information, you need to reference function parameters and local
variables on the stack. For example, if you translated a module with
publics only or you want to debug a function for an operating system,
reference function parameters and local variables on the stack.
PUSH EBP
MOV EBP,ESP
SUB ESP,size (locals)
Use either the ESP or EBP register to address parameters. Using the
EBP register is not valid until the PUSH EBP and MOV EBP, ESP
instructions are executed. Also note that once space for local
variables is created (SUB ESP,size) the position of the parameters
relative to ESP needs to be adjusted by the size of the local
variables and any saved registers.
BPX IsWindow
When this breakpoint is triggered, the prologue has not been executed,
and parameters can easily be accessed through the ESP register. At
this point, use of EBP is not valid.
Note: Once the space for local variables is allocated on the stack,
the local variables can be addressed using a negative offset from EBP.
The first local variable is at EBP-4. Simple data types are typically
Dword sized, so their offset can be calculated in a manner similar to
function parameters. For example, with two pointer local variables,
one will be at EBP-4 and the other will be at EBP-8.
Performance
Duplicate Breakpoints
Elapsed Time
The Pentium cycle counter is highly accurate, but you must keep the
following two issues in mind:
Breakpoint Statistics
You can combine the prefix "BP" with the breakpoint index to use as a
symbol in an expression. This works for all BPX and BPM breakpoints.
SoftICE uses the actual address of the breakpoint.
Example:
U BP0
Manipulating Breakpoints
BD Disable a breakpoint
BE Enable a breakpoint
BL List current breakpoints
BPEEdit a breakpoint
BPTUse breakpoint as template
BC Clear (remove) a breakpoint
BH Display breakpoint history