Merge "Add more debug information."
This commit is contained in:
commit
173310a27c
8 changed files with 36 additions and 14 deletions
|
|
@ -338,6 +338,9 @@ void put_apacket(apacket *p);
|
||||||
int check_header(apacket *p);
|
int check_header(apacket *p);
|
||||||
int check_data(apacket *p);
|
int check_data(apacket *p);
|
||||||
|
|
||||||
|
// Define it if you want to dump packets.
|
||||||
|
#define DEBUG_PACKETS 0
|
||||||
|
|
||||||
#if !DEBUG_PACKETS
|
#if !DEBUG_PACKETS
|
||||||
#define print_packet(tag,p) do {} while (0)
|
#define print_packet(tag,p) do {} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ int adb_connect(const char *service)
|
||||||
|
|
||||||
fd = _adb_connect(service);
|
fd = _adb_connect(service);
|
||||||
if(fd == -1) {
|
if(fd == -1) {
|
||||||
D("_adb_connect error: %s\n", __adb_error);
|
D("_adb_connect error: %s", __adb_error);
|
||||||
} else if(fd == -2) {
|
} else if(fd == -2) {
|
||||||
fprintf(stderr,"** daemon still not running\n");
|
fprintf(stderr,"** daemon still not running\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,9 @@ void adb_trace_init(void);
|
||||||
if (ADB_TRACING) { \
|
if (ADB_TRACING) { \
|
||||||
int save_errno = errno; \
|
int save_errno = errno; \
|
||||||
adb_mutex_lock(&D_lock); \
|
adb_mutex_lock(&D_lock); \
|
||||||
fprintf(stderr, "%s::%s():", \
|
fprintf(stderr, "%16s: %5d:%5lu | ", \
|
||||||
__FILE__, __FUNCTION__); \
|
__FUNCTION__, \
|
||||||
|
getpid(), adb_thread_id()); \
|
||||||
errno = save_errno; \
|
errno = save_errno; \
|
||||||
fprintf(stderr, __VA_ARGS__ ); \
|
fprintf(stderr, __VA_ARGS__ ); \
|
||||||
fflush(stderr); \
|
fflush(stderr); \
|
||||||
|
|
@ -96,15 +97,16 @@ void adb_trace_init(void);
|
||||||
} while (0)
|
} while (0)
|
||||||
# define DD(...) \
|
# define DD(...) \
|
||||||
do { \
|
do { \
|
||||||
int save_errno = errno; \
|
int save_errno = errno; \
|
||||||
adb_mutex_lock(&D_lock); \
|
adb_mutex_lock(&D_lock); \
|
||||||
fprintf(stderr, "%s::%s():", \
|
fprintf(stderr, "%16s: %5d:%5lu | ", \
|
||||||
__FILE__, __FUNCTION__); \
|
__FUNCTION__, \
|
||||||
errno = save_errno; \
|
getpid(), adb_thread_id()); \
|
||||||
fprintf(stderr, __VA_ARGS__ ); \
|
errno = save_errno; \
|
||||||
fflush(stderr); \
|
fprintf(stderr, __VA_ARGS__ ); \
|
||||||
adb_mutex_unlock(&D_lock); \
|
fflush(stderr); \
|
||||||
errno = save_errno; \
|
adb_mutex_unlock(&D_lock); \
|
||||||
|
errno = save_errno; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
# define D(...) \
|
# define D(...) \
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,8 @@ void fdevent_subproc_setup()
|
||||||
if(adb_socketpair(s)) {
|
if(adb_socketpair(s)) {
|
||||||
FATAL("cannot create shell-exit socket-pair\n");
|
FATAL("cannot create shell-exit socket-pair\n");
|
||||||
}
|
}
|
||||||
|
D("socketpair: (%d,%d)", s[0], s[1]);
|
||||||
|
|
||||||
SHELL_EXIT_NOTIFY_FD = s[0];
|
SHELL_EXIT_NOTIFY_FD = s[0];
|
||||||
fdevent *fde;
|
fdevent *fde;
|
||||||
fde = fdevent_create(s[1], fdevent_subproc_event_func, NULL);
|
fde = fdevent_create(s[1], fdevent_subproc_event_func, NULL);
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,7 @@ FoundIt:
|
||||||
__FUNCTION__, strerror(errno));
|
__FUNCTION__, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
D("socketpair: (%d,%d)", fds[0], fds[1]);
|
||||||
|
|
||||||
proc->out_fds[ proc->out_count ] = fds[1];
|
proc->out_fds[ proc->out_count ] = fds[1];
|
||||||
if (++proc->out_count == 1)
|
if (++proc->out_count == 1)
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
|
||||||
printf("cannot create service socket pair\n");
|
printf("cannot create service socket pair\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
D("socketpair: (%d,%d)", s[0], s[1]);
|
||||||
|
|
||||||
sti = malloc(sizeof(stinfo));
|
sti = malloc(sizeof(stinfo));
|
||||||
if(sti == 0) fatal("cannot allocate stinfo");
|
if(sti == 0) fatal("cannot allocate stinfo");
|
||||||
|
|
@ -264,10 +265,11 @@ static int create_subproc_raw(const char *cmd, const char *arg0, const char *arg
|
||||||
|
|
||||||
// 0 is parent socket, 1 is child socket
|
// 0 is parent socket, 1 is child socket
|
||||||
int sv[2];
|
int sv[2];
|
||||||
if (unix_socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0) {
|
if (adb_socketpair(sv) < 0) {
|
||||||
printf("[ cannot create socket pair - %s ]\n", strerror(errno));
|
printf("[ cannot create socket pair - %s ]\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
D("socketpair: (%d,%d)", sv[0], sv[1]);
|
||||||
|
|
||||||
*pid = fork();
|
*pid = fork();
|
||||||
if (*pid < 0) {
|
if (*pid < 0) {
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,11 @@ static __inline__ int adb_thread_create( adb_thread_t *thread, adb_thread_func
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline__ unsigned long adb_thread_id()
|
||||||
|
{
|
||||||
|
return GetCurrentThreadId();
|
||||||
|
}
|
||||||
|
|
||||||
static __inline__ void close_on_exec(int fd)
|
static __inline__ void close_on_exec(int fd)
|
||||||
{
|
{
|
||||||
/* nothing really */
|
/* nothing really */
|
||||||
|
|
@ -516,6 +521,12 @@ static __inline__ char* adb_strtok_r(char *str, const char *delim, char **savep
|
||||||
{
|
{
|
||||||
return strtok_r(str, delim, saveptr);
|
return strtok_r(str, delim, saveptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline__ unsigned long adb_thread_id()
|
||||||
|
{
|
||||||
|
return pthread_self();
|
||||||
|
}
|
||||||
|
|
||||||
#undef strtok_r
|
#undef strtok_r
|
||||||
#define strtok_r ___xxx_strtok_r
|
#define strtok_r ___xxx_strtok_r
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -629,7 +629,7 @@ static void transport_registration_func(int _fd, unsigned ev, void *data)
|
||||||
fatal_errno("cannot open transport socketpair");
|
fatal_errno("cannot open transport socketpair");
|
||||||
}
|
}
|
||||||
|
|
||||||
D("transport: %s (%d,%d) starting\n", t->serial, s[0], s[1]);
|
D("transport: %s socketpair: (%d,%d) starting", t->serial, s[0], s[1]);
|
||||||
|
|
||||||
t->transport_socket = s[0];
|
t->transport_socket = s[0];
|
||||||
t->fd = s[1];
|
t->fd = s[1];
|
||||||
|
|
@ -673,6 +673,7 @@ void init_transport_registration(void)
|
||||||
if(adb_socketpair(s)){
|
if(adb_socketpair(s)){
|
||||||
fatal_errno("cannot open transport registration socketpair");
|
fatal_errno("cannot open transport registration socketpair");
|
||||||
}
|
}
|
||||||
|
D("socketpair: (%d,%d)", s[0], s[1]);
|
||||||
|
|
||||||
transport_registration_send = s[0];
|
transport_registration_send = s[0];
|
||||||
transport_registration_recv = s[1];
|
transport_registration_recv = s[1];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue