了解 ctags 文件格式 [英] Understanding the ctags file format

查看:48
本文介绍了了解 ctags 文件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I used "Exhuberant ctags" to index all the tags from my c-project. The c-project is embedded software for a Cortex-M7 microcontroller. The result is a tags-file. I'm trying to read this file and understand what is written down.
Based on the documentation I find for ctags and Exhuberant ctags, I can grasp the meanings of most lines. For example:

ADC3    .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   1525;"  d

这一行的意思是:

  • 找到了一个名为 ADC3 的标签.
  • 标签位于文件 .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h 中.
  • 标签位于该文件中的 1525 行.
  • 标签类型为 d - 这是一个宏定义".
  • A tag has been found with name ADC3.
  • The tag is found in file .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h.
  • The tag is at line 1525 in that file.
  • The tag is type d - which is a "macro definition".

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

So far, so good. But there are lots of lines in the tags-file that I cannot wrap my head around. For example:

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

还有这个:

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

还有这个:

ADC_Common_TypeDef  .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^} ADC_Common_TypeDef;$/;" t   typeref:struct:__anon3

还有这个:

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

还有这个:

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

而且我可以继续...

你能帮我理解它们吗?也许找出一两个例子,同时给出一些关于如何解释这些线条的一般规则?那真的很有帮助.

Can you help me to understand them? Perhaps working out one or two examples, while giving some general rules on how to interpret these lines? That would be really helpful.

关于universal ctags"的最新.exe文件,参考这个问题:Windows 上的通用 ctags

推荐答案

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

In general, looking at CTags files manually isn't going to be very productive (though I understand you probably just want to understand what's going on). With that said, here's my explanation of what the various entries you've posted are.

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

I suspect most of what you'll see will fall into one of these broad categories, but when in doubt looking directly in the code will really help you figure out what's going on.

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

A0 是结构体 (m struct:__anon68) 的成员,该结构体用于将数据传入/传出数学加速函数.

A0 is a member of a struct (m struct:__anon68) which is used to pass data to/from mathematics acceleration functions.

ST 以特定方式声明其硬件寄存器.我将在这里使用 core_m7.h 中的一个示例,它声明所有 Cortex-M7 CPU 通用的寄存器块,而不管供应商如何:

ST declares their hardware registers in a particular way. I'll use an example here from core_m7.h, which declares register blocks common to all Cortex-M7 CPUs irrespective of vendor:

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          */

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

The struct determines the location in memory of various configuration and control registers, in this case for the NVIC (Nested Vectored Interrupt Controller) block, which manages the system's exception handling.

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

As far as CTags is concerned, this is identical to A0 above. The (very significant) difference lies in how the structs are instantiated -- for hardware blocks, the struct declarations mapped to specific memory addresses that have to be treated specially.

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

Many of your ctags lines will refer to these kinds of declaration, including:

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

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

Both of these are struct members. In your code, you'll likely see something like SCB->ABFSR = ....

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

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

Deserves special treatment, since it's a bitfield declaration. It's more complicated since it's a struct member inside a union (m struct:__anon182::__anon183), but effectively it's the same sort of thing. Depending on what you're looking, these anonymous nestings can get pretty deep -- keeping track of this stuff is where CTags and similar tools really start to prove their worth.

ADC_Common_TypeDef  .\Drivers\CMSIS\Device\ST\STM32F7xx\Include\stm32f767xx.h   /^} ADC_Common_TypeDef;$/;" t   typeref:struct:__anon3

这就是 CTags 跟踪所有这些匿名结构的方式.它说ADC_Common_TypeDefstruct:__anon3 是一回事"

This is how CTags keeps track of all those anonymous structs. It says "ADC_Common_TypeDef is the same thing as struct:__anon3"

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

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

This is a constant (the interrupt vector number for the ADC interrupt). It's declared as part of an anonymous enum (e enum:__anon1).

这篇关于了解 ctags 文件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