Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 The Chromium Authors. All rights reserved. | 2 * Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #ifndef TOOLS_ANDROID_MEMTRACK_HELPER_H_ | 7 #ifndef TOOLS_ANDROID_MEMTRACK_HELPER_H_ |
| 8 #define TOOLS_ANDROID_MEMTRACK_HELPER_H_ | 8 #define TOOLS_ANDROID_MEMTRACK_HELPER_H_ |
| 9 | 9 |
| 10 #include <android/log.h> | 10 #include <android/log.h> |
| 11 #include <errno.h> | 11 #include <errno.h> |
| 12 #include <stdio.h> | 12 #include <stdio.h> |
| 13 #include <stdlib.h> | 13 #include <stdlib.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 #include <sys/socket.h> | 15 #include <sys/socket.h> |
| 16 #include <sys/un.h> | 16 #include <sys/un.h> |
| 17 #include <unistd.h> | |
| 17 | 18 |
| 18 static inline void exit_with_failure(const char* reason) { | 19 static inline void exit_with_failure(const char* reason) { |
| 19 perror(reason); | 20 perror(reason); |
| 20 __android_log_write(ANDROID_LOG_ERROR, "memtrack_helper", reason); | 21 __android_log_write(ANDROID_LOG_ERROR, "memtrack_helper", reason); |
| 21 exit(EXIT_FAILURE); | 22 exit(EXIT_FAILURE); |
| 22 } | 23 } |
| 23 | 24 |
| 24 static inline void init_memtrack_server_addr(struct sockaddr_un* addr) { | 25 static inline void init_memtrack_server_addr(struct sockaddr_un* addr) { |
| 25 const char* const kAbstractSocketName = "chrome_tracing_memtrack_helper"; | 26 const char* const kAbstractSocketName = "chrome_tracing_memtrack_helper"; |
| 26 memset(addr, 0, sizeof(*addr)); | 27 memset(addr, 0, sizeof(*addr)); |
| 27 addr->sun_family = AF_UNIX; | 28 addr->sun_family = AF_UNIX; |
| 28 strncpy(&addr->sun_path[1], kAbstractSocketName, sizeof(addr->sun_path) - 2); | 29 strncpy(&addr->sun_path[1], kAbstractSocketName, sizeof(addr->sun_path) - 2); |
| 29 } | 30 } |
| 30 | 31 |
| 32 static inline void log_pid() { | |
|
Primiano Tucci (use gerrit)
2016/12/14 15:51:16
This is used only in one place, only in the .cc fi
kraynov
2016/12/15 15:43:48
Done.
| |
| 33 long pid = getpid(); | |
| 34 fprintf(stderr, "pid=%ld\n", pid); | |
| 35 __android_log_print(ANDROID_LOG_INFO, "memtrack_helper", "pid=%ld\n", pid); | |
| 36 } | |
| 37 | |
| 31 #endif // TOOLS_ANDROID_MEMTRACK_HELPER_H_ | 38 #endif // TOOLS_ANDROID_MEMTRACK_HELPER_H_ |
| OLD | NEW |