flat assembler
Message board for the users of flat assembler.
Index
> Programming Language Design > getting DEBUG info from fasmg ? |
Author |
|
jmg 19 Sep 2016, 00:17
I can find some mention of DEBUG output from fasm, but nothing for fasmg.
To usefully operate an in circuit debug, you do need some Debug info. This might be Intel OMF, ELF or some other format. A good ASCII-format debug example, is the SDCC .CDB file, designed for C, but a subset can be used for ASM operation. http://sdcc.sourceforge.net/mediawiki/index.php/CDB_File_Format In the simplest form, you need SourceFile:LineNumber to AbsCodeAdr mapping (SourceFile should be include-file capable) and Const or VariableName to Code or DataAddress mapping. Additions like Type tags and endian information can speed watch-allocate, if the debugger also supports that. Are there any examples of how to generate Debug info, from fasmg ? |
|||
19 Sep 2016, 00:17 |
|
Tomasz Grysztar 19 Sep 2016, 07:37
Since with fasmg any output format is generated by macros, the debug info appropriate for given format also has to be generated by these macros. I imagine that a variant of "proc" macro written to supplement ELF or COFF formatting macros could generate the debug info records in a right format for given output. The ELF formatter that comes with fasmg examples is currently limited to options compatible with fasm's built-in formatter, but these macros can be easily extended. The COFF formatting macros do not yet exist, but I plan to include at least basic fasm-compatible variant in the examples.
When a debug info format needs to be written as a separate file, the auxiliary output files would come in handy, but I still haven't decided how should they work in fasmg. Thus currently the only auxiliary output is to stdout with "display" directive (that's what the simple listing macro does). For example, the following macro would list all the symbols defined with "label": Code: macro label? name label name display 'Symbol ',`name,' defined in ',__FILE__ repeat 1,l:__LINE__ display '[',`l,']' end repeat display ' with value ' disphex name,8 display 13,10 end macro macro disphex number*,digits:8 repeat digits digit = ((number) shr ((%%-%) shl 2)) and 0Fh if digit < 10 display '0'+digit else display 'A'+digit-10 end if end repeat end macro This is just a basic example, as "disphex" will only display addresses that are plain numbers. When an address contains some variable terms (like in ELF output where the addresses are relative to sections/symbols) special handling is needed. The appropriate debug info generators need to be adapted and weaved into the macros that comprise the given framework (x86 ELF output, for example). |
|||
19 Sep 2016, 07:37 |
|
jmg 19 Sep 2016, 08:57
Thanks.
Thanks, so it is still work in progress... If you need info on the OMF51, that can be found here http://plit.de/asem-51/omfspec.htm I think many debug downloads can only support OMF51 _or_ Hex, which makes simplest OMF51 for ASM, slightly more complex, as you need to include a) Symbol Segments & address info, for VAR watch b) Source line to absolute code info, for Break / Step, across various files. c) Binary code, for download. |
|||
19 Sep 2016, 08:57 |
|
Tomasz Grysztar 19 Sep 2016, 09:40
I'm certainly not going to write all the macro packages myself (I still have the AVX macros and COFF output to write and even this may take long time, as I don't it as much myself), so it depends if there are people that would like to work on some specific macro package. And the basic fasmg package is going to contain only elementary examples anyway.
Current list of projects is listed in dedicated thread, but it does not include some works in progress. For instance, shoorick is working on a larger package that focuses on various 8-bit processors and microcontrollers with BIN/HEX output and Akeo is working on EBC assembler for UEFI. If you'd like to contribute in some way, I'm always willing to help with technical details of how to achieve various things with fasmg - in fact, my focus is now more on advising and writing supplementary documentation that on implementing new things. I know that I'm never going to achieve much by working on this alone, therefore I feel that my time spent on tutoring and advising others may actually be better spent than the time used to write new macros myself. Thus you will find that I often provide small snippets that demonstrate some idea, but do not handle all the corner cases. That's because I prefer to make a simplified sample that is quick to write and relatively easy to understand. But I usually try to add notes that explain where it lacks and how can it be extended to become a "real thing". |
|||
19 Sep 2016, 09:40 |
|
jmg 22 Sep 2016, 22:06
Tomasz Grysztar wrote: The name displayed is the exact text that was used to define symbol and it tries to display the value as a hexadecimal number even though some symbols may have values that cannot be presented this way. Extract of Symbol and Value/Address in hex is a good start, but some debuggers also need the memory segment. When you watch a variable, Name and Address are part of the info, the memory area is also needed, (in HLL also a Type, and Endian info ) Some debuggers do allow user over-ride of memory area & type, but that is patchy, and they tend to forget such changes on the next session. I'll try to add some example map/report files, created from Debug files + Source files.
|
|||||||||||
22 Sep 2016, 22:06 |
|
jmg 22 Sep 2016, 22:08
and another one
|
|||||||||||
22 Sep 2016, 22:08 |
|
Tomasz Grysztar 23 Sep 2016, 06:11
As I said, this macro would require tweaking to adapt to displaying addresses that are not a plain numbers. While it could be modified to display any linear polynomial in general, this may not be useful for specific purposes, since you may need something fitting to a selected type of output and macro framework.
The structure and meaning of the addresses may vary wildly in general. In my introductory document* I show on simple examples how to mark the area of a label (like instructions memory or data memory) by adding a plain variable term to the base address. The same method can be used by some formats to generate relocations (PE/ELF in x86 examples do it like that). When the frame uses multiple numbered segments, a setting like: Code: element segment? org segment*7C0h + 0 Thus the examples I provide show just some basic ideas how to tackle the problem, but any actual implementation needs to also take into consideration specific features of macro framework and output format that these macros implement. * Note that this document is not concluded and it is still slowly growing as I try to discuss more and more problems and use cases there. |
|||
23 Sep 2016, 06:11 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.