首页 > 其他分享 >Binder系列-1-Binder debug-2-宏值

Binder系列-1-Binder debug-2-宏值

时间:2024-01-15 17:25:54浏览次数:29  
标签:BC BINDER Binder 宏值 BR debug binder TYPE 0x%

一、用户空间宏

1. 用户空间code相关宏

class IBinder : public virtual RefBase //binder/IBinder.h
{
public:
        enum {
                /* binder服务函数code从1开始 */
                FIRST_CALL_TRANSACTION = 0x00000001,
                LAST_CALL_TRANSACTION = 0x00ffffff,

                /* binder系统的code */
                PING_TRANSACTION = 0x5f504e47
                DUMP_TRANSACTION = 0x5f444d50
                SHELL_COMMAND_TRANSACTION = 0x5f434d44
                INTERFACE_TRANSACTION = 0x5f4e5446
                INTERFACE_TRANSACTION2 = 0x5f4e5447
                SYSPROPS_TRANSACTION = 0x5f535052
                EXTENSION_TRANSACTION = 0x5f455854
                DEBUG_PID_TRANSACTION = 0x5f504944
                TWEET_TRANSACTION = 0x5f545754
                LIKE_TRANSACTION = 0x5f4c494b
        };
        ...
}

 

二、内核空间宏

1. 直接宏定义的

enum {
    BINDER_TYPE_BINDER    = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), //0x73622a85=sb*+85
    BINDER_TYPE_WEAK_BINDER    = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE), //0x77622a85
    BINDER_TYPE_HANDLE    = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE), //0x73682a85
    BINDER_TYPE_WEAK_HANDLE    = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE), //0x77682a85
    BINDER_TYPE_FD        = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE), //0x66642a85
    BINDER_TYPE_FDA        = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE), //0x66646185
    BINDER_TYPE_PTR        = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE), //0x70742a85
};

#define BINDER_WRITE_READ        _IOWR('b', 1, struct binder_write_read) //0xc0306201
#define BINDER_SET_IDLE_TIMEOUT        _IOW('b', 3, __s64) //0x40086203
#define BINDER_SET_MAX_THREADS        _IOW('b', 5, __u32) //0x40046205
#define BINDER_SET_IDLE_PRIORITY    _IOW('b', 6, __s32) //0x40046206
#define BINDER_SET_CONTEXT_MGR        _IOW('b', 7, __s32) //0x40046207
#define BINDER_THREAD_EXIT        _IOW('b', 8, __s32)     //0x40046208
#define BINDER_VERSION            _IOWR('b', 9, struct binder_version) //0xc0046209
#define BINDER_GET_NODE_DEBUG_INFO    _IOWR('b', 11, struct binder_node_debug_info) //0xc018620b
#define BINDER_GET_NODE_INFO_FOR_REF    _IOWR('b', 12, struct binder_node_info_for_ref) //0xc018620c
#define BINDER_SET_CONTEXT_MGR_EXT    _IOW('b', 13, struct flat_binder_object) //0x4018620d
#define BINDER_FREEZE            _IOW('b', 14, struct binder_freeze_info) //0x400c620e
#define BINDER_GET_FROZEN_INFO        _IOWR('b', 15, struct binder_frozen_status_info) //0xc00c620f
#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION    _IOW('b', 16, __u32) //0x40046210

 

2. binder_driver_return_protocol

enum binder_driver_return_protocol {
    BR_ERROR = _IOR('r', 0, __s32), //0x80047200
    BR_OK = _IO('r', 1), //0x7201
    BR_TRANSACTION_SEC_CTX = _IOR('r', 2, struct binder_transaction_data_secctx), //0x80487202
    BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), //0x80407202
    BR_REPLY = _IOR('r', 3, struct binder_transaction_data), //0x80407203
    BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), //0x80047204
    BR_DEAD_REPLY = _IO('r', 5), //0x7205
    BR_TRANSACTION_COMPLETE = _IO('r', 6), //0x7206
    BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), //0x80107207
    BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), //0x80107208
    BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), //0x80107209
    BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), //0x8010720a
    BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), //0x8018720b
    BR_NOOP = _IO('r', 12), //0x720c
    BR_SPAWN_LOOPER = _IO('r', 13), //0x720d
    BR_FINISHED = _IO('r', 14), //0x720e
    BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t), //0x8008720f
    BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), //0x80087210
    BR_FAILED_REPLY = _IO('r', 17), //0x7211
    BR_FROZEN_REPLY = _IO('r', 18), //0x7212
    BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19), //0x7213
};

 

