blob: 23f2c1a279c12d77d53285a9ed2a44c11e195c98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
http://en.cppreference.com/w/cpp/language/auto
http://www.learncpp.com/cpp-tutorial/4-8-the-auto-keyword/
Native debug:
https://source.android.com/devices/tech/debug/#native
source build/envsetup.sh
lunch hikey-userdebug
adb shell gdbserver :5039 /system/bin/my_test_app
gdbclient <pid|processname>
when <optimized out> is printed with p var in gdb shell,
it means we need to set the binary compilation to compile with -O0
==========print debug information in bionic functions====:
// write to console
int klog_fd = open("/dev/kmsg", O_WRONLY | O_CLOEXEC);
if (klog_fd < 0 ){
static const char* name = "/dev/__kmsg__";
if (mknod(name, S_IFCHR | 0600, (1 << 8) | 11) == 0) {
klog_fd = open(name, O_WRONLY | O_CLOEXEC);
unlink(name);
}
}
//int klog_fd = open("/data/local/tmp/", O_WRONLY | O_CLOEXEC);
char buf[240];
size_t msg_size = snprintf(buf, sizeof(buf), "=====LIUYQ writev=====%s:%d\n", __FILE__, __LINE__);
iovec iov[1];
iov[0].iov_base = buf;
iov[0].iov_len = msg_size;
writev(klog_fd, iov, 1);
close(klog_fd);
fflush(NULL);
==========print in CPP file==============
std::cout << "====LIUYQ===" << __FILE__ <<" :" << __LINE__ << " :" << __func__ << std::endl;
strerror(errno))
=========================================
|