blob: 1d2c8c7041a9686cbe98336105bf032e108b5462 [file] [log] [blame]
leozwangd3fc15f2014-07-29 12:50:02 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __ADB_TRACE_H
18#define __ADB_TRACE_H
19
Elliott Hughes4f713192015-12-04 22:00:26 -080020#include <android-base/logging.h>
21#include <android-base/stringprintf.h>
leozwangd3fc15f2014-07-29 12:50:02 -070022
leozwangd3fc15f2014-07-29 12:50:02 -070023/* IMPORTANT: if you change the following list, don't
24 * forget to update the corresponding 'tags' table in
Yabin Cuiaed3c612015-09-22 15:52:57 -070025 * the adb_trace_init() function implemented in adb_trace.cpp.
leozwangd3fc15f2014-07-29 12:50:02 -070026 */
Elliott Hughes2d4121c2015-04-17 09:47:42 -070027enum AdbTrace {
Yabin Cuiaed3c612015-09-22 15:52:57 -070028 ADB = 0, /* 0x001 */
29 SOCKETS,
30 PACKETS,
31 TRANSPORT,
32 RWX, /* 0x010 */
33 USB,
34 SYNC,
35 SYSDEPS,
36 JDWP, /* 0x100 */
37 SERVICES,
38 AUTH,
39 FDEVENT,
40 SHELL
Elliott Hughesbd4b1fa2015-08-28 14:46:33 -070041};
leozwangd3fc15f2014-07-29 12:50:02 -070042
Yabin Cuiaed3c612015-09-22 15:52:57 -070043#define VLOG_IS_ON(TAG) \
Chih-Hung Hsieh67867db2016-05-18 15:53:15 -070044 ((adb_trace_mask & (1 << (TAG))) != 0)
leozwangd3fc15f2014-07-29 12:50:02 -070045
Josh Gao95c44972018-02-06 15:49:26 -080046#define VLOG(TAG) \
Yabin Cuiaed3c612015-09-22 15:52:57 -070047 if (LIKELY(!VLOG_IS_ON(TAG))) \
Josh Gao95c44972018-02-06 15:49:26 -080048 ; \
49 else \
50 LOG(DEBUG)
leozwangd3fc15f2014-07-29 12:50:02 -070051
Yabin Cui7a3f8d62015-09-02 17:44:28 -070052// You must define TRACE_TAG before using this macro.
53#define D(...) \
Yabin Cuiaed3c612015-09-22 15:52:57 -070054 VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__)
55
56
57extern int adb_trace_mask;
58void adb_trace_init(char**);
59void adb_trace_enable(AdbTrace trace_tag);
leozwangd3fc15f2014-07-29 12:50:02 -070060
Yabin Cuib5e11412017-03-10 16:01:01 -080061// Include <atomic> before stdatomic.h (introduced in cutils/trace.h) to avoid compile error.
62#include <atomic>
63
Josh Gaofd12aaa2016-11-22 14:33:08 -080064#define ATRACE_TAG ATRACE_TAG_ADB
65#include <cutils/trace.h>
66#include <utils/Trace.h>
67
leozwangd3fc15f2014-07-29 12:50:02 -070068#endif /* __ADB_TRACE_H */