Board.KolibriOS.org

Official KolibriOS board
It is currently Sun Aug 25, 2019 11:23 pm

All times are UTC+03:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Dec 28, 2016 5:07 am 
Offline
Mentor
User avatar

Joined: Mon Oct 19, 2009 10:58 am
Posts: 421
Hi,

I wrote a macro I wanted for a long time. It took 10 lines and a few hours:
Code:
macro DEBUGFG _level, _group, _format, [_arg] {
 common
  if _group eqtype
   DEBUGF _level, _format,_arg
  else
   if _level >= _group
    DEBUGF 999, _format,_arg
   end if
  end if
}

This macro introduces so called log groups, a method to combine debug messages into logical groups to set their log level on per group basis.

Here is a simple example:
Spoiler: Show
Code:
use32
    org 0x0
    db  'MENUET01'
    dd  0x01,start,i_end,e_end,e_end,0,0

__DEBUG__ = 1
__DEBUG_LEVEL__ = 2

LOG_FLOW equ 1
LOG_CALC equ 3
LOG_SEND equ

include '../../../macros.inc'
include '../../../debug-fdo.inc'

start:
        DEBUGFG 1, LOG_FLOW, '1 flow\n'
        DEBUGFG 2, LOG_FLOW, '2 flow\n'
        DEBUGFG 3, LOG_FLOW, '3 flow\n'

        DEBUGFG 1, LOG_CALC, '1 calc\n'
        DEBUGFG 2, LOG_CALC, '2 calc\n'
        DEBUGFG 3, LOG_CALC, '3 calc\n'

        DEBUGFG 1, LOG_SEND, '1 send\n'
        DEBUGFG 2, LOG_SEND, '2 send\n'
        DEBUGFG 3, LOG_SEND, '3 send\n'

        DEBUGF 1, '1 blah\n'
        DEBUGF 2, '2 blah\n'
        DEBUGF 3, '3 blah\n'

        mov     eax, -1
        int     0x40


include_debug_strings

i_end:
rb 0x100        ;stack
e_end:


On debug board:
Code:
1 flow
2 flow
3 flow
3 calc
2 send
3 send
2 blah
3 blah


The macro works as follows:
  • If you specify log level for a group, it overrides __DEBUG_LEVEL__ for this particular group;
  • If you don't specify group log level, __DEBUG_LEVEL__ is used (calls DEBUGF);
  • If you misspelled group name, fasm will report an error.
Code:
$ fasm loggroups.asm loggroups
flat assembler  version 1.71.58  (16384 kilobytes memory)
loggroups.asm [23]:
        DEBUGFG 3, LOG_CLAC, '3 calc\n'
../../../debug-fdo.inc [380] DEBUGFG [5]:
   if _level >= _group
processed: if 3>=LOG_CLAC
error: undefined symbol 'LOG_CLAC'.

I hope this new macro will be useful for you.


Top
   
PostPosted: Wed Dec 28, 2016 12:55 pm 
Offline
Mentor/Kernel Developer
User avatar

Joined: Thu Mar 26, 2015 5:16 pm
Posts: 1264
It certainly could be useful... if you write a commentary about its arguments (or a one-string example). Same for the other macros. Cause each time I look into the fdo.inc I see a shit, so it's totally useless for me.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC+03:00


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited