Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e355ae4 authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "system: Remove legacy LogMsg implementations" into main

parents 3c97634f f148e3cd
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -222,7 +222,6 @@ cc_test {
    test_suites: ["device-tests"],
    srcs: [
        ":LegacyStackSdp",
        ":TestCommonLogMsg",
        ":TestCommonMockFunctions",
        ":TestFakeOsi",
        ":TestMockBtif",
@@ -282,7 +281,6 @@ cc_test {
    ],
    test_suites: ["device-tests"],
    srcs: [
        ":TestCommonLogMsg",
        ":TestCommonMockFunctions",
        ":TestMockBtif",
        ":TestMockDevice",
@@ -337,7 +335,6 @@ cc_test {
        ":BtaDmSources",
        ":LegacyStackSdp",
        ":OsiCompatSources",
        ":TestCommonLogMsg",
        ":TestCommonMainHandler",
        ":TestCommonMockFunctions",
        ":TestFakeOsi",
@@ -1249,7 +1246,6 @@ cc_test {
    ],
    srcs: [
        ":BtaDmSources",
        ":TestCommonLogMsg",
        ":TestCommonMainHandler",
        ":TestCommonMockFunctions",
        ":TestMockBtaGatt",
+0 −2
Original line number Diff line number Diff line
@@ -420,7 +420,6 @@ cc_test {
    },
    include_dirs: btifCommonIncludes,
    srcs: [
        ":TestCommonLogMsg",
        ":TestCommonMockFunctions",
        ":TestMockCommon",
        ":TestMockOsi",
@@ -512,7 +511,6 @@ cc_test {
    test_suites: ["device-tests"],
    include_dirs: btifCommonIncludes,
    srcs: [
        ":TestCommonLogMsg",
        ":TestCommonMockFunctions",
        ":TestFakeOsi",
        ":TestMockStack",
+0 −28
Original line number Diff line number Diff line
@@ -2,34 +2,6 @@
# Must be present before any TRC_ trace level settings
TraceConf=true

# Trace level configuration
#   BT_TRACE_LEVEL_NONE    0    ( No trace messages to be generated )
#   BT_TRACE_LEVEL_ERROR   1    ( Error condition trace messages )
#   BT_TRACE_LEVEL_WARNING 2    ( Warning condition trace messages )
#   BT_TRACE_LEVEL_API     3    ( API traces )
#   BT_TRACE_LEVEL_EVENT   4    ( Debug messages for events )
#   BT_TRACE_LEVEL_DEBUG   5    ( Full debug messages )
#   BT_TRACE_LEVEL_VERBOSE 6    ( Verbose messages ) - Currently supported for TRC_BTAPP only.
TRC_BTM=2
TRC_HCI=2
TRC_L2CAP=2
TRC_RFCOMM=2
TRC_OBEX=2
TRC_AVCT=2
TRC_AVDT=2
TRC_AVRC=2
TRC_AVDT_SCB=2
TRC_AVDT_CCB=2
TRC_A2D=2
TRC_SDP=2
TRC_SMP=2
TRC_BTAPP=2
TRC_BTIF=2
TRC_BNEP=2
TRC_PAN=2
TRC_HID_HOST=2
TRC_HID_DEV=2

# This is Log configuration for new C++ code using LOG() macros.
# See libchrome/base/logging.h for description on how to configure your logs.
# sample configuration:
+0 −235
Original line number Diff line number Diff line
@@ -20,247 +20,12 @@

#include <stdint.h>

// move this function outof extern "C" block
// as it is a C++ function.
__attribute__((format(printf, 5, 6))) extern void LogMsg(
    uint32_t trace_set_mask, const char* filename, uint32_t linenum,
    const char* func, const char* fmt_str, ...);

#ifdef __cplusplus
extern "C" {
#endif

/*****************************************************************************/

/* Define trace levels */
typedef enum {
  BT_TRACE_LEVEL_NONE = 0,    /* No trace messages to be generated    */
  BT_TRACE_LEVEL_ERROR = 1,   /* Error condition trace messages       */
  BT_TRACE_LEVEL_WARNING = 2, /* Warning condition trace messages     */
  BT_TRACE_LEVEL_API = 3,     /* API traces                           */
  BT_TRACE_LEVEL_EVENT = 4,   /* Debug messages for events            */
  BT_TRACE_LEVEL_DEBUG = 5,   /* Full debug messages                  */
  BT_TRACE_LEVEL_VERBOSE = 6, /* Verbose debug messages               */
} tLEGACY_TRACE_LEVEL;

#define TRACE_CTRL_GENERAL 0x00000000

#define TRACE_LAYER_MASK 0x00ff0000
#define TRACE_GET_LAYER(x) ((((uint32_t)(x)) & TRACE_LAYER_MASK) >> 16)

#define TRACE_LAYER_NONE 0x00000000
#define TRACE_LAYER_HCI 0x00070000
#define TRACE_LAYER_L2CAP 0x00080000
#define TRACE_LAYER_RFCOMM 0x00090000
#define TRACE_LAYER_SDP 0x000a0000
#define TRACE_LAYER_BTM 0x000d0000
#define TRACE_LAYER_BNEP 0x001b0000
#define TRACE_LAYER_PAN 0x001c0000
#define TRACE_LAYER_HID 0x001e0000
#define TRACE_LAYER_AVP 0x00200000
#define TRACE_LAYER_A2DP 0x00210000
#define TRACE_LAYER_SMP 0x00260000

#define TRACE_LAYER_MAX_NUM 0x0031

#define TRACE_ORG_MASK 0x0000ff00
#define TRACE_GET_ORG(x) ((((uint32_t)(x)) & TRACE_ORG_MASK) >> 8)

#define TRACE_ORG_STACK 0x00000000
#define TRACE_ORG_APPL 0x00000500
#define TRACE_ORG_USER_SCR 0x00000800

#define TRACE_TYPE_MASK 0x000000ff
#define TRACE_GET_TYPE(x) (((uint32_t)(x)) & TRACE_TYPE_MASK)

#define TRACE_TYPE_ERROR 0x00000000
#define TRACE_TYPE_WARNING 0x00000001
#define TRACE_TYPE_API 0x00000002
#define TRACE_TYPE_EVENT 0x00000003
#define TRACE_TYPE_DEBUG 0x00000004
#define TRACE_TYPE_INFO 0x00000005

static const char BTE_LOGMSG_MODULE[] = "bte_logmsg_module";

/* BTE tracing IDs for debug purposes */
/* LayerIDs for stack */
#define BTTRC_ID_STK_GKI 1
#define BTTRC_ID_STK_BTU 2
#define BTTRC_ID_STK_HCI 3
#define BTTRC_ID_STK_L2CAP 4
#define BTTRC_ID_STK_RFCM_MX 5
#define BTTRC_ID_STK_RFCM_PRT 6
#define BTTRC_ID_STK_OBEX_C 7
#define BTTRC_ID_STK_OBEX_S 8
#define BTTRC_ID_STK_AVCT 9
#define BTTRC_ID_STK_AVDT 10
#define BTTRC_ID_STK_AVRC 11
#define BTTRC_ID_STK_BIC 12
#define BTTRC_ID_STK_BIS 13
#define BTTRC_ID_STK_BNEP 14
#define BTTRC_ID_STK_BPP 15
#define BTTRC_ID_STK_BTM_ACL 16
#define BTTRC_ID_STK_BTM_PM 17
#define BTTRC_ID_STK_BTM_DEV_CTRL 18
#define BTTRC_ID_STK_BTM_SVC_DSC 19
#define BTTRC_ID_STK_BTM_INQ 20
#define BTTRC_ID_STK_BTM_SCO 21
#define BTTRC_ID_STK_BTM_SEC 22
#define BTTRC_ID_STK_HID 24
#define BTTRC_ID_STK_HSP2 25
#define BTTRC_ID_STK_CTP 26
#define BTTRC_ID_STK_FTC 27
#define BTTRC_ID_STK_FTS 28
#define BTTRC_ID_STK_HCRP 31
#define BTTRC_ID_STK_ICP 32
#define BTTRC_ID_STK_OPC 33
#define BTTRC_ID_STK_OPS 34
#define BTTRC_ID_STK_PAN 35
#define BTTRC_ID_STK_SAP 36
#define BTTRC_ID_STK_SDP 37
#define BTTRC_ID_STK_SLIP 38
#define BTTRC_ID_STK_SPP 39
#define BTTRC_ID_STK_TCS 40
#define BTTRC_ID_STK_VDP 41
#define BTTRC_ID_STK_MCAP 42 /* OBSOLETE */
#define BTTRC_ID_STK_GATT 43
#define BTTRC_ID_STK_SMP 44
#define BTTRC_ID_STK_NFC 45
#define BTTRC_ID_STK_NCI 46
#define BTTRC_ID_STK_IDEP 47
#define BTTRC_ID_STK_NDEP 48
#define BTTRC_ID_STK_LLCP 49
#define BTTRC_ID_STK_RW 50
#define BTTRC_ID_STK_CE 51
#define BTTRC_ID_STK_SNEP 52
#define BTTRC_ID_STK_NDEF 53
#define BTTRC_ID_STK_HIDD 54

/* LayerIDs for BTA */
#define BTTRC_ID_BTA_ACC 55 /* Advanced Camera Client */
#define BTTRC_ID_BTA_AG 56  /* audio gateway */
#define BTTRC_ID_BTA_AV 57  /* Advanced audio */
#define BTTRC_ID_BTA_BIC 58 /* Basic Imaging Client */
#define BTTRC_ID_BTA_BIS 59 /* Basic Imaging Server */
#define BTTRC_ID_BTA_BP 60  /* Basic Printing Client */
#define BTTRC_ID_BTA_CG 61
#define BTTRC_ID_BTA_CT 62      /* cordless telephony terminal */
#define BTTRC_ID_BTA_DG 63      /* data gateway */
#define BTTRC_ID_BTA_DM 64      /* device manager */
#define BTTRC_ID_BTA_DM_SRCH 65 /* device manager search */
#define BTTRC_ID_BTA_DM_SEC 66  /* device manager security */
#define BTTRC_ID_BTA_FM 67
#define BTTRC_ID_BTA_FTC 68 /* file transfer client */
#define BTTRC_ID_BTA_FTS 69 /* file transfer server */
#define BTTRC_ID_BTA_HIDH 70
#define BTTRC_ID_BTA_HIDD 71
#define BTTRC_ID_BTA_JV 72
#define BTTRC_ID_BTA_OPC 73  /* object push client */
#define BTTRC_ID_BTA_OPS 74  /* object push server */
#define BTTRC_ID_BTA_PAN 75  /* Personal Area Networking */
#define BTTRC_ID_BTA_PR 76   /* Printer client */
#define BTTRC_ID_BTA_SC 77   /* SIM Card Access server */
#define BTTRC_ID_BTA_SS 78   /* synchronization server */
#define BTTRC_ID_BTA_SYS 79  /* system manager */
#define BTTRC_ID_AVDT_SCB 80 /* avdt scb */
#define BTTRC_ID_AVDT_CCB 81 /* avdt ccb */

/* LayerIDs added for BTL-A. Probably should modify bte_logmsg.cc in future. */
#define BTTRC_ID_STK_RFCOMM 82
#define BTTRC_ID_STK_RFCOMM_DATA 83
#define BTTRC_ID_STK_OBEX 84
#define BTTRC_ID_STK_A2DP 85
#define BTTRC_ID_STK_BIP 86

/* LayerIDs for BT APP */
#define BTTRC_ID_BTAPP 87
/* this is a temporary solution to allow dynamic enable/disable of
 * BT_PROTOCOL_TRACE */
#define BTTRC_ID_BT_PROTOCOL 88
#define BTTRC_ID_MAX_ID BTTRC_ID_BT_PROTOCOL
#define BTTRC_ID_ALL_LAYERS 0xFF /* all trace layers */

/******************************************************************************
 *
 * Trace Levels
 *
 * The following values may be used for different levels:
 *      BT_TRACE_LEVEL_NONE    0        * No trace messages to be generated
 *      BT_TRACE_LEVEL_ERROR   1        * Error condition trace messages
 *      BT_TRACE_LEVEL_WARNING 2        * Warning condition trace messages
 *      BT_TRACE_LEVEL_API     3        * API traces
 *      BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
 *      BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
 *****************************************************************************/

/* Core Stack default trace levels */
#ifndef HCI_INITIAL_TRACE_LEVEL
#define HCI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef BTM_INITIAL_TRACE_LEVEL
#define BTM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef L2CAP_INITIAL_TRACE_LEVEL
#define L2CAP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef RFCOMM_INITIAL_TRACE_LEVEL
#define RFCOMM_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef BNEP_INITIAL_TRACE_LEVEL
#define BNEP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef PAN_INITIAL_TRACE_LEVEL
#define PAN_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef A2DP_INITIAL_TRACE_LEVEL
#define A2DP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef AVDT_INITIAL_TRACE_LEVEL
#define AVDT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef AVCT_INITIAL_TRACE_LEVEL
#define AVCT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef AVRC_INITIAL_TRACE_LEVEL
#define AVRC_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef HID_INITIAL_TRACE_LEVEL
#define HID_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef APPL_INITIAL_TRACE_LEVEL
#define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef GATT_INITIAL_TRACE_LEVEL
#define GATT_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

#ifndef SMP_INITIAL_TRACE_LEVEL
#define SMP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif

typedef uint8_t tBTTRC_LAYER_ID;
typedef uint8_t(tBTTRC_SET_TRACE_LEVEL)(uint8_t);

typedef struct {
  const tBTTRC_LAYER_ID layer_id_start;
  const tBTTRC_LAYER_ID layer_id_end;
  tBTTRC_SET_TRACE_LEVEL* p_f;
  const char* trc_name;
  uint8_t trace_level;
} tBTTRC_FUNC_MAP;

#ifdef __cplusplus
}
#endif
+0 −105
Original line number Diff line number Diff line
@@ -26,111 +26,6 @@
#include "main/main_int.h"
#include "osi/include/log.h"

#ifndef BTE_LOG_BUF_SIZE
#define BTE_LOG_BUF_SIZE 256
#endif

#define BTE_LOG_MAX_SIZE (BTE_LOG_BUF_SIZE - 12)

#define MSG_BUFFER_OFFSET 0

/* LayerIDs for BTA, currently everything maps onto appl_trace_level */
static const char* const bt_layer_tags[] = {
    "bt_btif",
    "bt_usb",
    "bt_serial",
    "bt_socket",
    "bt_rs232",
    "bt_lc",
    "bt_lm",
    "bt_hci",
    "bt_l2cap",
    "bt_rfcomm",
    "bt_sdp",
    "bt_tcs",
    "bt_obex",
    "bt_btm",
    "bt_gap",
    "UNUSED",
    "UNUSED",
    "bt_icp",
    "bt_hsp2",
    "bt_spp",
    "bt_ctp",
    "bt_bpp",
    "bt_hcrp",
    "bt_ftp",
    "bt_opp",
    "bt_btu",
    "bt_gki_deprecated",
    "bt_bnep",
    "bt_pan",
    "bt_hfp",
    "bt_hid",
    "bt_bip",
    "bt_avp",
    "bt_a2d",
    "bt_sap",
    "bt_amp",
    "bt_mca_deprecated",
    "bt_att",
    "bt_smp",
    "bt_nfc",
    "bt_nci",
    "bt_idep",
    "bt_ndep",
    "bt_llcp",
    "bt_rw",
    "bt_ce",
    "bt_snep",
    "bt_ndef",
    "bt_nfa",
};

void LogMsg(uint32_t trace_set_mask,
            const char* filename, uint32_t linenum, const char* func,
            const char* fmt_str, ...) {
  char buffer[BTE_LOG_BUF_SIZE];
  int trace_layer = TRACE_GET_LAYER(trace_set_mask);
  if (trace_layer >= TRACE_LAYER_MAX_NUM) trace_layer = 0;

  va_list ap;
  va_start(ap, fmt_str);
  vsnprintf(&buffer[MSG_BUFFER_OFFSET], BTE_LOG_MAX_SIZE, fmt_str, ap);
  va_end(ap);

#undef LOG_TAG
#define LOG_TAG bt_layer_tags[trace_layer]

  switch (TRACE_GET_TYPE(trace_set_mask)) {
    case TRACE_TYPE_ERROR:
      LOG_ERROR_INT(_LOG_SRC_FMT_STR "%s", filename, linenum, func, buffer);
      break;
    case TRACE_TYPE_WARNING:
      LOG_WARN_INT(_LOG_SRC_FMT_STR "%s", filename, linenum, func, buffer);
      break;
    case TRACE_TYPE_API:
    case TRACE_TYPE_EVENT:
      LOG_INFO_INT(_LOG_SRC_FMT_STR "%s", filename, linenum, func, buffer);
      break;
    case TRACE_TYPE_DEBUG:
      LOG_DEBUG_INT(_LOG_SRC_FMT_STR "%s", filename, linenum, func, buffer);
      break;
    case TRACE_TYPE_INFO:
      LOG_INFO_INT(_LOG_SRC_FMT_STR "%s", filename, linenum, func, buffer);
      break;
    default:
      /* we should never get this */
      LOG_ERROR_INT("!BAD TRACE TYPE! " _LOG_SRC_FMT_STR "%s", filename,
                    linenum, func, buffer);

      CHECK(TRACE_GET_TYPE(trace_set_mask) == TRACE_TYPE_ERROR);
      break;
  }
#undef LOG_TAG
#define LOG_TAG "bt_bte"
}

static future_t* init(void) {
  const stack_config_t* stack_config = stack_config_get_interface();
  if (!stack_config->get_trace_config_enabled()) {
Loading