leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 1 | /* |
| 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 Hughes | f55ead9 | 2015-12-04 22:00:26 -0800 | [diff] [blame] | 20 | #include <android-base/logging.h> |
| 21 | #include <android-base/stringprintf.h> |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 22 | |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 23 | /* IMPORTANT: if you change the following list, don't |
| 24 | * forget to update the corresponding 'tags' table in |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 25 | * the adb_trace_init() function implemented in adb_trace.cpp. |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 26 | */ |
Elliott Hughes | fe7ff81 | 2015-04-17 09:47:42 -0700 | [diff] [blame] | 27 | enum AdbTrace { |
Alex Buynytskyy | 175ce29 | 2020-02-13 06:52:04 -0800 | [diff] [blame] | 28 | ADB = 0, /* 0x001 */ |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 29 | SOCKETS, |
| 30 | PACKETS, |
| 31 | TRANSPORT, |
Alex Buynytskyy | 175ce29 | 2020-02-13 06:52:04 -0800 | [diff] [blame] | 32 | RWX, /* 0x010 */ |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 33 | USB, |
| 34 | SYNC, |
| 35 | SYSDEPS, |
Alex Buynytskyy | 175ce29 | 2020-02-13 06:52:04 -0800 | [diff] [blame] | 36 | JDWP, /* 0x100 */ |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 37 | SERVICES, |
| 38 | AUTH, |
| 39 | FDEVENT, |
Alex Buynytskyy | 175ce29 | 2020-02-13 06:52:04 -0800 | [diff] [blame] | 40 | SHELL, |
| 41 | INCREMENTAL, |
Elliott Hughes | 0ea5924 | 2015-08-28 14:46:33 -0700 | [diff] [blame] | 42 | }; |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 43 | |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 44 | #define VLOG_IS_ON(TAG) \ |
Chih-Hung Hsieh | 88cee43 | 2016-05-18 15:53:15 -0700 | [diff] [blame] | 45 | ((adb_trace_mask & (1 << (TAG))) != 0) |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 46 | |
Josh Gao | da85713 | 2018-02-06 15:49:26 -0800 | [diff] [blame] | 47 | #define VLOG(TAG) \ |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 48 | if (LIKELY(!VLOG_IS_ON(TAG))) \ |
Josh Gao | da85713 | 2018-02-06 15:49:26 -0800 | [diff] [blame] | 49 | ; \ |
| 50 | else \ |
| 51 | LOG(DEBUG) |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 52 | |
Yabin Cui | 815ad88 | 2015-09-02 17:44:28 -0700 | [diff] [blame] | 53 | // You must define TRACE_TAG before using this macro. |
| 54 | #define D(...) \ |
Yabin Cui | 19bec5b | 2015-09-22 15:52:57 -0700 | [diff] [blame] | 55 | VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__) |
| 56 | |
| 57 | |
| 58 | extern int adb_trace_mask; |
| 59 | void adb_trace_init(char**); |
| 60 | void adb_trace_enable(AdbTrace trace_tag); |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 61 | |
Yabin Cui | 3cf1b36 | 2017-03-10 16:01:01 -0800 | [diff] [blame] | 62 | // Include <atomic> before stdatomic.h (introduced in cutils/trace.h) to avoid compile error. |
| 63 | #include <atomic> |
| 64 | |
Josh Gao | 14ed70a | 2016-11-22 14:33:08 -0800 | [diff] [blame] | 65 | #define ATRACE_TAG ATRACE_TAG_ADB |
| 66 | #include <cutils/trace.h> |
| 67 | #include <utils/Trace.h> |
| 68 | |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 69 | #endif /* __ADB_TRACE_H */ |