让adb logcat打印内核调试信息
2011-10-10 17:41
776 查看
在默认情况下,adb logcat只能显示使用程序的调试信息,我把logcat.cpp修改了一下,让它同时可以打印内核调试信息:
system/core/logcat/logcat.cpp
static void readLogLines(int logfd)
{ char buffer[256] = {0};
while (1)
{
unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1] __attribute__((aligned(4)));
struct logger_entry *entry = (struct logger_entry *) buf;
int ret;
ret = read(logfd, entry, LOGGER_ENTRY_MAX_LEN);
if (ret < 0) { if (errno == EINTR) continue; if (errno == EAGAIN) break; perror("logcat read"); exit(EXIT_FAILURE); } else if (!ret)
{ fprintf(stderr, "read: Unexp ected EOF!\n"); exit(EXIT_FAILURE); } /* NOTE: driver guarantees we read exactly one full entry */ entry->msg[entry->len] = '\0'; if (g_printBinary) { printBinary(entry);
} else { (void) processBuffer(entry); } /*读入内核调试信息*/
if((ret = klogctl(9, buffer, sizeof(buffer))) > 0) { if((ret = klogctl(2, buffer, sizeof(buffer))) > 0) { entry->tid = 0; entry->pid = getpid(); /*priority*/
entry->msg[0] = ANDROID_LOG_INFO; /*tag*/ strcpy(entry->msg+1, KERNEL_TAG); /*message*/ strncpy(entry->msg+1+sizeof(KERNEL_TAG), buffer, ret); entry->len = 1 + sizeof(KERNEL_TAG) +
ret + 1; entry->msg[entry->len] = '\0'; if (g_printBinary) { printBinary(entry); } else { (void) processBuffer(entry); } } } }}
这里没有把内核调试信息的级别转换成Androind的LOG级别,全部运用了ANDROID_LOG_INFO级别,进程ID用了当前的进程ID。对我们来说已经够用了,有须要的朋友可以继续完备。
system/core/logcat/logcat.cpp
static void readLogLines(int logfd)
{ char buffer[256] = {0};
while (1)
{
unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1] __attribute__((aligned(4)));
struct logger_entry *entry = (struct logger_entry *) buf;
int ret;
ret = read(logfd, entry, LOGGER_ENTRY_MAX_LEN);
if (ret < 0) { if (errno == EINTR) continue; if (errno == EAGAIN) break; perror("logcat read"); exit(EXIT_FAILURE); } else if (!ret)
{ fprintf(stderr, "read: Unexp ected EOF!\n"); exit(EXIT_FAILURE); } /* NOTE: driver guarantees we read exactly one full entry */ entry->msg[entry->len] = '\0'; if (g_printBinary) { printBinary(entry);
} else { (void) processBuffer(entry); } /*读入内核调试信息*/
if((ret = klogctl(9, buffer, sizeof(buffer))) > 0) { if((ret = klogctl(2, buffer, sizeof(buffer))) > 0) { entry->tid = 0; entry->pid = getpid(); /*priority*/
entry->msg[0] = ANDROID_LOG_INFO; /*tag*/ strcpy(entry->msg+1, KERNEL_TAG); /*message*/ strncpy(entry->msg+1+sizeof(KERNEL_TAG), buffer, ret); entry->len = 1 + sizeof(KERNEL_TAG) +
ret + 1; entry->msg[entry->len] = '\0'; if (g_printBinary) { printBinary(entry); } else { (void) processBuffer(entry); } } } }}
这里没有把内核调试信息的级别转换成Androind的LOG级别,全部运用了ANDROID_LOG_INFO级别,进程ID用了当前的进程ID。对我们来说已经够用了,有须要的朋友可以继续完备。
相关文章推荐
- 让adb logcat打印内核调试信息
- 让adb logcat打印内核调试信息
- adb logcat打印内核调试信息
- 让adb logcat打印内核调试信息
- Android 让adb logcat打印内核调试信息
- Android 让adb logcat打印内核调试信息
- android adb logcat打印内核调试信息
- Android 让adb logcat打印内核调试信息
- adb打印内核调试信息dmsg和kmsg说明
- Android 用adb 打印linux内核调试信息dmesg和kmsg命令
- Android 用adb 打印linux内核调试信息dmesg和kmsg命令
- JNI开发之c代码中LOG打印调试信息
- 实时打印 android 模拟器的内核log信息
- Android Studio真机调试时不打印Log信息的解决方法
- 图形界面终端下打印内核调试信息
- adb查看内核LOG信息
- linux adb 控制内核打印log
- android 调试内核驱动 打印log缓存大小调整
- adb无线调试,显示:由于目标计算机积极拒绝, 无法连接. (10061)-另-调试无LOG信息,文中有提到。
- adb 打印指定进程的log信息