flat assembler
Message board for the users of flat assembler.

Index > Main > Debugging assembly

Author
Thread Post new topic Reply to topic
Erikina



Joined: 06 Apr 2006
Posts: 8
Erikina
I've been playing around with assembly for the last month, and now today is the first day in my two week school break - and I thought I would really like to learn assembly.

I have bought the book Assembly Language for Intel-Based Computers which I so far really like. It uses MASM, so for practice I am trying to convert the examples to FASM (without much success). Anyway, to my actual point ... I'm wonder what's the best way to debug assembly.

With C# I could set breakpoints in my code, and the program would freeze there ... and I could mouse-over variables and see what was stored in them etc. It was really nice. Is there an equivilent for assembly? I've downloaded OllyDbg but frankly that program scares me.


Thanks a lot guys.
Post 06 Apr 2006, 10:14
View user's profile Send private message MSN Messenger Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
Why? I've made it so that I can see exactly what I typed in FASM in it. It has very flexible design. You can colour everything (almost) you like in there and not only can you see variables at that time - you also "see" all the registers and memory at that moment. You can even trace it and "go back in time" Very Happy
Post 06 Apr 2006, 12:26
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Erikina wrote:

With C# I could set breakpoints in my code, and the program would freeze there ... and I could mouse-over variables and see what was stored in them etc. It was really nice. Is there an equivilent for assembly? I've downloaded OllyDbg but frankly that program scares me.
Thanks a lot guys.


if it can be done in C#, it has to be able to be done in ASM considering c# creates the opcodes which assembly is Smile

int3 is a breakpoint

Code:
mov eax, bla
int3
...
    


olydbg is a very good programme i recommend it, i've been too lazy to ever set custom colours but maybe i should Smile

_________________
redghost.ca
Post 06 Apr 2006, 14:25
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
C# doesn't generate machine language. It generates so-called MSIL, which is some MS's syntax that is compiled at run-time by .net framerwork Smile

to debug assembly (or anything), you need debugger, and things you mentioned are features of debuggers. It is not question of language (asm, C#), but of envirnment you use (notepad, visual studio).

For win32, best debugger i know is OllyDbg, but fasm still lacks symbolic information, so you won't see names. I think Fresh has some debugger, but i don't know if it is already working.
Post 06 Apr 2006, 14:41
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Erikina



Joined: 06 Apr 2006
Posts: 8
Erikina
Madis731 wrote:
Why? I've made it so that I can see exactly what I typed in FASM in it. It has very flexible design. You can colour everything (almost) you like in there and not only can you see variables at that time - you also "see" all the registers and memory at that moment. You can even trace it and "go back in time" Very Happy
You made OllyDbg? That is cool. Don't get me wrong, I'm not saying there is anything wrong with it - but I am completely new to assembly and all the features and stuff is quite confusing.

Vid wrote:
C# doesn't generate machine language. It generates so-called MSIL, which is some MS's syntax that is compiled at run-time by .net framerwork Smile

to debug assembly (or anything), you need debugger, and things you mentioned are features of debuggers. It is not question of language (asm, C#), but of envirnment you use (notepad, visual studio).
I understand that. But when I debug my C# I'm actually debugging in terms of the source code and it's extremely nice to debug and work with. Is there anything like that for assembly so I can debug at the source code level (not the executables ... if you know what I mean). If there's nothing like that for assembly, I guess I'll need to learn how to use OllyDbg.

Thanks a lot guys.
Post 06 Apr 2006, 20:35
View user's profile Send private message MSN Messenger Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
You can also use Dr. Watson (32-bit version). it produces a disassembly of where the fault occured and xx lines before and after the fault location. You can find it in your system32 folder. Just create a shortcut to your desktop, double click, do some setup (the most inportant would be which folder to put the output in, "my documents" would be a good place.)
Also, you may be able to use the Dr. Watson output with your c# setup.
Post 06 Apr 2006, 20:49
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i think there actually isn't any solution to debug FASM source at source level. Soon there will probably be some debugging information, but right now problem is that there is no widespread existing debug-info-format which could contain all information FASM produces. Seems Tomsz will have to develop his own format, from which other utilities will export to known formats.
Post 07 Apr 2006, 00:12
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Big Red



Joined: 25 Feb 2005
Posts: 43
Big Red
OllyDbg is a great debugger, seriously. Learn to use it now and you'll save yourself a lot of time later, even if you don't get FASM symbols. There's nothing quite as flexible.
Post 07 Apr 2006, 01:33
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu
IF you are using MASM or TASM you can add flags to the command line to include debug info inside the executable. For debugging this is much better than PDB... because it is always there available without additional files.

Then, in OllyDbg or in MS VC Debugger or in other symbolic debuggers you can debug at souce level and you will also see the source and the variables names, procedures names, arguments local avriables call stac etc... no hovering over a variable yet in Olly but you can add "watches"

In some ASM IDEs you can even setup breakpoints at source level Wink
but otherwise inserting a breakpint is like adding a line with: "int 3"

Of course inside Olly you can use and see the real hardware registers used for breakpoints...==> a powerfull feature of the CPU Very Happy
Post 07 Apr 2006, 06:41
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
@Erikina: I didn't make the debugger, I just said that I configured it to my needs and comfort Smile
Actually the guy who did it is called Oleh Yuschuk, that is maybe why it is called OllyDbg Very Happy
http://www.ollydbg.de/
Post 07 Apr 2006, 06:56
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
Madis731 wrote:
Why? I've made it so that I can see exactly what I typed in FASM in it. It has very flexible design. You can colour everything (almost) you like in there and not only can you see variables at that time - you also "see" all the registers and memory at that moment. You can even trace it and "go back in time" Very Happy


Madis731,

Can you share with us what you have done to view your FASM source from within OllyDbg? That would definetly make my nipples hard Exclamation

thanks,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 07 Apr 2006, 08:44
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Quote:

I've been playing around with assembly for the last month
I second your nomination of Kip Irvine's fine textbook and here are some other references:http://www.cheapersunglasses.com/asm.html
I would enter a special plug for a book which I have long admired, Dandamudi's textbook:
http://www.powells.com/cgi-bin/biblio?inkey=4-0387206361-0
Madis: Thanks for explaining the origins of ollydebug. I had always thought of Laurel and Hardy http://www.imdb.com/title/tt0029747/
because of Stan Laurel's plaintive and whining cry for "ollie", Oliver Hardy, to assist him in figuring out what to do next.
Smile
Post 07 Apr 2006, 08:56
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu
BUT wait... I guess you can hover over a variable in IDA Pro Wink

You can even hover over a Jump or Call ad it will show you some code from the destination.
Post 07 Apr 2006, 16:04
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
There are:
Options => Debugging options (Alt+O)
Disasm tab
1) IDEAL (Borland)
2) Don't show default segments (only when forced segment)
3) Don't always show the size of memory operands (only when prefixed)

Maybe this will help:


Description: OllyDbg ini-file
Download
Filename: ollydbg.7z
Filesize: 3.25 KB
Downloaded: 203 Time(s)


_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 08 Apr 2006, 09:55
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.