flat assembler
Message board for the users of flat assembler.

Index > Windows > My debugging symbols solution

Author
Thread Post new topic Reply to topic
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 13 Feb 2012, 23:41
Due to the rise in posts about debugging symbols, I finished my own two-click system for creating exported symbol debug binaries, briefly described here: http://board.flatassembler.net/topic.php?t=13843

As I use custom includes, I don't know how well the idea transfers to the usual includes.

Basically it consists of a program to extract suitable symbols from a .fas file, and a batch script:

fas.bat wrote:
@echo off
set include=E:\_program1\_programmering\fasmw\INCLUDE
cd E:\_projekt\fasm\32
e:
e:\_program1\_programmering\fasmw\FASM.EXE %1 -s debug.fas
fas.exe debug.fas 1> exports.txt
cp %1 debug.asm
sed -i "s~UI~UI,debug~" debug.asm
sed -i "s~import~<exports>\n\nimport~" debug.asm
sed -i "s~\ \.[^,]*,~~g" exports.txt
sed -i "s~\ [^,]*\.iat,~~g" exports.txt
sed -i "s~\ bss,~~g" exports.txt
sed -i -f fas.sed debug.asm
e:\_program1\_programmering\fasmw\FASM.EXE debug.asm %~d1%~p1%~n1.debug.exe


fas.sed wrote:
/<exports>/ {
r exports.txt
d
}


◊ I first generate the .fas file from the assembly file.

◊ Then, from the .fas file I output those symbols that:

    are defined
    are used
    have the "optimization adjustment is applied to" (whatever that means)
    are not virtual/relative
    are not anonymous labels


◊ I make a copy of the source file, set it to debug mode.

◊ Unwanted symbols are pruned: symbols that start with a dot, contain ".iat", or is "bss".

◊ The resulting string - an export macro invocation - is inserted into the source and compiled

The result is a good collection of exported symbols that is useful in debugging:

Image

_________________
This is a block of text that can be added to posts you make.
Post 13 Feb 2012, 23:41
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20433
Location: In your JS exploiting you and your system
revolution 14 Feb 2012, 01:45
Can you please explain what sed is? It is your own program? My windows system seem to be missing it.
Post 14 Feb 2012, 01:45
View user's profile Send private message Visit poster's website Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach 14 Feb 2012, 08:45
my best guess would be:
Quote:
Sed (streams editor) isn't really a true text editor or text processor. Instead, it is used to filter text, i.e., it takes text input and performs some operation (or set of operations) on it and outputs the modified text. Sed is typically used for extracting part of a file using pattern matching or substituting multiple occurances of a string within a file.

http://gnuwin32.sourceforge.net/packages/sed.htm
Post 14 Feb 2012, 08:45
View user's profile Send private message Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 14 Feb 2012, 14:33

_________________
This is a block of text that can be added to posts you make.
Post 14 Feb 2012, 14:33
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 16 Feb 2012, 22:43
revolution wrote:
Can you please explain what sed is? It is your own program? My windows system seem to be missing it.


That's because Windows is not UNIX nor POSIX and doesn't try to be. I honestly suspect you're being facetious as sed is fairly common (though admittedly very niche).

http://en.wikipedia.org/wiki/Sed
http://www.gnu.org/software/sed/
http://www.pement.org/sed/
http://sed.sourceforge.net/
http://lvogel.free.fr/sed.htm
http://www.exactcode.de/site/open_source/minised/
Post 16 Feb 2012, 22:43
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20433
Location: In your JS exploiting you and your system
revolution 16 Feb 2012, 22:51
It is just a way to get people to explain what they are doing, rather than assume that everyone knows what is happening. This is a Windows section so things like sed will be foreign to most users. It is certainly foreign to me. And from what I can already see there appears to be many different versions of sed, so one can only hope that they all do the same thing with the code posted above.
Post 16 Feb 2012, 22:51
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 16 Feb 2012, 22:54
Post 16 Feb 2012, 22:54
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 03 Nov 2012, 22:52
I've tweaked my system somewhat to include more useful symbols and filter more less useful ones.

http://files.sys5.se/fas.asm

fas.bat wrote:
@echo off
set include=E:\_program1\_programmering\fasmw\INCLUDE
cd E:\_projekt\fasm\32
e:
e:\_program1\_programmering\fasmw\FASM.EXE %1 -s debug.fas
fas.exe debug.fas 1> exports.txt
cp %1 debug.asm
sed -i "s~UI~UI,debug~" debug.asm
sed -i "s~import\t~<exports>\n\nimport\t~" debug.asm
sed -i "s~\ \.[^,]*,~~g" exports.txt
sed -i "s~\ [^,]*\.iat,~~g" exports.txt
sed -i "s~\ bss,~~g" exports.txt
sed -i "s~\, \.\.[^\ ]*~~g" exports.txt
sed -i "s~\, [^,]*?[^,]*~~g" exports.txt
sed -i -f fas.sed debug.asm
e:\_program1\_programmering\fasmw\FASM.EXE debug.asm %~d1%~p1%~n1.debug.exe
if %ERRORLEVEL%==0 goto end
pause
:end
del sed??????


Image

_________________
This is a block of text that can be added to posts you make.
Post 03 Nov 2012, 22:52
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
XQuader



Joined: 24 Apr 2011
Posts: 1
Location: Belarus
XQuader 26 Mar 2013, 13:36
Where is compiled version of fas.asm?
Can someone share it? Or share pe.inc (needed to compile it from fas.asm)

PS. Sorry for bad English
Post 26 Mar 2013, 13:36
View user's profile Send private message ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 26 Mar 2013, 22:58
I can try to make it a bit more general than it is now; it has a lot of hardcoded paths and stuff as it is now.
Post 26 Mar 2013, 22:58
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 29 Mar 2013, 18:40
Made a bundle: http://files.sys5.se/fas.zip

You need to change two lines in the fas.bat file, then supply fas.exe the parameter fas.asm to test the system out.

_________________
This is a block of text that can be added to posts you make.
Post 29 Mar 2013, 18:40
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.