debug.c (1727B)
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: debug.c 8 * Purpose: BCM API Debug declarations 9 * Requires: 10 */ 11 12 #include <shared/bsl.h> 13 14 #include <soc/defs.h> 15 #include <soc/cm.h> 16 #include <bcm/error.h> 17 18 #if defined(BROADCOM_DEBUG) 19 20 /* 21 * API Debug Message Helper. 22 * Called from the BCM_API macro in <bcm/debug.h> 23 * The BCM_API macro is called from the bcm api dispatcher. 24 */ 25 void 26 _bcm_debug_api(int log_src, char *api, 27 int nargs, int ninargs, 28 int arg1, int arg2, int arg3, int rv) 29 { 30 char *rvstr; 31 32 if (rv < 0) { 33 rvstr = bcm_errmsg(rv); 34 } else { 35 rvstr = bcm_errmsg(BCM_E_NONE); 36 } 37 38 switch (ninargs) { 39 case 0: 40 LOG_VERBOSE(log_src, 41 (BSL_META("API: %s(%s) -> %d %s\n"), 42 api, 43 nargs > 0 ? "..." : "", 44 rv, rvstr)); 45 break; 46 case 1: 47 LOG_VERBOSE(log_src, 48 (BSL_META("API: %s(%d%s) -> %d %s\n"), 49 api, arg1, 50 nargs > 1 ? ",..." : "", 51 rv, rvstr)); 52 break; 53 case 2: 54 LOG_VERBOSE(log_src, 55 (BSL_META("API: %s(%d,%d%s) -> %d %s\n"), 56 api, arg1, arg2, 57 nargs > 2 ? ",..." : "", 58 rv, rvstr)); 59 break; 60 default: 61 LOG_VERBOSE(log_src, 62 (BSL_META("API: %s(%d,%d,%d%s) -> %d %s\n"), 63 api, arg1, arg2, arg3, 64 nargs > 3 ? ",..." : "", 65 rv, rvstr)); 66 break; 67 } 68 } 69 70 #endif /* BROADCOM_DEBUG */