flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Debug information

Author
Thread Post new topic Reply to topic
Soft RaideR



Joined: 30 Aug 2003
Posts: 2
When fasm can generate debuf information or map files ?
Maybe anyone have macros's for generating map files?

sorry for my english.
Post 30 Aug 2003, 19:07
View user's profile Send private message ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7269
Location: Kraków, Poland
If you need to get the addresses of any place in code, you can do it with "display" directive, some macros that help displaying numbers (and addresses in particular) were posted in the Macroinstructions forum, and here's a small example of how you can utilize it for displaying addresses in Win32 program:
Code:
BASE_ADDRESS = 400000h

format PE GUI 4.0 at BASE_ADDRESS
entry start

;-----------------------------------------------------------

macro __digit num
 {
   if num < 10
    display '0'+num
   else
    display 'A'+num-10
   end if
 }

macro __display arg1,arg2
 {
   if arg2 eq
    display arg1
   else
    local ..tmp
    ..tmp = arg1
    virtual at 0
     repeat 32
      if ..tmp > 0
       db ..tmp mod arg2
       ..tmp = ..tmp / arg2
      end if
     end repeat
     repeat $
      load ..tmp byte from $-%
      __digit ..tmp
     end repeat
     if $ = 0
      display '0'
     end if
    end virtual
   end if
 }

macro display [arg] { __display arg }


macro display_address text,address
 { display text,<(BASE_ADDRESS+rva address),16>,'h',13,10 }

;-----------------------------------------------------------

display_address 'Entry point: ',start
display_address 'Data: ',some_data


section '.text' code readable executable

start:
        ret

section '.data' data readable executable

some_data db ?    
Post 01 Sep 2003, 00:28
View user's profile Send private message Visit poster's website Reply with quote
ucode81



Joined: 14 Sep 2003
Posts: 5
Hi,

I disagree with using display. I have looked at the source (except for the lack of comments, a fine job overall) and do not see that it would be that difficult to add debugging information to the COFF (PE) executable. Superb generic debuggers like OllyDebug could REALLY benefit.

I am not sure how the rest of you do this today, but I am "forced" to write my programs using TASM to debug them, and then I feed the only slightly modified source (I have created a few macros to handle some unique TASM directives I use) to FASM to create a far tighter executable (not to mention FASM is far faster than TASM). I am willing to help in this endeavor...
Post 14 Sep 2003, 20:54
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7269
Location: Kraków, Poland
What kind of debug info are you using? Is it a relationship between function names and addresses, or between addresses and lines in source code? The first one probably woulnd't be that hard to implement, but with the second there are some real problems (look at the thread about the listing feature).
Post 14 Sep 2003, 21:12
View user's profile Send private message Visit poster's website Reply with quote
Soft RaideR



Joined: 30 Aug 2003
Posts: 2
I have description of debug information. If you want I may send it to you. It consists of addresses of function and data, and numbers of source lines, but i dont understand for what may needs references for lines numbers of source code of project that written on assembler. Debugers that I try to use, except OllyDbg correct dissasemble all source code, but sometimes very useful view macros name in debuger without sorce code of macros.
Post 14 Sep 2003, 22:42
View user's profile Send private message ICQ Number Reply with quote
ucode81



Joined: 14 Sep 2003
Posts: 5
Ok, let me break this apart.

At a bare minimum, what is needed is the label (or variable) to address mapping table so that I can look at names instead of hex digits in the display. If you have something to do that already without peppering display throughout my code, I am all ears! Very Happy

A debugging environment that is far more user-friendly (and what we all have grown accustomed to in other assembler environments) is that the source line is also indicated. This could be used by the debugger directly (some debuggers provide the optoin to show disassembled or source code in the main window) or as a tracking source code window (OllyDebug and TurboDebug have this option as well). Cool

FYI, I did follow the thread on the listing feature but it seems to me there is somewhat simple way to get 99% of what is needed for debugging. Consider that that the source line IS the source line and you REALLY do not need to expand macros into multiple lines of code for debugging UNLIKE what most people would like to see a listing and is causing you all of your nightmares. Nearly all debuggers (actually, cannot find a counter-example so maybe all) associate the assembly instructions (plural) with the closest source line number located at (or below) the memory location being printed. (The reason they do is that all of the debuggers I tried support HLLs which is dominated by multiple assembly instructions per single HLL statement, so they have to!)

Cheers!
Post 16 Sep 2003, 00:14
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7269
Location: Kraków, Poland
OK, so I see that the modifications I have made in the way to make listing addition are enough for this purpose. The only remaining problem is choosing the format of debug information. Do you need it for COFF or ELF formats, or for the PE - which would be completely different solution?
Post 16 Sep 2003, 07:48
View user's profile Send private message Visit poster's website Reply with quote
ucode81



Joined: 14 Sep 2003
Posts: 5
COFF has a clear format as does ELF. PE actually has, well, three debug formats AFAIK: COFF directly per the spec, M$ CV4 format, and Borland's debug format.

I think having it in COFF is the best starting point. It is possible OllyDebug might be able to use it as is if FASM puts it in the EXE. If OllyDebug does not, then if I use a LINK.EXE with an MS COFF object file (instead of FASM generating the EXE), I will get debug output.

ELF is even simpler than COFF.
Post 17 Sep 2003, 18:14
View user's profile Send private message Reply with quote
BiDark



Joined: 22 Jun 2003
Posts: 110
Location: .th
Does anybody got CV4 spec? I would like to grap one.
Post 26 Sep 2003, 03:34
View user's profile Send private message 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-2019, Tomasz Grysztar.

Powered by rwasa.