# easycall **Repository Path**: yuri-yang/easycall ## Basic Information - **Project Name**: easycall - **Description**: 动态库测试小程序 - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 0 - **Created**: 2022-09-11 - **Last Updated**: 2025-02-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # easycall ## 概述 你是否会有这样的需求,当你需要将一个程序写成一个动态库的时候你对于动态库的测试必须是同步进行的,这意味着你动态库向外提供所有符号,都必须通过另外一个测试程序进行测试调用,这似乎非常不方便。那有没有更加体面的方法呢。 如果动态库并不复杂的时候,这还是可以忍受的但是当动态库的调用逻辑变得多样,要为每一种调用方法写一个测试用例并不是一件容易的事情。在这样的启发下,我准备完成这样一个程序,其底层逻辑并不复杂,其实就是利用dl库的动态运行特性,从而可以使得我们可以自由的调用动态库中的每一个接口。 ## 编译方式 ### 正常编译 make ### 交叉编译 以arm平台为例 按照下面的方式进行编译 make HOST=arm-linux CROSS_COMPILE=arm-linux-gnueabi- ## 安装到/usr/bin make install ### 清理编译内容 make clean ## 使用方式 正常情况下有三种运行模式 ### 单次执行 例: -l 链接动态库 -e 执行函数 > ./output/ecall -l /lib/x86_64-linux-gnu/libc.so.6 -e "printf \"HELLO\"" -f 执行文件 > ./output/ecall -l /lib/x86_64-linux-gnu/libc.so.6 -f cmd.txt cmd.txt中存放函数列表 比如这样 sleep 1 printf "HELLO" 这样程序就会一行一行按顺序执行 ### 命令行模式 > ./output/ecall -l [] 然后可以通过help查看帮助,在这种模式下具有符号导出自动补全功能 下面介绍常见几种内置命令用法 #### 显示帮助信息 { "h", com_help, "Display this help"}, { "help", com_help, "Display this help"}, { "?", com_help, "Display this help"}, #### 程序退出 { "q", com_quit, "Quit using Ecall"}, { "quit", com_quit, "Quit using Ecall"}, #### 进入调试模式 可以显示库信息以及函数运行时间 { "debug", com_debug, "Set debug mode"}, #### 历史命令 { "history", com_history, "List editline history"}, #### 显示所有库 { "list", com_list_lib, "List dynamic lib"}, #### 加载动态库 { "l", com_load_lib, "Load dynamic lib"}, { "load", com_load_lib, "Load dynamic lib"}, #### 显示所有符号信息 { "s", com_symbol, "Show dynamic lib's symbols"}, { "symbol", com_symbol, "Show dynamic lib's symbols"}, #### 运行shell命令 可以运行shell sh进入命令行 { "sh", com_shell, "Run shell cmd"}, { "shell", com_shell, "Run shell cmd"}, #### 更改全局变量 { "md.b", com_get_value_byte, "Get value as byte"}, { "md.w", com_get_value_word, "Get value as word"}, { "md.l", com_get_value_long, "Get value as long"}, { "nm.b", com_set_value_byte, "Get value as byte"}, { "nm.w", com_set_value_word, "Get value as word"}, { "nm.l", com_set_value_long, "Get value as long"}, #### 显示调试信息 { "stack", com_stack, "show stack"}, { "status", com_status, "show status"}, { "maps", com_maps, "show maps"}, ### 后台运行模式 > ./output/ecall -d -l [] > pcall -e [] -l [] ecall转在后台运行,通过pcall 发送执行命令 ### 编译错误 安装错误需要恢复仓库初始化,直接操作可能造成持续残留的未知影响。 > rm -r ./3rd > sudo rm -r ./output > git reset --hard HEAD #### 1. 提示autoreconf: not found > ./autogen.sh: 3: autoreconf: not found 安装autoconf工具即可,ubuntu使用以下命令: > sudo apt install autoconf #### 2. 提示LIBTOOL未定义 > src/Makefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined > src/Makefile.am:1: The usual way to define 'LIBTOOL' is to add 'LT_INIT' > src/Makefile.am:1: to 'configure.ac' and run 'aclocal' and 'autoconf' again. > src/Makefile.am:1: If 'LT_INIT' is in 'configure.ac', make sure > src/Makefile.am:1: its definition is in aclocal's search path. 安装autoconf工具即可,ubuntu使用以下命令: > sudo apt install libtool-bin