ctagsexuberant-ctags

can't figure out what's wrong with ctag regex for assembly macro extraction


This is part of an assembly code (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

I wanted to extrac tags for this type of macro defintion. So I referred to How to write .ctags file for assembly extention?
But somehow my trial doesn't work.
I tried all these commands below but all failed to show the tag (addruart).
Suppose this 8250.S file is under /tmp and contains only those 4 lines. And actually there are two tabs for indentation of each line. and between .macro and adduart is a tab too.

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$ 

How should I do it?
my ctags version :

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

Solution

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

    This should be:

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

    If you don't want to tune the regex patterns, you can replace your ctags with another implementation.

    Universal Ctags (https://ctags.io) is an unofficial fork of Exuberant Ctags. The latest u-ctags recognizes macro definitions defined with gas's syntax. You don't have to add regex options for extracting them.

    $ 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 is extracted unexpectedly. I have no idea how to fix this.