am e4975da3: Merge "Adb: use VLOG() to replace D() for verbose logging."
* commit 'e4975da33326295885f4c606288516d73459c68e': Adb: use VLOG() to replace D() for verbose logging.
This commit is contained in:
commit
56ece709b0
30 changed files with 253 additions and 219 deletions
|
|
@ -37,6 +37,7 @@ LIBADB_SRC_FILES := \
|
||||||
adb_auth.cpp \
|
adb_auth.cpp \
|
||||||
adb_io.cpp \
|
adb_io.cpp \
|
||||||
adb_listeners.cpp \
|
adb_listeners.cpp \
|
||||||
|
adb_trace.cpp \
|
||||||
adb_utils.cpp \
|
adb_utils.cpp \
|
||||||
sockets.cpp \
|
sockets.cpp \
|
||||||
transport.cpp \
|
transport.cpp \
|
||||||
|
|
|
||||||
141
adb/adb.cpp
141
adb/adb.cpp
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "adb.h"
|
#include "adb.h"
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include <base/logging.h>
|
#include <base/logging.h>
|
||||||
#include <base/macros.h>
|
#include <base/macros.h>
|
||||||
|
|
@ -53,22 +52,6 @@
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !ADB_HOST
|
|
||||||
const char* adb_device_banner = "device";
|
|
||||||
static android::base::LogdLogger gLogdLogger;
|
|
||||||
#else
|
|
||||||
const char* adb_device_banner = "host";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void AdbLogger(android::base::LogId id, android::base::LogSeverity severity,
|
|
||||||
const char* tag, const char* file, unsigned int line,
|
|
||||||
const char* message) {
|
|
||||||
android::base::StderrLogger(id, severity, tag, file, line, message);
|
|
||||||
#if !ADB_HOST
|
|
||||||
gLogdLogger(id, severity, tag, file, line, message);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string adb_version() {
|
std::string adb_version() {
|
||||||
// Don't change the format of this --- it's parsed by ddmlib.
|
// Don't change the format of this --- it's parsed by ddmlib.
|
||||||
return android::base::StringPrintf("Android Debug Bridge version %d.%d.%d\n"
|
return android::base::StringPrintf("Android Debug Bridge version %d.%d.%d\n"
|
||||||
|
|
@ -97,128 +80,6 @@ void fatal_errno(const char* fmt, ...) {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !ADB_HOST
|
|
||||||
static std::string get_log_file_name() {
|
|
||||||
struct tm now;
|
|
||||||
time_t t;
|
|
||||||
tzset();
|
|
||||||
time(&t);
|
|
||||||
localtime_r(&t, &now);
|
|
||||||
|
|
||||||
char timestamp[PATH_MAX];
|
|
||||||
strftime(timestamp, sizeof(timestamp), "%Y-%m-%d-%H-%M-%S", &now);
|
|
||||||
|
|
||||||
return android::base::StringPrintf("/data/adb/adb-%s-%d", timestamp,
|
|
||||||
getpid());
|
|
||||||
}
|
|
||||||
|
|
||||||
void start_device_log(void) {
|
|
||||||
int fd = unix_open(get_log_file_name().c_str(),
|
|
||||||
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
|
|
||||||
if (fd == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirect stdout and stderr to the log file.
|
|
||||||
dup2(fd, STDOUT_FILENO);
|
|
||||||
dup2(fd, STDERR_FILENO);
|
|
||||||
fprintf(stderr, "--- adb starting (pid %d) ---\n", getpid());
|
|
||||||
unix_close(fd);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int adb_trace_mask;
|
|
||||||
|
|
||||||
std::string get_trace_setting_from_env() {
|
|
||||||
const char* setting = getenv("ADB_TRACE");
|
|
||||||
if (setting == nullptr) {
|
|
||||||
setting = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::string(setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !ADB_HOST
|
|
||||||
std::string get_trace_setting_from_prop() {
|
|
||||||
char buf[PROPERTY_VALUE_MAX];
|
|
||||||
property_get("persist.adb.trace_mask", buf, "");
|
|
||||||
return std::string(buf);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string get_trace_setting() {
|
|
||||||
#if ADB_HOST
|
|
||||||
return get_trace_setting_from_env();
|
|
||||||
#else
|
|
||||||
return get_trace_setting_from_prop();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split the space separated list of tags from the trace setting and build the
|
|
||||||
// trace mask from it. note that '1' and 'all' are special cases to enable all
|
|
||||||
// tracing.
|
|
||||||
//
|
|
||||||
// adb's trace setting comes from the ADB_TRACE environment variable, whereas
|
|
||||||
// adbd's comes from the system property persist.adb.trace_mask.
|
|
||||||
static void setup_trace_mask() {
|
|
||||||
const std::string trace_setting = get_trace_setting();
|
|
||||||
if (trace_setting.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_map<std::string, int> trace_flags = {
|
|
||||||
{"1", 0},
|
|
||||||
{"all", 0},
|
|
||||||
{"adb", TRACE_ADB},
|
|
||||||
{"sockets", TRACE_SOCKETS},
|
|
||||||
{"packets", TRACE_PACKETS},
|
|
||||||
{"rwx", TRACE_RWX},
|
|
||||||
{"usb", TRACE_USB},
|
|
||||||
{"sync", TRACE_SYNC},
|
|
||||||
{"sysdeps", TRACE_SYSDEPS},
|
|
||||||
{"transport", TRACE_TRANSPORT},
|
|
||||||
{"jdwp", TRACE_JDWP},
|
|
||||||
{"services", TRACE_SERVICES},
|
|
||||||
{"auth", TRACE_AUTH},
|
|
||||||
{"fdevent", TRACE_FDEVENT},
|
|
||||||
{"shell", TRACE_SHELL}};
|
|
||||||
|
|
||||||
std::vector<std::string> elements = android::base::Split(trace_setting, " ");
|
|
||||||
for (const auto& elem : elements) {
|
|
||||||
const auto& flag = trace_flags.find(elem);
|
|
||||||
if (flag == trace_flags.end()) {
|
|
||||||
D("Unknown trace flag: %s", elem.c_str());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag->second == 0) {
|
|
||||||
// 0 is used for the special values "1" and "all" that enable all
|
|
||||||
// tracing.
|
|
||||||
adb_trace_mask = ~0;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
adb_trace_mask |= 1 << flag->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void adb_trace_init(char** argv) {
|
|
||||||
#if !ADB_HOST
|
|
||||||
// Don't open log file if no tracing, since this will block
|
|
||||||
// the crypto unmount of /data
|
|
||||||
if (!get_trace_setting().empty()) {
|
|
||||||
if (isatty(STDOUT_FILENO) == 0) {
|
|
||||||
start_device_log();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
setup_trace_mask();
|
|
||||||
android::base::InitLogging(argv, AdbLogger);
|
|
||||||
|
|
||||||
D("%s", adb_version().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
apacket* get_apacket(void)
|
apacket* get_apacket(void)
|
||||||
{
|
{
|
||||||
apacket* p = reinterpret_cast<apacket*>(malloc(sizeof(apacket)));
|
apacket* p = reinterpret_cast<apacket*>(malloc(sizeof(apacket)));
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "adb_auth.h"
|
#include "adb_auth.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_AUTH
|
#define TRACE_TAG AUTH
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "adb_auth.h"
|
#include "adb_auth.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_AUTH
|
#define TRACE_TAG AUTH
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "adb_auth.h"
|
#include "adb_auth.h"
|
||||||
|
|
@ -452,7 +452,6 @@ int adb_auth_get_userkey(unsigned char *data, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
int adb_auth_keygen(const char* filename) {
|
int adb_auth_keygen(const char* filename) {
|
||||||
adb_trace_mask |= (1 << TRACE_AUTH);
|
|
||||||
return (generate_key(filename) == 0);
|
return (generate_key(filename) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "adb_client.h"
|
#include "adb_client.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_RWX
|
#define TRACE_TAG RWX
|
||||||
|
|
||||||
#include "adb_io.h"
|
#include "adb_io.h"
|
||||||
|
|
||||||
|
|
@ -84,10 +84,8 @@ bool ReadFdExactly(int fd, void* buf, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
D("readx: fd=%d wanted=%zu got=%zu", fd, len0, len0 - len);
|
VLOG(RWX) << "readx: fd=" << fd << " wanted=" << len0 << " got=" << (len0 - len)
|
||||||
if (ADB_TRACING) {
|
<< " " << dump_hex(reinterpret_cast<const unsigned char*>(buf), len0);
|
||||||
dump_hex(reinterpret_cast<const unsigned char*>(buf), len0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -96,10 +94,8 @@ bool WriteFdExactly(int fd, const void* buf, size_t len) {
|
||||||
const char* p = reinterpret_cast<const char*>(buf);
|
const char* p = reinterpret_cast<const char*>(buf);
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
D("writex: fd=%d len=%d: ", fd, (int)len);
|
VLOG(RWX) << "writex: fd=" << fd << " len=" << len
|
||||||
if (ADB_TRACING) {
|
<< " " << dump_hex(reinterpret_cast<const unsigned char*>(buf), len);
|
||||||
dump_hex(reinterpret_cast<const unsigned char*>(buf), len);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
r = adb_write(fd, p, len);
|
r = adb_write(fd, p, len);
|
||||||
|
|
|
||||||
174
adb/adb_trace.cpp
Normal file
174
adb/adb_trace.cpp
Normal file
|
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sysdeps.h"
|
||||||
|
#include "adb_trace.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <base/logging.h>
|
||||||
|
#include <base/strings.h>
|
||||||
|
|
||||||
|
#include "adb.h"
|
||||||
|
|
||||||
|
#if !ADB_HOST
|
||||||
|
#include <cutils/properties.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !ADB_HOST
|
||||||
|
const char* adb_device_banner = "device";
|
||||||
|
static android::base::LogdLogger gLogdLogger;
|
||||||
|
#else
|
||||||
|
const char* adb_device_banner = "host";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void AdbLogger(android::base::LogId id, android::base::LogSeverity severity,
|
||||||
|
const char* tag, const char* file, unsigned int line,
|
||||||
|
const char* message) {
|
||||||
|
android::base::StderrLogger(id, severity, tag, file, line, message);
|
||||||
|
#if !ADB_HOST
|
||||||
|
gLogdLogger(id, severity, tag, file, line, message);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !ADB_HOST
|
||||||
|
static std::string get_log_file_name() {
|
||||||
|
struct tm now;
|
||||||
|
time_t t;
|
||||||
|
tzset();
|
||||||
|
time(&t);
|
||||||
|
localtime_r(&t, &now);
|
||||||
|
|
||||||
|
char timestamp[PATH_MAX];
|
||||||
|
strftime(timestamp, sizeof(timestamp), "%Y-%m-%d-%H-%M-%S", &now);
|
||||||
|
|
||||||
|
return android::base::StringPrintf("/data/adb/adb-%s-%d", timestamp,
|
||||||
|
getpid());
|
||||||
|
}
|
||||||
|
|
||||||
|
void start_device_log(void) {
|
||||||
|
int fd = unix_open(get_log_file_name().c_str(),
|
||||||
|
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
|
||||||
|
if (fd == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect stdout and stderr to the log file.
|
||||||
|
dup2(fd, STDOUT_FILENO);
|
||||||
|
dup2(fd, STDERR_FILENO);
|
||||||
|
fprintf(stderr, "--- adb starting (pid %d) ---\n", getpid());
|
||||||
|
unix_close(fd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int adb_trace_mask;
|
||||||
|
|
||||||
|
std::string get_trace_setting_from_env() {
|
||||||
|
const char* setting = getenv("ADB_TRACE");
|
||||||
|
if (setting == nullptr) {
|
||||||
|
setting = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string(setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !ADB_HOST
|
||||||
|
std::string get_trace_setting_from_prop() {
|
||||||
|
char buf[PROPERTY_VALUE_MAX];
|
||||||
|
property_get("persist.adb.trace_mask", buf, "");
|
||||||
|
return std::string(buf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::string get_trace_setting() {
|
||||||
|
#if ADB_HOST
|
||||||
|
return get_trace_setting_from_env();
|
||||||
|
#else
|
||||||
|
return get_trace_setting_from_prop();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split the space separated list of tags from the trace setting and build the
|
||||||
|
// trace mask from it. note that '1' and 'all' are special cases to enable all
|
||||||
|
// tracing.
|
||||||
|
//
|
||||||
|
// adb's trace setting comes from the ADB_TRACE environment variable, whereas
|
||||||
|
// adbd's comes from the system property persist.adb.trace_mask.
|
||||||
|
static void setup_trace_mask() {
|
||||||
|
const std::string trace_setting = get_trace_setting();
|
||||||
|
if (trace_setting.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unordered_map<std::string, int> trace_flags = {
|
||||||
|
{"1", 0},
|
||||||
|
{"all", 0},
|
||||||
|
{"adb", ADB},
|
||||||
|
{"sockets", SOCKETS},
|
||||||
|
{"packets", PACKETS},
|
||||||
|
{"rwx", RWX},
|
||||||
|
{"usb", USB},
|
||||||
|
{"sync", SYNC},
|
||||||
|
{"sysdeps", SYSDEPS},
|
||||||
|
{"transport", TRANSPORT},
|
||||||
|
{"jdwp", JDWP},
|
||||||
|
{"services", SERVICES},
|
||||||
|
{"auth", AUTH},
|
||||||
|
{"fdevent", FDEVENT},
|
||||||
|
{"shell", SHELL}};
|
||||||
|
|
||||||
|
std::vector<std::string> elements = android::base::Split(trace_setting, " ");
|
||||||
|
for (const auto& elem : elements) {
|
||||||
|
const auto& flag = trace_flags.find(elem);
|
||||||
|
if (flag == trace_flags.end()) {
|
||||||
|
LOG(ERROR) << "Unknown trace flag: " << elem;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag->second == 0) {
|
||||||
|
// 0 is used for the special values "1" and "all" that enable all
|
||||||
|
// tracing.
|
||||||
|
adb_trace_mask = ~0;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
adb_trace_mask |= 1 << flag->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void adb_trace_init(char** argv) {
|
||||||
|
#if !ADB_HOST
|
||||||
|
// Don't open log file if no tracing, since this will block
|
||||||
|
// the crypto unmount of /data
|
||||||
|
if (!get_trace_setting().empty()) {
|
||||||
|
if (isatty(STDOUT_FILENO) == 0) {
|
||||||
|
start_device_log();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
android::base::InitLogging(argv, AdbLogger);
|
||||||
|
setup_trace_mask();
|
||||||
|
|
||||||
|
VLOG(ADB) << adb_version();
|
||||||
|
}
|
||||||
|
|
||||||
|
void adb_trace_enable(AdbTrace trace_tag) {
|
||||||
|
adb_trace_mask |= (1 << trace_tag);
|
||||||
|
}
|
||||||
|
|
@ -22,36 +22,40 @@
|
||||||
|
|
||||||
/* IMPORTANT: if you change the following list, don't
|
/* IMPORTANT: if you change the following list, don't
|
||||||
* forget to update the corresponding 'tags' table in
|
* forget to update the corresponding 'tags' table in
|
||||||
* the adb_trace_init() function implemented in adb.c
|
* the adb_trace_init() function implemented in adb_trace.cpp.
|
||||||
*/
|
*/
|
||||||
enum AdbTrace {
|
enum AdbTrace {
|
||||||
TRACE_ADB = 0, /* 0x001 */
|
ADB = 0, /* 0x001 */
|
||||||
TRACE_SOCKETS,
|
SOCKETS,
|
||||||
TRACE_PACKETS,
|
PACKETS,
|
||||||
TRACE_TRANSPORT,
|
TRANSPORT,
|
||||||
TRACE_RWX, /* 0x010 */
|
RWX, /* 0x010 */
|
||||||
TRACE_USB,
|
USB,
|
||||||
TRACE_SYNC,
|
SYNC,
|
||||||
TRACE_SYSDEPS,
|
SYSDEPS,
|
||||||
TRACE_JDWP, /* 0x100 */
|
JDWP, /* 0x100 */
|
||||||
TRACE_SERVICES,
|
SERVICES,
|
||||||
TRACE_AUTH,
|
AUTH,
|
||||||
TRACE_FDEVENT,
|
FDEVENT,
|
||||||
TRACE_SHELL
|
SHELL
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int adb_trace_mask;
|
#define VLOG_IS_ON(TAG) \
|
||||||
extern unsigned char adb_trace_output_count;
|
((adb_trace_mask & (1 << TAG)) != 0)
|
||||||
void adb_trace_init(char**);
|
|
||||||
|
|
||||||
#define ADB_TRACING ((adb_trace_mask & (1 << TRACE_TAG)) != 0)
|
#define VLOG(TAG) \
|
||||||
|
if (LIKELY(!VLOG_IS_ON(TAG))) \
|
||||||
|
; \
|
||||||
|
else \
|
||||||
|
LOG(INFO)
|
||||||
|
|
||||||
// You must define TRACE_TAG before using this macro.
|
// You must define TRACE_TAG before using this macro.
|
||||||
#define D(...) \
|
#define D(...) \
|
||||||
do { \
|
VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__)
|
||||||
if (ADB_TRACING) { \
|
|
||||||
LOG(INFO) << android::base::StringPrintf(__VA_ARGS__); \
|
|
||||||
} \
|
extern int adb_trace_mask;
|
||||||
} while (0)
|
void adb_trace_init(char**);
|
||||||
|
void adb_trace_enable(AdbTrace trace_tag);
|
||||||
|
|
||||||
#endif /* __ADB_TRACE_H */
|
#endif /* __ADB_TRACE_H */
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "adb_utils.h"
|
#include "adb_utils.h"
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ bool mkdirs(const std::string& path) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_hex(const void* data, size_t byte_count) {
|
std::string dump_hex(const void* data, size_t byte_count) {
|
||||||
byte_count = std::min(byte_count, size_t(16));
|
byte_count = std::min(byte_count, size_t(16));
|
||||||
|
|
||||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
|
const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
|
||||||
|
|
@ -170,7 +170,7 @@ void dump_hex(const void* data, size_t byte_count) {
|
||||||
line.push_back(c);
|
line.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
D("%s", line.c_str());
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse_host_and_port(const std::string& address,
|
bool parse_host_and_port(const std::string& address,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ bool mkdirs(const std::string& path);
|
||||||
|
|
||||||
std::string escape_arg(const std::string& s);
|
std::string escape_arg(const std::string& s);
|
||||||
|
|
||||||
void dump_hex(const void* ptr, size_t byte_count);
|
std::string dump_hex(const void* ptr, size_t byte_count);
|
||||||
|
|
||||||
// Parses 'address' into 'host' and 'port'.
|
// Parses 'address' into 'host' and 'port'.
|
||||||
// If no port is given, takes the default from *port.
|
// If no port is given, takes the default from *port.
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
@ -1554,6 +1554,8 @@ int adb_commandline(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "keygen")) {
|
else if (!strcmp(argv[0], "keygen")) {
|
||||||
if (argc < 2) return usage();
|
if (argc < 2) return usage();
|
||||||
|
// Always print key generation information for keygen command.
|
||||||
|
adb_trace_enable(AUTH);
|
||||||
return adb_auth_keygen(argv[1]);
|
return adb_auth_keygen(argv[1]);
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "jdwp")) {
|
else if (!strcmp(argv[0], "jdwp")) {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_FDEVENT
|
#define TRACE_TAG FDEVENT
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "fdevent.h"
|
#include "fdevent.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_SYNC
|
#define TRACE_TAG SYNC
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "file_sync_service.h"
|
#include "file_sync_service.h"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
/* implement the "debug-ports" and "track-debug-ports" device services */
|
/* implement the "debug-ports" and "track-debug-ports" device services */
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_JDWP
|
#define TRACE_TAG JDWP
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
@ -324,8 +324,9 @@ jdwp_process_event( int socket, unsigned events, void* _proc )
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseProcess:
|
CloseProcess:
|
||||||
if (proc->pid >= 0)
|
if (proc->pid >= 0) {
|
||||||
D( "remove pid %d to jdwp process list", proc->pid );
|
D( "remove pid %d to jdwp process list", proc->pid );
|
||||||
|
}
|
||||||
jdwp_process_free(proc);
|
jdwp_process_free(proc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_SERVICES
|
#define TRACE_TAG SERVICES
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_ADB
|
#define TRACE_TAG ADB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
// to be more complex due to partial reads and non-blocking I/O so this model
|
// to be more complex due to partial reads and non-blocking I/O so this model
|
||||||
// was chosen instead.
|
// was chosen instead.
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_SHELL
|
#define TRACE_TAG SHELL
|
||||||
|
|
||||||
#include "shell_service.h"
|
#include "shell_service.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_SOCKETS
|
#define TRACE_TAG SOCKETS
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_SYSDEPS
|
#define TRACE_TAG SYSDEPS
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_TRANSPORT
|
#define TRACE_TAG TRANSPORT
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
|
@ -42,7 +42,7 @@ static std::list<atransport*> pending_list;
|
||||||
|
|
||||||
ADB_MUTEX_DEFINE( transport_lock );
|
ADB_MUTEX_DEFINE( transport_lock );
|
||||||
|
|
||||||
static void dump_packet(const char* name, const char* func, apacket* p) {
|
static std::string dump_packet(const char* name, const char* func, apacket* p) {
|
||||||
unsigned command = p->msg.command;
|
unsigned command = p->msg.command;
|
||||||
int len = p->msg.data_length;
|
int len = p->msg.data_length;
|
||||||
char cmd[9];
|
char cmd[9];
|
||||||
|
|
@ -73,9 +73,10 @@ static void dump_packet(const char* name, const char* func, apacket* p) {
|
||||||
else
|
else
|
||||||
snprintf(arg1, sizeof arg1, "0x%x", p->msg.arg1);
|
snprintf(arg1, sizeof arg1, "0x%x", p->msg.arg1);
|
||||||
|
|
||||||
D("%s: %s: [%s] arg0=%s arg1=%s (len=%d) ",
|
std::string result = android::base::StringPrintf("%s: %s: [%s] arg0=%s arg1=%s (len=%d) ",
|
||||||
name, func, cmd, arg0, arg1, len);
|
name, func, cmd, arg0, arg1, len);
|
||||||
dump_hex(p->data, len);
|
result += dump_hex(p->data, len);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -99,9 +100,7 @@ read_packet(int fd, const char* name, apacket** ppacket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ADB_TRACING) {
|
VLOG(TRANSPORT) << dump_packet(name, "from remote", *ppacket);
|
||||||
dump_packet(name, "from remote", *ppacket);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,9 +112,7 @@ write_packet(int fd, const char* name, apacket** ppacket)
|
||||||
snprintf(buff, sizeof buff, "fd=%d", fd);
|
snprintf(buff, sizeof buff, "fd=%d", fd);
|
||||||
name = buff;
|
name = buff;
|
||||||
}
|
}
|
||||||
if (ADB_TRACING) {
|
VLOG(TRANSPORT) << dump_packet(name, "to remote", *ppacket);
|
||||||
dump_packet(name, "to remote", *ppacket);
|
|
||||||
}
|
|
||||||
char* p = reinterpret_cast<char*>(ppacket); /* we really write the packet address */
|
char* p = reinterpret_cast<char*>(ppacket); /* we really write the packet address */
|
||||||
int len = sizeof(apacket*);
|
int len = sizeof(apacket*);
|
||||||
while(len > 0) {
|
while(len > 0) {
|
||||||
|
|
@ -996,19 +993,16 @@ void unregister_usb_transport(usb_handle *usb) {
|
||||||
adb_mutex_unlock(&transport_lock);
|
adb_mutex_unlock(&transport_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef TRACE_TAG
|
|
||||||
#define TRACE_TAG TRACE_RWX
|
|
||||||
|
|
||||||
int check_header(apacket *p, atransport *t)
|
int check_header(apacket *p, atransport *t)
|
||||||
{
|
{
|
||||||
if(p->msg.magic != (p->msg.command ^ 0xffffffff)) {
|
if(p->msg.magic != (p->msg.command ^ 0xffffffff)) {
|
||||||
D("check_header(): invalid magic");
|
VLOG(RWX) << "check_header(): invalid magic";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p->msg.data_length > t->get_max_payload()) {
|
if(p->msg.data_length > t->get_max_payload()) {
|
||||||
D("check_header(): %u > atransport::max_payload = %zu",
|
VLOG(RWX) << "check_header(): " << p->msg.data_length << " atransport::max_payload = "
|
||||||
p->msg.data_length, t->get_max_payload());
|
<< t->get_max_payload();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_TRANSPORT
|
#define TRACE_TAG TRANSPORT
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_TRANSPORT
|
#define TRACE_TAG TRANSPORT
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_USB
|
#define TRACE_TAG USB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_USB
|
#define TRACE_TAG USB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
@ -491,12 +491,14 @@ static void usb_ffs_kick(usb_handle *h)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = ioctl(h->bulk_in, FUNCTIONFS_CLEAR_HALT);
|
err = ioctl(h->bulk_in, FUNCTIONFS_CLEAR_HALT);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
D("[ kick: source (fd=%d) clear halt failed (%d) ]", h->bulk_in, errno);
|
D("[ kick: source (fd=%d) clear halt failed (%d) ]", h->bulk_in, errno);
|
||||||
|
}
|
||||||
|
|
||||||
err = ioctl(h->bulk_out, FUNCTIONFS_CLEAR_HALT);
|
err = ioctl(h->bulk_out, FUNCTIONFS_CLEAR_HALT);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
D("[ kick: sink (fd=%d) clear halt failed (%d) ]", h->bulk_out, errno);
|
D("[ kick: sink (fd=%d) clear halt failed (%d) ]", h->bulk_out, errno);
|
||||||
|
}
|
||||||
|
|
||||||
adb_mutex_lock(&h->lock);
|
adb_mutex_lock(&h->lock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_USB
|
#define TRACE_TAG USB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TRACE_TAG TRACE_USB
|
#define TRACE_TAG USB
|
||||||
|
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue