openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

cint_debug.c (1534B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        cint_debug.c
      8  * Purpose:     CINT debug functions
      9  */
     10 
     11 #include "cint_config.h"
     12 #include "cint_porting.h"
     13 #include "cint_debug.h"
     14 #include "cint_interpreter.h"
     15 #include "cint_ast.h"
     16 
     17 void
     18 __cint_trace(const char* pfx, const char* fmt, va_list args)
     19      COMPILER_ATTRIBUTE((format (printf, 2, 0))); 
     20 
     21 
     22 void
     23 __cint_trace(const char* pfx, const char* fmt, va_list args)
     24 {
     25     CINT_PRINTF("{%s: ", pfx); 
     26     CINT_VPRINTF(fmt, args); 
     27     CINT_PRINTF("}\n"); 
     28 }
     29 
     30 void 
     31 cint_dtrace(const char* fmt, ...)
     32 {
     33     va_list args;     
     34     if(interp.debug.dtrace) {
     35         va_start(args, fmt); 
     36         __cint_trace("DTRACE", fmt, args); 
     37         va_end(args); 
     38     }   
     39 }
     40 
     41 void 
     42 cint_debug(const char* fmt, ...)
     43 {
     44     va_list args;     
     45     va_start(args, fmt); 
     46     __cint_trace("DEBUG", fmt, args); 
     47     va_end(args); 
     48 }
     49 
     50 
     51 void 
     52 cint_trace(const char* pfx, const char* fmt, ...)
     53 {
     54     va_list args; 
     55     va_start(args, fmt); 
     56     __cint_trace(pfx, fmt, args); 
     57     va_end(args); 
     58 }
     59 
     60 void
     61 cint_ftrace(const char* name, int enter)
     62 {
     63     if(interp.debug.ftrace) {
     64         cint_trace("FTRACE", "'%s' %s", 
     65                    name, enter ? "Enter" : "Exit"); 
     66     }
     67 }
     68 
     69 void
     70 cint_atrace(cint_ast_t* ast)
     71 {
     72     if(interp.debug.atrace) {
     73         cint_trace("ATRACE", "%s", ""); 
     74         cint_ast_dump_single(ast, 8); 
     75     }
     76 }