flat assembler
Message board for the users of flat assembler.

Index > Linux > Debugging symbols in Linux and BSD

Author
Thread Post new topic Reply to topic
sachamasry



Joined: 27 Apr 2010
Posts: 5
sachamasry
This question has been asked, but no concrete answer has been given (as far as I can tell), as to how to debug fasm executables in Linux and the BSDs.

I understand there is no stabs symbol output-does this mean that debugging can only be done by viewing the machine instructions?

Is there some meaningful way to debug in Lunux/BSD, or is FASM mainly Windows-centric, with the solution being YASM instead?
Post 27 Apr 2010, 03:30
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
sachamasry,

Probably you need to find/write tool to convert .fas FASM symbolic information into appropriate for your debugger format.
Post 27 Apr 2010, 08:30
View user's profile Send private message Reply with quote
sachamasry



Joined: 27 Apr 2010
Posts: 5
sachamasry
Thanks for the reply baldr.

I realise this. This area doesn't seem to be covered in the manual or any other official documentation which is why I'm asking this question.

As far as I understand it, gdb requires stabs symbols output to be able to display the program listing. I have no idea how to supply symbols to gdb in any format, except where they have been explicitly created and added to the object (executable) by gas/NASM/YASM.

So:

1. Is there a tool/script that will convert .fas symbolic information to gdb's stabs? Or to whatever format ALD uses?

2. How is a .fas symbolic information file created in the first place?

or, how do the rest of the people on Linux and BSD debug FASM executables?

Any help at all would be appreciated-I've seen the question raised on the forums, without reference to a working solution. As FASM is now available and used on both Linux and BSD systems, surely those who have converted from their previous assemblers have put together some sort of workflow?
Post 27 Apr 2010, 09:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17641
Location: In your JS exploiting you and your system
revolution
1. Not that I know of.

2. It is an assembly time selection. In console version you select third file at the command line. In IDE there is a menu option.

3. We don't debug, we write perfect code first time every time. Razz Yeah, right, we really wish THAT were true!
Post 27 Apr 2010, 10:03
View user's profile Send private message Visit poster's website Reply with quote
sachamasry



Joined: 27 Apr 2010
Posts: 5
sachamasry
revolution,

Are you saying that:

There are no Linux/BSD-based debuggers able to debug FASM output, to your knowledge?

Those still choosing to develop with FASM on Linux (against all odds) can not and do not debug any code?

?

Really?

So what do they do-go back to NASM/YASM?
Post 27 Apr 2010, 11:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17641
Location: In your JS exploiting you and your system
revolution
When you generate an executable directly from fasm there is no symbol table generated that is useable directly by existing external tools. But you can always generate an object format and then link. That will give you some rudimentary symbolic information, right? You just gotta use public and extrn directives.
Post 27 Apr 2010, 11:52
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7784
Location: Kraków, Poland
Tomasz Grysztar
Please check out this thread: http://board.flatassembler.net/topic.php?t=9792

Yes, we have a kind of shortage of people willing/able to write a bunch of converters from .fas into various debug info formats.
Post 27 Apr 2010, 12:23
View user's profile Send private message Visit poster's website Reply with quote
sachamasry



Joined: 27 Apr 2010
Posts: 5
sachamasry
Ok, the first part I now know from the documentation and forums, and am not generating executables, in favour of a separate linking stage with ld.

As for the second part, I understand that it's possible to disassemble the binary file and see the instructions inside, and [possibly] follow along with gdb and the disassembled source side by side. It's counterintuitive, though, and likely to be very difficult for any meaningful program. To be honest, though, I'm not sure what you mean by using public and extrn directives-what would I be attempting to achieve using these? Sorry, I've just started looking at FASM and am really trying to get to grips with it (unsuccessfully, though).

Thanks for the pointer, though.
Post 27 Apr 2010, 12:46
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17641
Location: In your JS exploiting you and your system
revolution
[tongue-in-cheek]

sachamasry: Use fasmarm instead. It generates full debug info for source level debugging when using the DWARF output format.

[/tongue-in-cheek]

BTW: public and extrn are explained here:
http://flatassembler.net/docs.php?article=manual#2.4.4
Post 27 Apr 2010, 12:51
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7784
Location: Kraków, Poland
Tomasz Grysztar
revolution wrote:
[tongue-in-cheek]

sachamasry: Use fasmarm instead. It generates full debug info for source level debugging when using the DWARF output format.

[/tongue-in-cheek]
Well, since thus you definitely have some experience with DWARF format, wouldn't you mind writing some small fas2DWARF tool? Wink
Post 27 Apr 2010, 12:57
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: 17641
Location: In your JS exploiting you and your system
revolution
Is DWARF suitable for x86 CPUs? Are there any x86 debuggers that can read DWARF?
Post 27 Apr 2010, 13:25
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: 17641
Location: In your JS exploiting you and your system
revolution
Actually there isn't a need to make a special app for fas2DWARF. It wouldn't be very difficult to make a fasm version with DWARF integrated as a native output format. The only difficulty comes with the problem of no definitions for the x86 code types. What would a debugger make of the THUMB code type? What would be the x86 equivalents of THUMB code? Or ARM code? Or THUMBEE code?
Post 27 Apr 2010, 13:37
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7784
Location: Kraków, Poland
Tomasz Grysztar
revolution wrote:
It wouldn't be very difficult to make a fasm version with DWARF integrated as a native output format.
However that would be against the idea of fas as universal fasm-to-world intermediate format. I prefer it this way, because it allows separate maintenance of debugging-related tools, possibly by other people.
Post 27 Apr 2010, 13:45
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: 17641
Location: In your JS exploiting you and your system
revolution
Well you already got PE, ELF and BIN. It is just another executable format. Wink

Anyhow, currently it would be easier to make a .asm-to-.dwarf, than it is to make a .fas-to-.dwarf. Since all the code is already there and tested. People could make a special fasm version for themselves and pretend it is just for symbolic generation, whereas it would actually be a full assembler also.
Post 27 Apr 2010, 13:51
View user's profile Send private message Visit poster's website Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
revolution wrote:
Is DWARF suitable for x86 CPUs?
GNU toolchain uses DWARF as default debugging data format, so I think it is suitable for x86.
revolution wrote:
Are there any x86 debuggers that can read DWARF?
GNU debugger, for instance.
Post 27 Apr 2010, 13:59
View user's profile Send private message Reply with quote
sachamasry



Joined: 27 Apr 2010
Posts: 5
sachamasry
revolution, thanks for the public and extrn directives. These make sense now, and as you said, using them helps debugging in gdb with disassembly immensely.

Fanael and Tomasz are absolutely right-gdb uses and understands the dwarf data format, I have tried outputting it in YASM and it's read automatically.

This makes for a situation in which it is tolerable to debug, and possible to use FASM as the assembler of choice. Naturally, it would be desirable to debug with a proper symbols output, so if there is a gleam in the author's eye, the *nix community would benefit immensely from a usable debug output.

Thank you all for helping.
Post 28 Apr 2010, 01:23
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.