News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Assembler Debuger

Started by Robert Collins, December 21, 2004, 11:48:47 PM

Previous topic - Next topic

Robert Collins

Like when I was writing old DOS programs I always used the old 'DEBUG.EXE' program to help me debug my assembly programs. But now I am getting into Win32 Assembly and was wondering if there is any such tool to use for debugging similar to 'DEBUG.EXE'. I can't use the DOS debuger for Windows programs as we all know.

John


pbrennick

http://home.t-online.de/home/Ollydbg/odbg110.zip is the version that I use, I think it is the most current.

Paul

Robert Collins

Quote from: John on December 21, 2004, 11:52:13 PM
Have you found Ollydbg yet?

No I didn't know about it. I have been using the debugger of the VC++ IDE but it doesn't do alot. I d/l the zip file and it seems to be a very nice debugger. Thanks for the link.

Vortex

You can debug Masm executables with the VC++ IDE, assemble and link your project with the debug info option, after open your executable in the IDE.

Relvinian

Quote from: Robert Collins on December 22, 2004, 01:17:53 AM
Quote from: John on December 21, 2004, 11:52:13 PM
Have you found Ollydbg yet?

No I didn't know about it. I have been using the debugger of the VC++ IDE but it doesn't do alot. I d/l the zip file and it seems to be a very nice debugger. Thanks for the link.

The visual studio (or just vc++) IDE does just fine with MASM asm debug files. Just make sure you compile with debug info in your .asm files and you'll have full source code in visual studio. I use the IDE heavily for debugging of both C++ and ASM routines both at home and work.

Relivinian

Robert Collins

Quote from: Vortex on December 22, 2004, 11:12:55 AM
You can debug Masm executables with the VC++ IDE, assemble and link your project with the debug info option, after open your executable in the IDE.

Quote from: Relvinian on December 22, 2004, 03:14:25 PM
The visual studio (or just vc++) IDE does just fine with MASM asm debug files. Just make sure you compile with debug info in your .asm files and you'll have full source code in visual studio. I use the IDE heavily for debugging of both C++ and ASM routines both at home and work.

Relivinian


Can one of you show me how (the stuffI needed) to:

1) Assemble an .ASM program using VC++
2) The debugging info in the .ASM file
3) Debugging the assembly with full source in Visual Studio

MANT

I'm pretty familiar with OllyDbg and have used it quite a bit, but I still almost always use the VC++ debugger because it's better at seeing the debug information in the code.

I don't assemble using VC++, though, I use straight ml. Here's a sample of the command lines you might use (1) for release exe (2) for debug exe...


    \masm32\bin\ml /c /nologo /coff /Fm *.asm
    \masm32\bin\ml /c /nologo /coff /Zi /Fm /FR *.asm


Here are the link commands I use...


    \masm32\bin\link /nologo /subsystem:windows /entry:start /out:"myprog.exe" /map *.obj
    \masm32\bin\link /nologo /subsystem:windows /entry:start /out:"myprog.exe" /map /mapinfo:lines /debug /pdb:"myprog.pdb" /pdbtype:sept *.obj


Some of the options aren't strictly necessary, but perhaps these will get you started. If it's a console app, use /subsystem:console instead.

As for debugging the exe, open the VC IDE and Open Project, select the exe file. Then press F10 to single-step. That takes you to the code window.

Have fun!

MANT

I'm sure others have posted something like this in the past, but FWIW, here's a make.bat file I created to do the assembly & linking. It's crude but it's fast and it works great for small projects. Just type "make" to make a release exe, "make debug" to make a debug exe, and "make clean" to clean up the directory.


@echo off

    : The name of the main exe & asm file
    set name=myprog

    if (%1)==(clean) goto clean

    : The masm32 directory
    set masm32=\masm32

    : Either windows or console
    set subsystem=windows

:assemble
    if (%1)==(debug) goto debug

:release
    echo ---RC---
    rc %name%.rc
    if errorlevel 1 goto errrc
    h2inc /WIN32 resource.h

    echo ---MASM---
    if exist %name%.ex~ del /Q %name%.ex~
    \masm32\bin\ml /c /nologo /coff /Fm *.asm
    if errorlevel 1 goto errasm

    echo ---LINK---
    \masm32\bin\link /nologo /subsystem:%subsystem% /out:"%name%.exe" *.obj *.res
    if errorlevel 1 goto errlink

    goto done

:debug
    echo ---RC---
    rc %name%.rc
    if errorlevel 1 goto errrc
    h2inc /WIN32 resource.h

    echo ---MASM---
    \masm32\bin\ml /c /nologo /coff /Zi /Fm /FR *.asm
    if errorlevel 1 goto errasm

    echo ---LINK---
    \masm32\bin\link /nologo /subsystem:%subsystem% /debug /out:"%name%.exe" /pdb:"%name%.pdb" /pdbtype:sept /map /mapinfo:lines *.obj *.res
    if errorlevel 1 goto errlink

    goto done

:clean
    if exist %name%.ilk   del /Q %name%.ilk
    if exist %name%.map   del /Q %name%.map
    if exist %name%.pdb   del /Q %name%.pdb
    if exist %name%.res   del /Q %name%.res
    if exist %name%.lst   del /Q *.lst
    if exist %name%.obj   del /Q *.obj
    if exist %name%.sbr   del /Q *.sbr
    if exist resource.inc del /Q resource.inc
    goto done

:errrc
    echo.
    echo RC error
    goto done

:errasm
    echo.
    echo Assembly error
    goto done

:errlink
    echo.
    echo Link error
    goto done

:done
    set name=
    set masm32=
    set lb=
    set subsystem=
    echo on


Vortex

Pelle's IDE is able also to debug MASM applications.

WinCC

I just posted a link to my Visual C++ 2003 MASM32 "enhancements"  here http://www.masmforum.com/simple/index.php?topic=132.0

Regards WinCC

pbrennick

#11
MANT,
That is a nice (and useful) batch file to add to any toolbox.

Paul

MANT

Thanks, Paul... I forgot to mention you have to comment out the RC stuff if your project doesn't use resources.