VectorCAST未打桩日志解析

VectorCAST未打桩日志解析

VectorCAST未打桩日志解析

使用vectorCAST时unstubbed_entities.log如下

*** This is not an error log ***
The existence of entities in this log does not signify that an error has 
occurred.  The purpose of this log is to provide a reason to you when a 
symbol has not been stubbed by VectorCAST.  When a link error occurs, the 
'Reason Not Stubbed' column provides an explanation.  In certain cases you 
may be required to provide a definition for certain entities in user code.  
Please consult the User's Guide for more information.Directory: F:/STM32WS/V004-20260716/XXX/SOFTWARE/PROJECT_XXX/DRIVERS/CMSIS/INCLUDE
Symbol Name              Type      Reason Not Stubbed
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
__builtin_arm_get_fpscr  function  Cannot stub this function without a prototype. Declare the function with a valid prototype (either in the real code or Unit Appendix User Code) so a proper stub can be generated. Specifying "__builtin_arm_get_fpscr" as an Additional Stub can force a stub definition, but the stub's prototype might not match the real function. You can also enable the option "Stub functions without prototypes" to automatically stub all such functions, but that risks errors due to stubbing of functions that are also provided by libraries.
__builtin_arm_set_fpscr  function  Cannot stub this function without a prototype. Declare the function with a valid prototype (either in the real code or Unit Appendix User Code) so a proper stub can be generated. Specifying "__builtin_arm_set_fpscr" as an Additional Stub can force a stub definition, but the stub's prototype might not match the real function. You can also enable the option "Stub functions without prototypes" to automatically stub all such functions, but that risks errors due to stubbing of functions that are also provided by libraries.
__copy_table_end__       constant  The type const __copy_table_t is inaccessible.
__copy_table_start__     constant  The type const __copy_table_t is inaccessible.
__zero_table_end__       constant  The type const __zero_table_t is inaccessible.
__zero_table_start__     constant  The type const __zero_table_t is inaccessible.

这个日志是 VectorCAST 的信息性报告,并非错误日志。它旨在解释哪些函数或符号未被替换为桩(Stub)以及具体原因,以帮助你在后续可能出现的链接错误中进行诊断。

针对你日志中的每一项,具体分析如下:

1. __builtin_arm_get_fpscr__builtin_arm_set_fpscr (函数)

  • 原因缺少函数原型。VectorCAST 需要函数的原型(声明)才能生成正确的桩函数。这些是编译器内置(Built-in)函数,通常没有显式的原型声明。
  • 解决方案
    1. 推荐方案:在项目的用户代码或 VectorCAST 的 Unit Appendix User Code 中,为这两个函数添加有效的原型声明。例如:
      unsigned int __builtin_arm_get_fpscr(void);
      void __builtin_arm_set_fpscr(unsigned int);
      
      这样 VectorCAST 就能识别并生成正确的桩。
    2. 备选方案:在 VectorCAST 环境的配置中,将这两个函数名添加到 “Additional Stubs” 列表。这会强制生成桩,但原型可能不匹配,存在风险。
    3. 风险方案:在 VectorCAST 编译选项中启用 “Stub functions without prototypes”。这会为所有此类函数自动生成桩,但风险较高,可能会错误地对某些库函数进行打桩。

2. __copy_table_end__, __copy_table_start__, __zero_table_end__, __zero_table_start__ (常量)

  • 原因类型 const __copy_table_t 不可访问。VectorCAST 在分析这些符号时,无法找到其类型 __copy_table_t 的完整定义。这通常是因为包含了这些声明的头文件路径未被正确识别或处理。
  • 解决方案
    1. 检查并添加包含路径:确认定义了 __copy_table_t 类型的头文件所在目录,并将其添加到 VectorCAST 项目的 Include Paths 中。
    2. 分类包含路径:如果这些常量定义在你不希望被桩化的库代码中,可以将该包含路径的类型设置为 “Library Include Path”。这会让 VectorCAST 知道此处的符号不应被打桩,从而可能解决此问题。
    3. 诊断路径问题:如果问题依旧,可以检查 VectorCAST 的 Jobs 窗口,查看具体的编译命令和错误详情,以定位路径配置问题。

总结与后续行动

符号 核心问题 建议操作
__builtin_arm_* 缺少函数原型 在项目代码或VectorCAST用户代码中显式声明原型。
__copy_table_*/__zero_table_* 类型定义不可访问 确保包含相关类型定义的头文件路径被正确添加到VectorCAST项目中,并可考虑设为“Library Include Path”。

这篇日志本身不是错误,它只是指出了潜在的问题点。但如果这些未打桩的符号在链接时找不到定义,就会导致最终的链接错误,那时就需要根据这里的提示来解决。

补充信息:MCU型号是STM32U5F7

使用的是STM32U5F7,很好地解释了unstubbed_entities.log中问题的根本原因——这些符号是ARM Cortex-M内核(特别是带有FPU的M33或M55内核)相关的编译器内置(built-in)函数或链接脚本符号,与具体的STM32型号关系不大。

这意味着解决方案不受MCU型号影响,以下是针对两个核心问题的具体解决方案:

1. 对于 __builtin_arm_get/set_fpscr:添加函数原型声明

这是ARM架构下用于读写浮点状态和控制寄存器(FPSCR)的内置函数。VectorCAST需要它们有明确的函数原型才能生成测试桩。你可以在VectorCAST环境的 Unit Appendix User Code 中添加以下声明即可解决:

unsigned int __builtin_arm_get_fpscr(void);
void __builtin_arm_set_fpscr(unsigned int);

2. 对于 __copy/zero_table_start/end:配置库头文件路径

这些通常是链接脚本中用于标记内存段(如ROM、RAM)复制或清零区域的符号,其类型__copy_table_t__zero_table_t定义在芯片厂商(这里是ST)提供的库头文件中。

根本原因是VectorCAST在解析时找不到这些类型的完整定义,原因是包含它们的头文件路径没有被正确识别。你只需要检查并修改项目配置:

  1. 确认并添加路径:确保包含__copy_table_t__zero_table_t等类型定义的头文件(可能在CMSIS或STM32CubeU5的驱动库中)所在目录,已经添加到了VectorCAST项目的Include Paths中。
  2. 设置为“库包含路径”:将这些路径的类型标记为 “Library Include Path”。这会让VectorCAST知道这些是外部库的符号,不应该被桩化(因为它们由链接器提供),同时也能解决类型不可见的问题。