1# binder事件上下文如何关联 2binder事件相对复杂,这里是从ftrace事件中抽离出来的binder相关消息,用来作为开发者或用户追踪binder事件的参考。 3a binder event is identified by the sender and receive device, and a reply message only end 4the last binder msg which reply the calling one. 5the alloc_buf msg can always flow the binder_transaction, so we no need to identify the alloc msg with transactionID. 6 7## TAG TT need reply!!! needReply = !isReply && !(flags & 0x01) 8``` 9RenderThread-2267 ( 1592) [003] ...1 168766.128108: binder_transaction: transaction=25155526 dest_node=25155471 dest_proc=506 dest_thread=0 reply=0 flags=0x10 code=0x9 10RenderThread-2267 ( 1592) [003] ...1 168766.128110: binder_transaction_alloc_buf: transaction=25155526 data_size=120 offsets_size=8 11``` 12### received 13``` 14Binder:506_2-537 ( 506) [003] ...1 168766.128154: binder_transaction_received: transaction=25155526 15``` 16### binder is in DB, TAG A needReply 17``` 18Binder:506_2-537 ( 506) [003] ...1 168766.128221: binder_transaction: transaction=25155529 dest_node=25155527 dest_proc=1592 dest_thread=2267 reply=0 flags=0x10 code=0x5f474854 19Binder:506_2-537 ( 506) [003] ...1 168766.128223: binder_transaction_alloc_buf: transaction=25155529 data_size=72 offsets_size=0 20``` 21### the flowing is for TAG A, this is the reply for TAG A 22``` 23RenderThread-2267 ( 1592) [003] ...1 168766.128262: binder_transaction: transaction=25155530 dest_node=0 dest_proc=506 dest_thread=537 reply=1 flags=0x8 code=0x0 24 25RenderThread-2267 ( 1592) [003] ...1 168766.128264: binder_transaction_alloc_buf: transaction=25155530 data_size=4 offsets_size=0 26``` 27### calc the dur of TAG A 28``` 29Binder:506_2-537 ( 506) [003] ...1 168766.128288: binder_transaction_received: transaction=25155530 30``` 31### binder last TAG A needReply, this is TAG B needReply!!! 32``` 33Binder:506_2-537 ( 506) [003] ...1 168766.128328: binder_transaction: transaction=25155532 dest_node=25155527 dest_proc=1592 dest_thread=2267 reply=0 flags=0x10 code=0x2 34Binder:506_2-537 ( 506) [003] ...1 168766.128330: binder_transaction_alloc_buf: transaction=25155532 data_size=72 offsets_size=0 35``` 36## in db 37``` 38RenderThread-2267 ( 1592) [003] ...1 168766.128347: binder_transaction_received: transaction=25155532 39``` 40## the reply message is not in db Session D, this is the reply for TAG B 41``` 42RenderThread-2267 ( 1592) [003] ...1 168766.128361: binder_transaction: transaction=25155533 dest_node=0 dest_proc=506 dest_thread=537 reply=1 flags=0x0 code=0x0 43RenderThread-2267 ( 1592) [003] ...1 168766.128363: binder_transaction_alloc_buf: transaction=25155533 data_size=4 offsets_size=0 44``` 45### no this message in db, calcate the dur of TAG B 46``` 47Binder:506_2-537 ( 506) [003] ...1 168766.128385: binder_transaction_received: transaction=25155533 48``` 49### no this message in db Session E, this is the reply for TAG TT 50``` 51Binder:506_2-537 ( 506) [003] ...1 168766.128412: binder_transaction: transaction=25155534 dest_node=0 dest_proc=1592 dest_thread=2267 reply=1 flags=0x0 code=0x0 52 53Binder:506_2-537 ( 506) [003] ...1 168766.128413: binder_transaction_alloc_buf: transaction=25155534 data_size=68 offsets_size=0 54``` 55## the dur of TAG TT is calcated by the flowing msg 56``` 57RenderThread-2267 ( 1592) [003] ...1 168766.128430: binder_transaction_received: transaction=25155534 58```