字节对齐检查就是在需要考虑字节对齐时,检查源码中结构体类型变量的字节对齐情况。
检查源码中结构体变量的字节对齐情况。
1 | devkit advisor addr-align [-h | --help] {-i INPUT_PATH | --input INPUT_PATH} {-c COMMAND | --cmd COMMAND} [-o OUTPUT_PATH | --output OUTPUT_PATH] [-r {all,json,html,csv} | --report-type {all,json,html,csv}] [-l {0,1,2,3} | --log-level {0,1,2,3}] [--set-timeout TIMEOUT] |
参数 |
参数选项 |
参数说明 |
---|---|---|
-h/--help |
- |
获取帮助信息。 |
-i/--input |
input_path |
必选参数,待扫描的源码文件夹路径。 |
-c/--cmd |
command |
必选参数,源码构建命令。在服务器中正常执行的构建命令,若存在多个构建命令需使用英文分号分隔并用英文双引号包住。命令中如有空格,也需要用英文双引号包住。 例如:"mkdir build;cd build;cmake ..;make"。 说明:
命令行工具源码构建命令不支持设置变量和export环境变量。 例如:"CFLAGS='-O0 -g';make"或"export CFLAGS='-O0 -g';make"。 |
-o/--output |
output_path |
扫描报告的存放路径,默认存放在当前执行路径下,报告名称为模块名称_时间戳。 |
--set-timeout |
time |
任务超时时间,单位为分钟,若执行时间超过超时时间则退出执行。默认无超时时间,任务将持续执行直到结束。 |
-l/--log-level |
0/1/2/3 |
设置日志级别,默认为1。
|
-r/--report-type |
all/json/html/csv |
扫描报告的格式,默认为all。
|
此处以扫描“/opt/DevKit/wtdbg2-2.5”文件夹下源码,构建命令为make,扫描报告存放至“/opt/DevKit”路径且日志级别为DEBUG为例,请根据实际情况进行修改。
1 | devkit advisor addr-align -i /opt/DevKit/wtdbg2-2.5 -c make -o /opt/DevKit -l 0 |
若在源码路径下进行字节对齐检查,分析完成后,执行ls时目录为空,这时需要返回到上一层目录,再重新进入到源码路径下执行ls命令,可以查看到相关文件。
返回信息如下,并输出报告。
debug: Enter the second level command: advisor Executing byte alignment check task, please wait... Current progress: # [5%] Start to obtain the compile database Current progress: ###### [20%] Start to obtain the preview compilation result Current progress: ################ [50%] Start to obtain the byte alignment result Current progress: ################################# [100%] Scanned time: 2025/04/07 01:36:04 Configuration: Scan source code path: /opt/DevKit/wtdbg2-2.5 Generate report path: /opt/DevKit Generate report type: all Task Timeout Interval: The timeout period is not set. Log level: debug For the detailed information(This is the full scan result. Please make sure that the project can be successfully compiled with "make"), please check: /opt/DevKit/addr-align_20250407013604_dca9.json /opt/DevKit/addr-align_20250407013604_dca9.html /opt/DevKit/addr-align_20250407013604_dca9.csv
参数 |
说明 |
---|---|
配置信息 |
显示软件源码文件存放路径。 |
需要修改的源码文件 |
显示需要进行字节对齐的源码文件路径等相关信息。 |