3 binder_driver_command_protocol

enum binder_driver_command_protocol {
    BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), //0x40406300
    BC_REPLY = _IOW('c', 1, struct binder_transaction_data), //0x40406301
    BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), //0x40046302
    BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t), //0x40086303
    BC_INCREFS = _IOW('c', 4, __u32), //0x40046304
    BC_ACQUIRE = _IOW('c', 5, __u32), //0x40046305
    BC_RELEASE = _IOW('c', 6, __u32), //0x40046306
    BC_DECREFS = _IOW('c', 7, __u32), //0x40046307
    BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), //0x40106308
    BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), //0x40106309
    BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), //0x4008630a
    BC_REGISTER_LOOPER = _IO('c', 11), //0x630b
    BC_ENTER_LOOPER = _IO('c', 12), //0x630c
    BC_EXIT_LOOPER = _IO('c', 13), //0x630d
    BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie), //0x400c630e
    BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie), //0x400c630f
    BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), //0x40086310
    BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg), //0x40486311
    BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg), //0x40486312
};

 

三、打印函数

1. 用户空间打印函数

#include <stdio.h>

#define B_PACK_CHARS(c1, c2, c3, c4) ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))

enum {
        FIRST_CALL_TRANSACTION = 0x00000001,
        LAST_CALL_TRANSACTION = 0x00ffffff,

        PING_TRANSACTION = B_PACK_CHARS('_', 'P', 'N', 'G'),
        DUMP_TRANSACTION = B_PACK_CHARS('_', 'D', 'M', 'P'),
        SHELL_COMMAND_TRANSACTION = B_PACK_CHARS('_', 'C', 'M', 'D'),
        INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'),
        INTERFACE_TRANSACTION2 = B_PACK_CHARS('_', 'N', 'T', 'F') + 1,
        SYSPROPS_TRANSACTION = B_PACK_CHARS('_', 'S', 'P', 'R'),
        EXTENSION_TRANSACTION = B_PACK_CHARS('_', 'E', 'X', 'T'),
        DEBUG_PID_TRANSACTION = B_PACK_CHARS('_', 'P', 'I', 'D'),
        TWEET_TRANSACTION = B_PACK_CHARS('_', 'T', 'W', 'T'),
        LIKE_TRANSACTION = B_PACK_CHARS('_', 'L', 'I', 'K'),
};


void main()
{
    printf("PING_TRANSACTION = 0x%x\n \
            DUMP_TRANSACTION = 0x%x\n \
            SHELL_COMMAND_TRANSACTION = 0x%x\n \
            INTERFACE_TRANSACTION = 0x%x\n \
            INTERFACE_TRANSACTION2 = 0x%x\n \
            SYSPROPS_TRANSACTION = 0x%x\n \
            EXTENSION_TRANSACTION = 0x%x\n \
            DEBUG_PID_TRANSACTION = 0x%x\n \
            TWEET_TRANSACTION = 0x%x\n \
            LIKE_TRANSACTION = 0x%x\n",
            PING_TRANSACTION,
            DUMP_TRANSACTION,
            SHELL_COMMAND_TRANSACTION,
            INTERFACE_TRANSACTION,
            INTERFACE_TRANSACTION2,
            SYSPROPS_TRANSACTION,
            EXTENSION_TRANSACTION,
            DEBUG_PID_TRANSACTION,
            TWEET_TRANSACTION,
            LIKE_TRANSACTION
    );
}

 

2. 内核空间打印函数

