PDA

View Full Version : Tracing source code


warg
July 11th, 2007, 09:15
noobie question here:

I'm trying to trace a masm program I wrote. I got Ollydbg to follow along the main source code file in the source window, but how do I get it show and follow along in included files also?

blabberer
July 11th, 2007, 09:26
what include file ? can you be more clearer ?

do you mean kernel32.inc , user32.inc ?

if you have sources for them then they should all show up

look at view -> sources -> see what files ollydbg are looking for
and reporting as absent

you can follow only source files that are referanced by debug information

warg
July 11th, 2007, 11:02
Well, for example, I have the file xx.asm
In that file I have the line " include yy.asm"
where yy.asm contains some extra procs I'm calling from xx.asm
Ollydbg happily steps through xx.asm, but knows nothing about yy.asm and does not show it in the source window.

my assemble options are: /Zi /Zd /c /coff /Cp /nologo /Fl /Sn /Fm /Sg

my link options are: /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /VERSION:4.0 /INCREMENTAL:NO

LLXX
July 12th, 2007, 10:47
OllyDbg really isn't a source-level debugger. But since it's Asm, your "source" is going to be nearly the same as what you see in the disassembly anyway. Since you're writing in Asm you should recognise the code quite well enough as-is.

warg
July 12th, 2007, 12:40
Ok, thanks, if it was possible, I wanted to know how.
For a large program, it's pretty difficult to know which proc you are in just from the disassembly, which also makes it hard to set break points.

blabberer
July 13th, 2007, 06:59
warg
if it is your asm file ollydbg should find it

i thought you were looking for kernel32.inc files sources from your first post

anyway ill give an example here see whats wrong with your project if ollydbg cant find your own include file

Code:

iczelions tut-02 msgbox.exe source code taken as base example

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
MsgCaption db "Iczelion's tutorial no.2",0
MsgBoxText db "Win32 Assembly is Great!",0

.code
start:
include blah.asm <------- addded blah.asm to this code
invoke MessageBox, NULL,addr MsgBoxText, addr MsgCaption, MB_OK
invoke ExitProcess,NULL

end start


blah.asm contains these lines

Code:


mov eax,30h
mov ebx,4h
add eax,ebx



i compiled and linked it like this

Code:

\masm32\bin\ml /c /coff /Zi "msgbox.asm"

\masm32\bin\Link /PDB:MSGBOX.PDB /PDBTYPE:SEPT /DEBUG /DEBUGTYPE:CV /SUBSYSTEM:WINDOWS /RELEASE "msgbox.obj"


output like this

Code:


test:\>dir /b
msgbox.asm
blah.asm
makeit.bat

test:\>makeit.bat

test:\>\masm32\bin\ml /c /coff /Zi "msgbox.asm"
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.

Assembling: msgbox.asm

test:\>
test:\>\masm32\bin\Link /PDB:MSGBOX.PDB /PDBTYPE:SEPT /DEBUG /DEBUGTYPE:CV /SUBS
YSTEM:WINDOWS /RELEASE "msgbox.obj"
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


test:\>
test:\>dir /b
msgbox.asm
blah.asm
makeit.bat
msgbox.obj
msgbox.exe
MSGBOX.PDB

test:\>


lets load this file in ollydbg

ollydbg finds both the sources

Code:

Source files
Module Source Source path
MSGBOX BLAH.ASM D:\MASM32\ICZTUTES\TUTE02\WITHDEBUGINFO\blah.asm
MSGBOX MSGBOX.ASM D:\MASM32\ICZTUTES\TUTE02\WITHDEBUGINFO\msgbox.asm


in disassembly window

Code:

EAX=00401000 (MSGBOX.<ModuleEntryPoint>
blah.asm:1. mov eax,30h


msgbox.asm:17. invoke MessageBox, NULL,addr MsgBoxText, addr MsgCaption, MB_OK



a picture

warg
July 13th, 2007, 09:12
Thank you. That works perfectly. I just spent an hour trying to find out why my code doesn't work. I let you know when I figure it out.

warg
July 13th, 2007, 10:26
Ok, finally found it. Try adding the /Fl option to your assembly. Removing that solved my problem. I can't think of any reason generating a listing would mess up the pdb or whatever Olly uses to determine the source files????!? I'm using masm 6.15 by the way if it matters.

blabberer
July 13th, 2007, 12:57
dunno never listed anything

but, in my opinion, it should not be hindering any pdb information creation.