The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ecube on October 07, 2006, 07:30:26 AM

Title: ollydbg
Post by: ecube on October 07, 2006, 07:30:26 AM
Does anyone know how to get ollydbg to beautifully debug your code by almost showing your exact source? I tried adding /debug to my build.bat and set select path for symbols in olly didn't do it. I did it along time ago after someone posted about it, forgot how to :(
Title: Re: ollydbg
Post by: BogdanOntanu on October 07, 2006, 12:03:47 PM
There are some flags that must be given to MASM command line and to the LINKER command line.
Both have to concur...research it a little.

Then you can load your new generated "debug" binary in Olly and you will see all variable manes and labels etc. Additionally you can load the source text file and syncronize it with the CPU  disassembly.

Works for TASM also ;)


Title: Re: ollydbg
Post by: ecube on October 07, 2006, 08:48:50 PM
I tried researching and was unable to find the answer hence why I posted here...If anyone is willing to give me a real answer i'd appreciate it, thanks.
Title: Re: ollydbg
Post by: Vortex on October 07, 2006, 09:24:12 PM
E^cube,

Here are the command-line switches to build an executable with debug info :

\masm32\bin\ml /c /coff /Zi sourcefile.asm
\masm32\bin\link /SUBSYSTEM:CONSOLE /DEBUG /DEBUGTYPE:CV sourcefile.obj


Attached is an screenshot taken from an Ollydbg session, one of the panels displays the source code.

[attachment deleted by admin]
Title: Re: ollydbg
Post by: ecube on October 08, 2006, 01:36:37 AM
Thankyou very much Vortex, that's great.  :bg
Title: Re: ollydbg
Post by: GregL on October 08, 2006, 05:24:36 AM
Yeah, thanks Vortex. I didn't realize you could do that with OllyDbg. It's not mentioned in the help, at least I never found it. It's not really intuitive either, it took me a while to figure out how to do it. Like they say, "A picture is worth a thousand words".

Title: Re: ollydbg
Post by: mitchi on June 27, 2009, 05:25:06 PM
Good thing this topic was here. I had forgotten how to do it :)
Title: Re: ollydbg
Post by: dedndave on June 27, 2009, 05:41:22 PM
Good thing this topic was here. I had no idea how to do it.  :bg
Title: Re: ollydbg
Post by: jj2007 on June 27, 2009, 07:46:46 PM
Good thing this topic was here. I still have no idea how to do it. My source window is empty... ::)
Title: Re: ollydbg
Post by: mitchi on June 28, 2009, 08:44:09 AM
Go to the source files window before going to the source window.
In the source files window double-click on your .asm file.
The source code will appear.
Title: Re: ollydbg
Post by: jj2007 on June 28, 2009, 09:20:36 AM
Quote from: mitchi on June 28, 2009, 08:44:09 AM
Go to the source files window before going to the source window.
In the source files window double-click on your .asm file.
The source code will appear.

I tried that already but my source files window is empty, too...
Title: Re: ollydbg
Post by: Mark Jones on June 28, 2009, 09:21:53 AM
IIRC, GoASM+GoLink = debugging data embedded inside exectuable. PoLink = similar.

Unsure of the results using the first two (think the latter will not work while the former does), but I know for certain Olly can read .PDB file data (MS LINK.EXE). Try the standard MASM32 package versions of ML and LINK, not the newer versions.

The /Zi switch is needed (/Zd possibly also), along with /debug IIRC.
Title: Re: ollydbg
Post by: Jimg on June 28, 2009, 02:09:38 PM
Also I have found that including the /Fl listing switch prevents the source from showing in Olly for some reason.
Title: Re: ollydbg
Post by: Vortex on June 28, 2009, 03:55:23 PM
Hi jj2007,

What's the version of your Olldbg copy?
Title: Re: ollydbg
Post by: jj2007 on June 28, 2009, 05:07:56 PM
Quote from: Vortex on June 28, 2009, 03:55:23 PM
What's the version of your Olldbg copy?

23.05.2004 - and it works now, with /Zi /Zd for ml and /debug for link, both the versions that come with Masm32. Later versions of ml and link do not work with debug symbols.
Title: Re: ollydbg
Post by: Vortex on June 28, 2009, 05:23:20 PM
Hi Jochen,

Me too, I am using the debugger dating 23.05.2004, it's V1.1  Probably, the later versions of ml.exe and link.exe are designed to create a different version of debug information. This is why you may have problems with Ollydbg. If you wish to view the source code, Pelles IDE is another good alternative for debugging.
Title: Re: ollydbg
Post by: jj2007 on June 28, 2009, 05:45:27 PM
Hi Erol,

I prefer Olly 2.0, but it does not know about symbols. Version 1.1 works fine in general, but it's a pity that Oleh has not implemented a newer version that would work with versions of ml and link that understand SSE2...
Title: Re: ollydbg
Post by: Vortex on June 28, 2009, 05:50:14 PM
Hi Jochen,

I share the same opinion with you. Ollydbg lacks the flexibility to work with the later versions of MS tools. Attached is a debugging session with Pelles C IDE displaying both the source code and the disassembled code.

QuoteStart Pelles C IDE.
File -> Open -> Select the EXE to debug.
Hit F5 to start the debugging session.
Select the command line arguments


[attachment deleted by admin]
Title: Re: ollydbg
Post by: dedndave on June 28, 2009, 06:26:52 PM
shouldn't be too difficult to convert debug info between formats, eh ?
Title: Re: ollydbg
Post by: Mark Jones on June 28, 2009, 07:28:18 PM
Unfortunately Dave, the .PDB file details are unpublished, and MS likes to change it occasionally. :'(
Title: Re: ollydbg
Post by: redskull on June 28, 2009, 08:42:02 PM
I found the 'trick' with Olly is you have to double click the source line itself, not the 'source' window.  To explain a little further

1. Build with the switches (/Zi /Zd for ML, /DEBUG /PDB /RELEASE for link), and make sure the appropriate boxes are set in the Olly options
2. Load up Olly, start debugging
3. In the CPU window, underneath where the dissassembly is (but before the memory dump), you should see the cooresponding source code line in light gray
4. Double click *that* line, and the source should open in a new window, and you can then follow along.

I don't know if it's just my version, or a bug, or what, but I couldn't get it to work any 'normal' way.  After you do this, you should be able to open and close it via the 'S' button.

-r
Title: Re: ollydbg
Post by: Vortex on June 29, 2009, 05:10:38 PM
Hi redskull,

That's a know trick working in Ollydbg V1.1
Title: Re: ollydbg
Post by: dedndave on June 29, 2009, 05:21:40 PM
QuoteUnfortunately Dave, the .PDB file details are unpublished, and MS likes to change it occasionally.
Mark,
That is exactly how i used to feel about OBJ files, until Vortex pointed me in the right direction - lol
Here is how I look at it: Oleh had to get his information someplace
Even if his information is out of date or incomplete, it is what he used to write his debugger

Now, you will all get a nice chuckle when i tell you what i did back in the old days
I disassembled the linker to figure out what i could about OBJ files - lol
It was a lot of work, back then, but my curiosity wasn't quenched until i found out
Actually, i disassembled most of DOS ver's 1.12, 2.10, and 3.30/3.31
i even disassembled SymDeb that came with MASM 5.10 - lol - modified it for my own use, too

i used my modified SymDeb and PcWrite to do the disassembly - lol
oh - and i wrote some programs along the way to help resolve code/data addresses and create labels
Title: Re: ollydbg
Post by: Vortex on June 29, 2009, 05:36:53 PM
KetilO's PDB Explore (http://www.masm32.com/board/index.php?topic=11525.0)