blob: 67ee854b7b08ac46b05101380cbd8d1f1e544615 [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
Yabin Cui7a3f8d62015-09-02 17:44:28 -070020#include <base/logging.h>
21#include <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
25 * the adb_trace_init() function implemented in adb.c
26 */
Elliott Hughes2d4121c2015-04-17 09:47:42 -070027enum AdbTrace {
leozwangd3fc15f2014-07-29 12:50:02 -070028 TRACE_ADB = 0, /* 0x001 */
29 TRACE_SOCKETS,
30 TRACE_PACKETS,
31 TRACE_TRANSPORT,
32 TRACE_RWX, /* 0x010 */
33 TRACE_USB,
34 TRACE_SYNC,
35 TRACE_SYSDEPS,
36 TRACE_JDWP, /* 0x100 */
37 TRACE_SERVICES,
38 TRACE_AUTH,
39 TRACE_FDEVENT,
Elliott Hughesbd4b1fa2015-08-28 14:46:33 -070040};
leozwangd3fc15f2014-07-29 12:50:02 -070041
Dan Albert9313c0d2015-05-21 13:58:50 -070042extern int adb_trace_mask;
43extern unsigned char adb_trace_output_count;
44void adb_trace_init(char**);
leozwangd3fc15f2014-07-29 12:50:02 -070045
Yabin Cui7a3f8d62015-09-02 17:44:28 -070046#define ADB_TRACING ((adb_trace_mask & (1 << TRACE_TAG)) != 0)
leozwangd3fc15f2014-07-29 12:50:02 -070047
Yabin Cui7a3f8d62015-09-02 17:44:28 -070048// You must define TRACE_TAG before using this macro.
49#define D(...) \
Elliott Hughesbd4b1fa2015-08-28 14:46:33 -070050 do { \
51 if (ADB_TRACING) { \
52 int saved_errno = errno; \
Yabin Cui7a3f8d62015-09-02 17:44:28 -070053 LOG(INFO) << android::base::StringPrintf(__VA_ARGS__); \
Elliott Hughesbd4b1fa2015-08-28 14:46:33 -070054 errno = saved_errno; \
55 } \
leozwangd3fc15f2014-07-29 12:50:02 -070056 } while (0)
leozwangd3fc15f2014-07-29 12:50:02 -070057
leozwangd3fc15f2014-07-29 12:50:02 -070058#endif /* __ADB_TRACE_H */