android logcat里打印kernel信息
2013-11-29 22:44
591 查看
没试过,摘录下来 有空研究下:
1.在Android的源码中(目标路径为:system/core/logcat/logcat.cpp),将其此logcat.cpp文件中的static void readLogLines(int logfd)函数作出如下修改:
2 在如上修改的.cpp文件的头文件中加入如下两个头文件:
#include < sys/klog.h>
#define KERNEL_TAG "Kernel"
可能要修改init.rc 里的 服务,需要root权限
有空研究一下
1.在Android的源码中(目标路径为:system/core/logcat/logcat.cpp),将其此logcat.cpp文件中的static void readLogLines(int logfd)函数作出如下修改:
2 在如上修改的.cpp文件的头文件中加入如下两个头文件:
#include < sys/klog.h>
#define KERNEL_TAG "Kernel"
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: Unexpected EOF! "); exit(EXIT_FAILURE); } /* NOTE: driver guarantees we read exactly one full entry */ entry->msg[entry->len] = ''; 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] = ''; if (g_printBinary) { printBinary(entry); } else { (void) processBuffer(entry); } } } } }
可能要修改init.rc 里的 服务,需要root权限
有空研究一下
相关文章推荐
- 解决Android Logcat不打印信息
- android logcat不打印信息
- android手机调试时不能打印Logcat日志信息
- android 调试logcat不打印错误信息
- android logcat 打印完整信息
- Android底层库打印调试信息到logcat中查看
- android studio logcat 打印不出信息
- android手机调试时不能打印Logcat日志信息
- Qt打印调试信息输出到android logcat中
- android手机调试时不能打印Logcat日志信息
- Android ffmpeg调试信息打印在logcat里
- 解决android logcat不打印信息
- Android调试 LogCat中的消息一闪而过,根本看不到打印的信息.
- 解决android logcat不打印信息
- android jni 打印信息到logcat
- Android下使用Logcat打印信息
- Android之——JNI配置C语言打印Logcat信息
- 解决:Android手机在AndroidStudio或Eclipse等开发工具调试时Logcat不打印日志信息
- 解决android logcat不打印信息
- android logcat不打印信息