如何获取Binder事务缓冲区的内容以进行故障排除 [英] How to get contents of Binder transaction buffer for troubleshooting

查看:38
本文介绍了如何获取Binder事务缓冲区的内容以进行故障排除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式或通过调试工具来了解Binder交易缓冲区中当前持有的交易?

Is there a way, either programmatically or through a debugging tool, to know the current transactions held in the Binder transaction buffer?

有时候,通常是在运行了数小时/天之后,我的应用崩溃了,并显示了错误跟踪,如下所示:

Sometimes, usually after hours/days of run, my app crashes with an error trace like this:

08-30 09:49:57.459  1879  1904 E JavaBinder: !!! FAILED BINDER TRANSACTION !!!
08-30 09:49:57.469  1879  1904 W BroadcastQueue: Exception when sending broadcast to ComponentInfo{com.mycompany.myapp/com.mycompany.myapp.receiver.UpdateContentReceiver}
08-30 09:49:57.469  1879  1904 W BroadcastQueue: android.os.TransactionTooLargeException
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at android.os.BinderProxy.transact(Native Method)
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at android.app.ApplicationThreadProxy.scheduleReceiver(ApplicationThreadNative.java:771)
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at com.android.server.am.BroadcastQueue.processCurBroadcastLocked(BroadcastQueue.java:231)
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at com.android.server.am.BroadcastQueue.processNextBroadcast(BroadcastQueue.java:778)
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at com.android.server.am.BroadcastQueue$1.handleMessage(BroadcastQueue.java:140)
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at android.os.Handler.dispatchMessage(Handler.java:99)
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at android.os.Looper.loop(Looper.java:137)
08-30 09:49:57.469  1879  1904 W BroadcastQueue:    at com.android.server.am.ActivityManagerService$AThread.run(ActivityManagerService.java:1487)

我尝试发送的广播没有额外内容,因此其大小可以忽略不计.根据 TransactionTooLargeException

The broadcast I was trying to send has no extras, so it has negligible size. As per documentation of TransactionTooLargeException:

Binder事务缓冲区具有有限的固定大小,当前为1Mb,该进程中的所有正在进行的事务共享该大小.因此,即使有很多交易正在进行,即使有许多交易正在进行,也会引发该异常.

The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size.

我的假设是缓冲区被其他东西(我的应用程序,我正在使用的一个库或系统)填充了,当缓冲区快满时,它会抛出 TransactionTooLargeException .通过检查缓冲区的内容,我可以轻松地发现问题.

My hypotesis is that the buffer is filled up by something else (my app, one of the libraries I'm using or the system) and when it's almost full, it throws TransactionTooLargeException. By inspecting the contents of the buffer, I could easily spot the problem.

推荐答案

http://www.slideshare.net/jserv/android-ipc-mechanism ,有关Binder事务缓冲区的详细信息可以通过debugfs找到.用

As found in slide 67 of http://www.slideshare.net/jserv/android-ipc-mechanism, detailed information about the Binder transaction buffer can be found through debugfs. After mounting it with

mount -t debugfs none /sys/kernel/debug

可以在/sys/kernel/debug/binder/中访问Binder信息,在那里可以获取全局信息以及每个进程的信息.

the Binder info can be reached in /sys/kernel/debug/binder/, where one can get global as well as per-process information.

这篇关于如何获取Binder事务缓冲区的内容以进行故障排除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