Symbolic Debugging MASM programs using SoftICE
http://asm.tsx.org ![]()
This Article will describe how to set up MASM and SoftICE to be able to use
symbolic debugging.
Well, I have had a pain trying to get masm produced executables to debug
correctly with SoftICE. After some kludging I've finally figured it out...
Its actually simple to do, but if you dont know what you're doing (or haven't
read your manual), its quite a pain. Set these options when you build your
project and you should have no problems debugging it with SoftICE.
Setting up the Assssembler
ML /COFF /Zi [...]
The /COFF statement is required to generate the correct object file format to
use with SoftICE.
Setting up the Linker
Link /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV [...]
The /SUBSYSTEM:WINDOWS statement causes the linker to generate a Windows GUI
application. This could be changed to CONSOLE if necessary.
Setting up SoftICE This batch file will translate the symbol information and package the source code. This will allow you full symbolic and source level debugging. It will then launch the debugger amd break on the module's entry point (WinMain, DllMain, or DriverEntry). This batch file will completely replace the use of Loader32.exe, giving quick and easy access to the debugger from the command line.
rem DEBUG.BAT @echo off nmsym /translate:source,package,always /source:. /load:execute,break %1Now all you have to do is type "DEBUG MyProgram.exe" on the command line to automatically load the source and symbols and begin debugging. Here you can download this (as well as some improved versions) batch file: db_bat.zip Setting up the Paths Now all you need to do is add your MASM bin directory to the PATH, as shown by the following:
SET PATH = %PATH%;C:\MASM\BIN You could add this to your autoexec.bat file so that the masm bin directory is always on the path, or you could add it to a custom batch file to set up your programming environment. Debugging with SoftICE
Note: It is a good idea to have a WinMain function in your source, so that
SoftICE will break on it when it loads the program...
Once you have the program laoded into softice you can use the SRC command
to toggle between source view, code view, and mixed mode...
You can also set breakpoints on your functions by typing BPX MyFunc.
BPM MyVar will break on access to a variable.
Another useful command is FILE, which is used to change which source file
is currently being displayed.
Of course, READ YOUR MANUAL so you really know what your doing...
NOTE: These settings haven't seemed to work for everybody... so if you have
problems, or know what I am doing wrong, please let me know.
|