了解 ctags 文件格式

K.M*_*ier 5 arm ctags exuberant-ctags cortex-m

我使用“Exhuberant ctags”来索引我的 c 项目中的所有标签。c-project 是 Cortex-M7 微控制器的嵌入式软件。结果是一个标签文件。我正在尝试阅读该文件并理解所写的内容。
根据我找到的 ctags 和 Exhuberant ctags 的文档,我可以掌握大多数行的含义。例如:

ADC3    .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   1525;"  d
Run Code Online (Sandbox Code Playgroud)

这行的意思是:

  • 已找到名称为 的标签ADC3
  • 该标签可在文件中找到.\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h
  • 该标签位于1525该文件中的行。
  • 标签是 type d- 这是一个“宏定义”。

到目前为止,一切都很好。但是标签文件中有很多行我无法理解。例如:

A0  .\Drivers\CMSIS\Include\arm_math.h  /^    q15_t A0;           \/**< The derived gain, A0 = Kp + Ki + Kd . *\/$/;"   m   struct:__anon68
Run Code Online (Sandbox Code Playgroud)

和这个:

ABFSR   .\Drivers\CMSIS\Include\core_cm7.h  /^  __IOM uint32_t ABFSR;                  \/*!< Offset: 0x2A8 (R\/W)  Auxiliary Bus Fault Status Register *\/$/;"  m   struct:__anon187
Run Code Online (Sandbox Code Playgroud)

和这个:

ABR .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^  __IO uint32_t ABR;      \/*!< QUADSPI Alternate Bytes register,                   Address offset: 0x1C *\/$/;"  m   struct:__anon39
Run Code Online (Sandbox Code Playgroud)

和这个:

ADC_Common_TypeDef  .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^} ADC_Common_TypeDef;$/;" t   typeref:struct:__anon3
Run Code Online (Sandbox Code Playgroud)

和这个:

ADC_IRQn    .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^  ADC_IRQn                    = 18,     \/*!< ADC1, ADC2 and ADC3 global Interrupts                             *\/$/;"   e   enum:__anon1
Run Code Online (Sandbox Code Playgroud)

和这个:

C   .\Drivers\CMSIS\Include\core_cm7.h  /^    uint32_t C:1;                        \/*!< bit:     29  Carry condition code flag *\/$/;" m   struct:__anon182::__anon183
Run Code Online (Sandbox Code Playgroud)

我可以继续...

你能帮我理解它们吗?也许可以找出一两个例子,同时给出一些如何解释这些行的一般规则?这真的很有帮助。

编辑:有关“universal ctags”的最新.exe文件,请参阅此问题:Universal ctags on Windows

Aus*_*ser 2

一般来说,手动查看 CTags 文件不会很有成效(尽管我知道您可能只是想了解发生了什么)。话虽如此,这是我对您发布的各种条目的解释。

我怀疑您将看到的大部分内容都属于这些大类之一,但是当有疑问时,直接查看代码将真正帮助您弄清楚发生了什么。

结构成员

数据结构

A0  .\Drivers\CMSIS\Include\arm_math.h  /^    q15_t A0;           \/**< The derived gain, A0 = Kp + Ki + Kd . *\/$/;"   m   struct:__anon68
Run Code Online (Sandbox Code Playgroud)

A0是 struct ( m struct:__anon68) 的成员,用于向数学加速函数传递数据或从数学加速函数传递数据。

硬件寄存器

ST 以特定方式声明其硬件寄存器。我将在此处使用来自 的示例core_m7.h,该示例声明所有 Cortex-M7 CPU 通用的寄存器块,无论供应商如何:

typedef struct
{
  __IO uint32_t ISER[8];                 /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register           */
       uint32_t RESERVED0[24];
  __IO uint32_t ICER[8];                 /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register         */
       uint32_t RSERVED1[24];
  __IO uint32_t ISPR[8];                 /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register          */
       uint32_t RESERVED2[24];
  __IO uint32_t ICPR[8];                 /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register        */
       uint32_t RESERVED3[24];
  __IO uint32_t IABR[8];                 /*!< Offset: 0x200 (R/W)  Interrupt Active bit Register           */
       uint32_t RESERVED4[56];
  __IO uint8_t  IP[240];                 /*!< Offset: 0x300 (R/W)  Interrupt Priority Register (8Bit wide) */
       uint32_t RESERVED5[644];
  __O  uint32_t STIR;                    /*!< Offset: 0xE00 ( /W)  Software Trigger Interrupt Register     */
}  NVIC_Type;

/* ... */

#define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address  */
#define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address                  */

/* ... */

#define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct          */
Run Code Online (Sandbox Code Playgroud)

该结构确定各种配置和控制寄存器在内存中的位置,在本例中为NVIC(嵌套向量中断控制器)块,该块管理系统的异常处理。

就 CTags 而言,这与A0上面相同。(非常重要的)区别在于结构体​​的实例化方式——对于硬件块,结构体声明映射到必须进行特殊处理的特定内存地址。

您的许多 ctags 行将引用这些类型的声明,包括:

ABFSR   .\Drivers\CMSIS\Include\core_cm7.h  /^  __IOM uint32_t ABFSR;                  \/*!< Offset: 0x2A8 (R\/W)  Auxiliary Bus Fault Status Register *\/$/;"  m   struct:__anon187

ABR .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^  __IO uint32_t ABR;      \/*!< QUADSPI Alternate Bytes register,                   Address offset: 0x1C *\/$/;"  m   struct:__anon39
Run Code Online (Sandbox Code Playgroud)

这两个都是结构成员。在您的代码中,您可能会看到类似的内容SCB->ABFSR = ...

C   .\Drivers\CMSIS\Include\core_cm7.h  /^    uint32_t C:1;                        \/*!< bit:     29  Carry condition code flag *\/$/;" m   struct:__anon182::__anon183
Run Code Online (Sandbox Code Playgroud)

值得特殊对待,因为它是位域声明。它更复杂,因为它是联合 ( )内的m struct:__anon182::__anon183结构成员,但实际上它是同一类东西。根据您要查看的内容,这些匿名嵌套可能会变得相当深 - 跟踪这些内容是 CTag 和类似工具真正开始证明其价值的地方。

类型定义

ADC_Common_TypeDef  .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^} ADC_Common_TypeDef;$/;" t   typeref:struct:__anon3
Run Code Online (Sandbox Code Playgroud)

这就是 CTags 跟踪所有这些匿名结构的方式。它说“与”ADC_Common_TypeDef是一样的struct:__anon3

常量(枚举)

ADC_IRQn    .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^  ADC_IRQn                    = 18,     \/*!< ADC1, ADC2 and ADC3 global Interrupts                             *\/$/;"   e   enum:__anon1
Run Code Online (Sandbox Code Playgroud)

这是一个常量(ADC 中断的中断向量号)。它被声明为匿名枚举 ( e enum:__anon1) 的一部分。