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

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

问题描述

我使用了丰富的标签"来索引我的c项目中的所有标签.该c项目是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

我可以继续前进...

And I can geep going...

您能帮助我理解它们吗?也许给出一个或两个示例,同时给出一些有关如何解释这些界限的一般规则?那真的很有帮助.

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.

有关通用ctags"的最新.exe文件,请参阅以下问题: Windows上的通用标签

推荐答案

通常,手动查看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

这两个都是struct成员.在您的代码中,您可能会看到类似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

由于它是位字段声明,因此应给予特殊待遇.由于它是内部的结构成员 联合(m struct:__anon182::__anon183),因此更为复杂,但实际上是同一回事.根据您的查找,这些匿名嵌套会变得很深-跟踪这些东西是CTags和类似工具真正开始证明其价值的地方.

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天全站免登陆