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 :(
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 ;)
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.
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]
Thankyou very much Vortex, that's great. :bg
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".
Good thing this topic was here. I had forgotten how to do it :)
Good thing this topic was here. I had no idea how to do it. :bg
Good thing this topic was here. I still have no idea how to do it. My source window is empty... ::)
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.
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...
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.
Also I have found that including the /Fl listing switch prevents the source from showing in Olly for some reason.
Hi jj2007,
What's the version of your Olldbg copy?
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.
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.
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...
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]
shouldn't be too difficult to convert debug info between formats, eh ?
Unfortunately Dave, the .PDB file details are unpublished, and MS likes to change it occasionally. :'(
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
Hi redskull,
That's a know trick working in Ollydbg V1.1
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
KetilO's PDB Explore (http://www.masm32.com/board/index.php?topic=11525.0)