blob: d5a10d999b7b624e95b42b0de31bc6983056f13a [file] [log] [blame]
leozwangf25a6a42014-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 Hughesf55ead92015-12-04 22:00:26 -080020#include <android-base/logging.h>
21#include <android-base/stringprintf.h>
leozwangf25a6a42014-07-29 12:50:02 -070022
leozwangf25a6a42014-07-29 12:50:02 -070023/* IMPORTANT: if you change the following list, don't
24 * forget to update the corresponding 'tags' table in
Fabien Sanglardb94502a2024-06-17 17:37:50 -070025 * the setup_trace_mask() function implemented in adb_trace.cpp.
leozwangf25a6a42014-07-29 12:50:02 -070026 */
Elliott Hughesfe7ff812015-04-17 09:47:42 -070027enum AdbTrace {
Alex Buynytskyy175ce292020-02-13 06:52:04 -080028 ADB = 0, /* 0x001 */
Yabin Cui19bec5b2015-09-22 15:52:57 -070029 SOCKETS,
30 PACKETS,
31 TRANSPORT,
Alex Buynytskyy175ce292020-02-13 06:52:04 -080032 RWX, /* 0x010 */
Yabin Cui19bec5b2015-09-22 15:52:57 -070033 USB,
34 SYNC,
35 SYSDEPS,
Alex Buynytskyy175ce292020-02-13 06:52:04 -080036 JDWP, /* 0x100 */
Yabin Cui19bec5b2015-09-22 15:52:57 -070037 SERVICES,
38 AUTH,
39 FDEVENT,
Alex Buynytskyy175ce292020-02-13 06:52:04 -080040 SHELL,
41 INCREMENTAL,
Fabien Sanglardb94502a2024-06-17 17:37:50 -070042 MDNS,
43 NUM_TRACES,
Elliott Hughes0ea59242015-08-28 14:46:33 -070044};
leozwangf25a6a42014-07-29 12:50:02 -070045
Yabin Cui19bec5b2015-09-22 15:52:57 -070046#define VLOG_IS_ON(TAG) \
Chih-Hung Hsieh88cee432016-05-18 15:53:15 -070047 ((adb_trace_mask & (1 << (TAG))) != 0)
leozwangf25a6a42014-07-29 12:50:02 -070048
Josh Gaoda857132018-02-06 15:49:26 -080049#define VLOG(TAG) \
Yabin Cui19bec5b2015-09-22 15:52:57 -070050 if (LIKELY(!VLOG_IS_ON(TAG))) \
Josh Gaoda857132018-02-06 15:49:26 -080051 ; \
52 else \
53 LOG(DEBUG)
leozwangf25a6a42014-07-29 12:50:02 -070054
Yabin Cui815ad882015-09-02 17:44:28 -070055// You must define TRACE_TAG before using this macro.
56#define D(...) \
Yabin Cui19bec5b2015-09-22 15:52:57 -070057 VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__)
58
59
60extern int adb_trace_mask;
61void adb_trace_init(char**);
62void adb_trace_enable(AdbTrace trace_tag);
leozwangf25a6a42014-07-29 12:50:02 -070063
leozwangf25a6a42014-07-29 12:50:02 -070064#endif /* __ADB_TRACE_H */