Official KolibriOS board
It is currently Thu Jan 20, 2022 5:16 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 
User avatar

Joined: Mon Oct 19, 2009 10:58 am
Posts: 707

I wrote a macro I wanted for a long time. It took 10 lines and a few hours:
macro DEBUGFG _level, _group, _format, [_arg] {
  if _group eqtype
   DEBUGF _level, _format,_arg
   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
    org 0x0
    db  'MENUET01'
    dd  0x01,start,i_end,e_end,e_end,0,0

__DEBUG__ = 1

LOG_FLOW equ 1
LOG_CALC equ 3

include '../../../'
include '../../../'

        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


rb 0x100        ;stack

On debug board:
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.
$ fasm loggroups.asm loggroups
flat assembler  version 1.71.58  (16384 kilobytes memory)
loggroups.asm [23]:
        DEBUGFG 3, LOG_CLAC, '3 calc\n'
../../../ [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.

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

Joined: Thu Mar 26, 2015 5:16 pm
Posts: 1282
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 I see a shit, so it's totally useless for me.

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 3 guests

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