• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 #include <android-base/logging.h>
21 #include <android-base/stringprintf.h>
22 
23 /* IMPORTANT: if you change the following list, don't
24  * forget to update the corresponding 'tags' table in
25  * the adb_trace_init() function implemented in adb_trace.cpp.
26  */
27 enum AdbTrace {
28     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
41 };
42 
43 #define VLOG_IS_ON(TAG) \
44     ((adb_trace_mask & (1 << (TAG))) != 0)
45 
46 #define VLOG(TAG)                 \
47     if (LIKELY(!VLOG_IS_ON(TAG))) \
48         ;                         \
49     else                          \
50         LOG(DEBUG)
51 
52 // You must define TRACE_TAG before using this macro.
53 #define D(...) \
54     VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__)
55 
56 
57 extern int adb_trace_mask;
58 void adb_trace_init(char**);
59 void adb_trace_enable(AdbTrace trace_tag);
60 
61 // Include <atomic> before stdatomic.h (introduced in cutils/trace.h) to avoid compile error.
62 #include <atomic>
63 
64 #define ATRACE_TAG ATRACE_TAG_ADB
65 #include <cutils/trace.h>
66 #include <utils/Trace.h>
67 
68 #endif /* __ADB_TRACE_H */
69