【问题标题】:can't figure out what's wrong with ctag regex for assembly macro extraction无法弄清楚用于汇编宏提取的 ctag 正则表达式有什么问题
【发布时间】:2021-12-17 02:21:15
【问题描述】:

这是汇编代码的一部分(u-boot、arch/arm/include/debug/8250.S)

.macro  addruart, rp, rv, tmp
ldr \rp, =CONFIG_DEBUG_UART_PHYS
ldr \rv, =CONFIG_DEBUG_UART_VIRT
.endm

我想为这种类型的宏定义提取标签。所以我提到了How to write .ctags file for assembly extention?
但不知何故,我的试验不起作用。
我尝试了以下所有这些命令,但都未能显示标签 (addruart)。
假设这个 8250.S 文件在 /tmp 下并且只包含那 4 行。实际上每行都有两个缩进标签。在.macroadduart 之间也是一个标签。

ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro[\t ]+\(([a-zA-Z_0-9]+)\)/\1/m,macro/'  -o - /tmp/8250.S
ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro[\t ][\t ]*\([a-zA-Z_0-9]+\)/\1/m,macro/'  -o - /tmp/8250.S
ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro[\t ][\t ]*\([a-zA-Z_0-9][a-zA-Z_0-9]*\)/\1/m,macro/'  -o - /tmp/8250.S
ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro[\t ]\([a-zA-Z_0-9][a-zA-Z_0-9]*\)/\1/m,macro/'  -o - /tmp/8250.S
ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro\t\([a-zA-Z_0-9][a-zA-Z_0-9]*\)/\1/m,macro/'  -o - /tmp/8250.S
ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro\([a-zA-Z_0-9][a-zA-Z_0-9]*\)/\1/m,macro/'  -o - /tmp/8250.S
ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro\([a-zA-Z_0-9][a-zA-Z_0-9]*\)/\1/m,macro/'  -o - /tmp/8250.S
ckim@ckim-ubuntu:~/U-BOOT/u-boot$ 

我该怎么做?
我的 ctags 版本:

Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
  Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
  Optional compiled features: +wildcards, +regex

【问题讨论】:

    标签: ctags exuberant-ctags


    【解决方案1】:
    ckim@ckim-ubuntu:~/U-BOOT/u-boot$ ctags --regex-Asm='/\.macro[\t ]+\(([a-zA-Z_0-9]+)\)/\1/m,macro/'  -o - /tmp/8250.S
    

    这应该是:

    --regex-Asm='/\.macro[\t ]+([a-zA-Z_0-9]+)/\1/m,macro/'
    

    如果您不想调整正则表达式模式,可以将 ctags 替换为其他实现。

    Universal Ctags (https://ctags.io) 是 Exuberant Ctags 的非官方分支。 最新的 u-ctags 识别使用 gas 语法定义的宏定义。 您不必添加正则表达式选项来提取它们。

    $ cat /tmp/foo.S
    cat /tmp/foo.S
    .macro  addruart, rp, rv, tmp
    ldr \rp, =CONFIG_DEBUG_UART_PHYS
    ldr \rv, =CONFIG_DEBUG_UART_VIRT
    .endm
    $ ./ctags --options=NONE -o - /tmp/foo.S
    ./ctags --options=NONE -o - /tmp/foo.S
    ctags: Notice: No options will be read from files or environment
    addruart    /tmp/foo.S  /^.macro  addruart, rp, rv, tmp$/;" m
    ldr /tmp/foo.S  /^ldr \\rp, =CONFIG_DEBUG_UART_PHYS$/;" l
    ldr /tmp/foo.S  /^ldr \\rv, =CONFIG_DEBUG_UART_VIRT$/;" l
    

    ldr 被意外提取。我不知道如何解决这个问题。

    【讨论】:

    猜你喜欢
    • 2013-02-14
    • 2021-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-16
    • 2018-05-16
    • 2013-11-21
    相关资源
    最近更新 更多