static void dump_binder_cmd_val(void)
{
    printk("BINDER_TYPE_BINDER=0x%x, BINDER_TYPE_WEAK_BINDER=0x%x, BINDER_TYPE_HANDLE=0x%x, BINDER_TYPE_WEAK_HANDLE=0x%x, \
        BINDER_TYPE_FD=0x%x, BINDER_TYPE_FDA=0x%x, BINDER_TYPE_PTR=0x%x\n",
        BINDER_TYPE_BINDER, BINDER_TYPE_WEAK_BINDER, BINDER_TYPE_HANDLE, BINDER_TYPE_WEAK_HANDLE, BINDER_TYPE_FD, BINDER_TYPE_FDA,
        BINDER_TYPE_PTR);

    printk("BINDER_WRITE_READ=0x%x, BINDER_SET_IDLE_TIMEOUT=0x%x, BINDER_SET_MAX_THREADS=0x%x, BINDER_SET_IDLE_PRIORITY=0x%x, \
        BINDER_SET_CONTEXT_MGR=0x%x, BINDER_THREAD_EXIT=0x%x, BINDER_VERSION=0x%x, BINDER_GET_NODE_DEBUG_INFO=0x%x,
        BINDER_GET_NODE_INFO_FOR_REF=0x%x, BINDER_SET_CONTEXT_MGR_EXT=0x%x, BINDER_FREEZE=0x%x, BINDER_GET_FROZEN_INFO=0x%x, \
        BINDER_ENABLE_ONEWAY_SPAM_DETECTION=0x%x\n",
        BINDER_WRITE_READ, BINDER_SET_IDLE_TIMEOUT, BINDER_SET_MAX_THREADS, BINDER_SET_IDLE_PRIORITY,
        BINDER_SET_CONTEXT_MGR, BINDER_THREAD_EXIT, BINDER_VERSION, BINDER_GET_NODE_DEBUG_INFO,
        BINDER_GET_NODE_INFO_FOR_REF, BINDER_SET_CONTEXT_MGR_EXT, BINDER_FREEZE, BINDER_GET_FROZEN_INFO, \
        BINDER_ENABLE_ONEWAY_SPAM_DETECTION);

    printk("BR_ERROR=0x%x, BR_OK=0x%x, BR_TRANSACTION_SEC_CTX=0x%x, BR_TRANSACTION=0x%x, \
        BR_REPLY=0x%x, BR_ACQUIRE_RESULT=0x%x, BR_DEAD_REPLY=0x%x, BR_TRANSACTION_COMPLETE=0x%x, \
        BR_INCREFS=0x%x, BR_ACQUIRE=0x%x, BR_RELEASE=0x%x, BR_DECREFS=0x%x, \
        BR_ATTEMPT_ACQUIRE=0x%x, BR_NOOP=0x%x, BR_SPAWN_LOOPER=0x%x, BR_FINISHED=0x%x, \
        BR_DEAD_BINDER=0x%x, BR_CLEAR_DEATH_NOTIFICATION_DONE=0x%x, BR_FAILED_REPLY=0x%x, BR_FROZEN_REPLY=0x%x, \
        BR_ONEWAY_SPAM_SUSPECT=0x%x\n",
        BR_ERROR, BR_OK, BR_TRANSACTION_SEC_CTX, BR_TRANSACTION,
        BR_REPLY, BR_ACQUIRE_RESULT, BR_DEAD_REPLY, BR_TRANSACTION_COMPLETE,
        BR_INCREFS, BR_ACQUIRE, BR_RELEASE, BR_DECREFS,
        BR_ATTEMPT_ACQUIRE, BR_NOOP, BR_SPAWN_LOOPER, BR_FINISHED,
        BR_DEAD_BINDER, BR_CLEAR_DEATH_NOTIFICATION_DONE, BR_FAILED_REPLY, BR_FROZEN_REPLY,
        BR_ONEWAY_SPAM_SUSPECT);

    printk("BC_TRANSACTION=0x%x, BC_REPLY=0x%x, BC_ACQUIRE_RESULT=0x%x, BC_FREE_BUFFER=0x%x, \
        BC_INCREFS=0x%x, BC_ACQUIRE=0x%x, BC_RELEASE=0x%x, BC_DECREFS=0x%x, \
        BC_INCREFS_DONE=0x%x, BC_ACQUIRE_DONE=0x%x, BC_ATTEMPT_ACQUIRE=0x%x, BC_REGISTER_LOOPER=0x%x, \
        BC_ENTER_LOOPER=0x%x, BC_EXIT_LOOPER=0x%x, BC_REQUEST_DEATH_NOTIFICATION=0x%x, BC_CLEAR_DEATH_NOTIFICATION=0x%x, \
        BC_DEAD_BINDER_DONE=0x%x, BC_TRANSACTION_SG=0x%x, BC_REPLY_SG=0x%x\n",
        BC_TRANSACTION, BC_REPLY, BC_ACQUIRE_RESULT, BC_FREE_BUFFER,
        BC_INCREFS, BC_ACQUIRE, BC_RELEASE, BC_DECREFS,
        BC_INCREFS_DONE, BC_ACQUIRE_DONE, BC_ATTEMPT_ACQUIRE, BC_REGISTER_LOOPER,
        BC_ENTER_LOOPER, BC_EXIT_LOOPER, BC_REQUEST_DEATH_NOTIFICATION, BC_CLEAR_DEATH_NOTIFICATION,
        BC_DEAD_BINDER_DONE, BC_TRANSACTION_SG, BC_REPLY_SG);
}

 

标签:BC,BINDER,Binder,宏值,BR,debug,binder,TYPE,0x%
From: https://www.cnblogs.com/hellokitty2/p/17965846

相关文章

  • Binder系列-5-binder_mmap—1—mmap()分析
    一、manmmap1.函数声明#include<sys/mman.h>void*mmap(void*addr,size_tlength,intprot,intflags,intfd,off_toffset);intmunmap(void*addr,size_tlength);intmsync(void*addr,size_tlength,intflags)作用:将文件或设备向内存中进行映射或取消映......
  • 无涯教程-Redis - DEBUG SEGFAULT 命令函数
    RedisDEBUGSEGFAULT执行的无效内存访问使Redis崩溃,它用于在开发过程中模拟错误。DEBUGSEGFAULT-语法以下是RedisDEBUGSEGFAULT命令的基本语法。redis127.0.0.1:6379>DEBUGSEGFAULTDEBUGSEGFAULT-示例redis127.0.0.1:6379>DEBUGSEGFAULTCouldnotcon......
  • win下php7.2安装xdebug和php-redis
    先通过phpinfo()查看自己的php信息确定版本为:7.2-nts-vc15-x861、安装xdebughttps://xdebug.org/download.php下载对应的版本dll文件将dll文件复制到php文件夹的ext文件夹内修改php.ini,添加zend_extension=php_xdebug-2.7.0beta1-7.2-vc15-nts.dll重启apache,再次查看phpinfo()2、安......
  • IntelliJ IDEA Debug模式下结束后继续执行代码问题
    1.默认的配置默认的Debug模式下点击Stop后会继续执行代码。2.设置不继续执行后续代码Preferences->Build,Execution,Deployment->Debugger找到Java那一栏下边可以看到Killthedebugprocessimmediately选项,勾选后点击确定就可以了。或是直接在设置搜索框里输入Kil......
  • 【Android】深入Binder拦截
    ☞Github☜☞Gitee☜说明Binder作为Android系统跨进程通信的核心机制。网上也有很多深度讲解该机制的文章,如:Android跨进程通信详解Binder机制原理Android系统核心机制Binder【系列】这些文章和系统源码可以很好帮助我们理解Binder的实现原理和设计理念,为拦截做准备......
  • IDEA Debug 调试技巧(基础版)
    前言Debug是程序员的开发神器,使用好了可以帮助我们非常高效的工作、学习、排查问题等。毫不客气的说,是决定我们进阶到更高层级的一个重要技能。正文Debug的常见使用场景需求代码测试:通过debug你才能知道你的代码究竟是怎么运行的,更容易发现问题问题排查:只要能进入到问题流......
  • 解决mac arm 中 goland 无法 debug 问题
    新电脑不知道装了什么,导致无法debug现象可以run,没有问题不能debug,报错信息如下单元测试报错^Cgotooltest2json:signal:interruptmain方法debug报错^Ccouldnotlaunchprocess:stubexitedwhilewaitingforconnection:signal:interrupt解决之路网上找遍......
  • 将Debug目录下的所有文件打包到exe
    关闭杀毒软件, 最终结果    设置图标 ......
  • 如何使用xdebug调试php程序
    1由于我的是phpstudy集成环境,直接找到php.ini的位置:D:\phpstudy_pro\Extensions\php\php7.3.9nts\php.ini在文件尾部直接添加[Xdebug]zend_extension=D:/phpstudy_pro/Extensions/php/php7.0.9nts/ext/php_xdebug.dllxdebug.idekey=phpstormxdebug.remote_enable=Onxde......
  • debug跳转至 var4.getTargetException()
    今天敲了一个插入表的业务逻辑,发现控制台没有报错,但方法却没有执行完毕,debug后发现程序跳转到了该异常。经过上网搜索后有所了解,出现该异常的根本原因是当使用反射调用方法时,如果被调用的方法抛出了异常,而调用的方法却没有捕捉处理,那么该异常会被封装在一个`InvocationTargetEx......