'ctags'에 해당되는 글 5건

  1. 2011.10.28 ctags 제약사항
  2. 2009.07.21 VI에 ctags 사용하기
  3. 2009.06.14 ctags format - CTAGS 출력 포맷/양식
  4. 2009.05.06 Gedit에 ctags 확장기능 추가하기 - Plugins
  5. 2009.01.07 ctags
막상 ctags를 돌려보니 main()은 보이는데
그아래의 변수들이 보이지 않는 현상 발생 -_-
이게 무슨 신혼첫날밤에 발기부전 걸리는 소리야! 라는 생각에
검색을 해보니 공식적인 내용은 발견하지 못했지만 아래의 내용들 발견..

ctagas는 원래 로컬 변수들은 못다루는듯 -_-
확인겸 openCV 소스를 받아서 전체를 돌리고 vi에서 해보니
main(int argc, char** argv) 의 argv를 소스내에서 찾으니 엉뚱한 곳으로 날아간다.

I know CTags does not handle local vars, However, the code I said I will be happy to contribute uses also a lexer + written with flex language to analyze a current scope (small scope, the main parsing is done via CTags)

즉, ctags만으로는 지역변수나 전역변수가 사용된 곳, 함수가 사용된 곳은 찾기 힘들다. 이때는 cscope를 사용하면 된다.
[링크 : http://blog.naver.com/parkys1982/30014739315

12. How can I locate all references to a specific function or variable?

There are several packages already available which provide this capability. As of this writing, they are:
GLOBAL source code tag system
GNU id-utils
cscope
cflow
 
[링크 : http://ctags.sourceforge.net/faq.html#12

신고

'프로그램 사용 > ctags & cscope' 카테고리의 다른 글

ctags 제약사항  (0) 2011.10.28
kscope 에서 특정 확장자 추가하기  (0) 2009.11.04
kscope 프로젝트 생성하기  (0) 2009.08.20
ctags format - CTAGS 출력 포맷/양식  (0) 2009.06.14
ctags  (0) 2009.01.07
Posted by 구차니
TAG ctags

댓글을 달아 주세요

프로그램 사용/vi2009.07.21 13:06
ctags는 c언어를 파싱하여 token 별로 추출해주는 녀석이다.
아무튼 vi에서 사용하기 위해서는
가장 간단한 방법으로


/src/ctags -R 을 실행후
/src/vi src.c 를 실행한다.

네비게이션은
ctrl - ] 는 추적하기(여러개 있을 경우 숫자로 선택)
ctrl - t 는 이전 위치로 돌아오기이다.
:tag tagname 은 그 태그로 이동하기 이다.(함수 이름, 변수 전부 이동가능)

[링크 : http://www.buggymind.com/90]
[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/article/ctags]

문서불러오기
:e [파일명]
새 문서(새 창열기)
:new
새 문서(이름으로)
:new [파일명]
[링크 : http://mwultong.blogspot.com/2006/06/vim-gvim.html]


ctrl+w f 하면 #include "" 나 #include <>의 파일 따라가기
[링크 : http://kldp.org/node/72478]


2010.01.28 추가
[링크 : http://www.viper.pe.kr/cgi-bin/moin.cgi/ctags_와_vi_사용하기]
신고
Posted by 구차니
TAG ctags, vi, vi ctags

댓글을 달아 주세요

6. Proposal
-----------

Use a comment after the {tagaddress} field.  The format would be:

    {tagname}<Tab>{tagfile}<Tab>{tagaddress}[;"<Tab>{tagfield}..]

   {tagname}    Any identifier, not containing white space..
   <Tab>    Exactly one TAB character (although many versions of Vi can handle any amount of white space).
   {tagfile}    The name of the file where {tagname} is defined, relative to the current directory
                   (or location of the tags file?).
   {tagaddress}    Any Ex command.  When executed, it behaves like 'magic' was not set.
                         It may be restricted to a line number or a search pattern (Posix).

Optionally:
   ;"        semicolon + doublequote: Ends the tagaddress in way that looks like the start of a comment to Vi.
   {tagfield}    See below.

A tagfield has a name, a colon, and a value: "name:value".
- The name consist only out of alphabetical characters.  Upper and lower case are allowed.
   Lower case is recommended.  Case matters ("kind:" and "Kind: are different tagfields).
- The value may be empty.
  It cannot contain a <Tab>.
  When a value contains a "\t", this stands for a <Tab>.
  When a value contains a "\r", this stands for a <CR>.
  When a value contains a "\n", this stands for a <NL>.
  When a value contains a "\\", this stands for a single '\' character.
  Other use of the backslash character is reserved for future expansion.
  Warning: When a tagfield value holds an MS-DOS file name, the backslashes must be doubled!

Proposed tagfield names:

FIELD-NAME    DESCRIPTION

arity        Number of arguments for a function tag.
class        Name of the class for which this tag is a member or method.
enum        Name of the enumeration in which this tag is an enumerator.
file        Static (local) tag, with a scope of the specified file.  When the value is empty, {tagfile} is used.
function    Function in which this tag is defined.  Useful for local variables (and functions).
               When functions nest (e.g., in Pascal), the function names are concatenated, separated with
                '/', so it looks like a path.
kind        Kind of tag.  The value depends on the language.  For C and
        C++ these kinds are recommended:
        c    class name
        d    define (from #define XXX)
        e    enumerator
        f    function or method name
        F    File name
        g    enumeration name
        m    member (of structure or class data)
        p    function prototype
        s    structure name
        t    typedef
        u    union name
        v    variable
        When this field is omitted, the kind of tag is undefined.
struct        Name of the struct in which this tag is a member.
union        Name of the union in which this tag is a member.

Note that these are mostly for C and C++.  When tags programs are written for
other languages, this list should be extended to include the used field names.
This will help users to be independent of the tags program used.

Examples:

    asdf    sub.cc    /^asdf()$/;"    new_field:some\svalue    file:
    foo_t    sub.h    /^typedef foo_t$/;"    kind:t
    func3    sub.p    /^func3()$/;"    function:/func1/func2    file:
    getflag    sub.c    /^getflag(arg)$/;"    kind:f    file:
    inc    sub.cc    /^inc()$/;"    file: class:PipeBuf


The name of the "kind:" field can be omitted.  This is to reduce the size of
the tags file by about 15%.  A program reading the tags file can recognize the
"kind:" field by the missing ':'.  Examples:

    foo_t    sub.h    /^typedef foo_t$/;"    t
    getflag    sub.c    /^getflag(arg)$/;"    f    file:


Additional remarks:
- When a tagfield appears twice in a tag line, only the last one is used.

Note about line separators:

Vi traditionally runs on Unix systems, where the line separator is a single
linefeed character <NL>.  On MS-DOS and compatible systems <CR><NL> is the
standard line separator.  To increase portability, this line separator is also
supported.

On the Macintosh a single <CR> is used for line separator.  Supporting this on
Unix systems causes problems, because most fgets() implementation don't see
the <CR> as a line separator.  Therefore the support for a <CR> as line
separator is limited to the Macintosh.

Summary:
line separator    generated on        accepted on
<LF>        Unix            Unix, MS-DOS, Macintosh
<CR>        Macintosh        Macintosh
<CR><LF>    MS-DOS            Unix, MS-DOS, Macintosh

The characters <CR> and <LF> cannot be used inside a tag line.  This is not
mentioned elsewhere (because it's obvious).

Note about white space:

Vi allowed any white space to separate the tagname from the tagfile, and the
filename from the tagaddress.  This would need to be allowed for backwards
compatibility.  However, all known programs that generate tags use a single
<Tab> to separate fields.

There is a problem for using file names with embedded white space in the
tagfile field.  To work around this, the same special characters could be used
as in the new fields, for example "\s".  But, unfortunately, in MS-DOS the
backslash character is used to separate file names.  The file name
"c:\vim\sap" contains "\s", but this is not a <Space>.  The number of
backslashes could be doubled, but that will add a lot of characters, and make
parsing the tags file slower and clumsy.

To avoid these problems, we will only allow a <Tab> to separate fields, and
not support a file name or tagname that contains a <Tab> character.  This
means that we are not 100% Vi compatible.  However, there is no known tags
program that uses something else than a <Tab> to separate the fields.  Only
when a user typed the tags file himself, or made his own program to generate a
tags file, we could run into problems.  To solve this, the tags file should be
filtered, to replace the arbitrary white space with a single <Tab>.  This Vi
command can be used:

    :%s/^\([^ ^I]*\)[ ^I]*\([^ ^I]*\)[ ^I]*/\1^I\2^I/

(replace ^I with a real <Tab>).

TAG FILE INFORMATION:

Psuedo-tag lines can be used to encode information into the tag file regarding
details about its content (e.g. have the tags been sorted?, are the optional
tagfields present?), and regarding the program used to generate the tag file.
This information can be used both to optimize use of the tag file (e.g.
enable/disable binary searching) and provide general information (what version
of the generator was used).

The names of the tags used in these lines may be suitably chosen to ensure
that when sorted, they will always be located near the first lines of the tag
file.  The use of "!_TAG_" is recommended.  Note that a rare tag like "!"
can sort to before these lines.  The program reading the tags file should be
smart enough to skip over these tags.

The lines described below have been chosen to convey a select set of
information.

Tag lines providing information about the content of the tag file:

!_TAG_FILE_FORMAT    {version-number}    /optional comment/
!_TAG_FILE_SORTED    {0|1}            /0=unsorted, 1=sorted/

The {version-number} used in the tag file format line reserves the value of
"1" for tag files complying with the original UNIX vi/ctags format, and
reserves the value "2" for tag files complying with this proposal. This value
may be used to determine if the extended features described in this proposal
are present.

Tag lines providing information about the program used to generate the tag
file, and provided solely for documentation purposes:

!_TAG_PROGRAM_AUTHOR    {author-name}    /{email-address}/
!_TAG_PROGRAM_NAME    {program-name}    /optional comment/
!_TAG_PROGRAM_URL    {URL}    /optional comment/
!_TAG_PROGRAM_VERSION    {version-id}    /optional comment/

[링크 : http://ctags.sourceforge.net/FORMAT]



별다른 옵션을 주지 않고
 ctags [filename]
으로 실행하면 tags 라는 파일이 생성됨

$more test.c
#include <stdio.h>
#define VERSION 1.00

typedef struct _point_
{
    int x;
    int y;
} POINT;

void main()
{
    int a;
    char str[] = "Hello world";
    POINT pt;
   
    printf("%s\n",str);
}

$ more tags
!_TAG_FILE_FORMAT    2    /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED    1    /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert    /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME    Exuberant Ctags    //
!_TAG_PROGRAM_URL    http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION    5.4    //
POINT    test.c    /^} POINT;$/;"    t    file:
VERSION    test.c    2;"    d    file:
_point_    test.c    /^typedef struct _point_$/;"    s    file:
main    test.c    /^void main()$/;"    f
x    test.c    /^    int x;$/;"    m    struct:_point_    file:
y    test.c    /^   
int y;$/;"    m    struct:_point_    file:

{tagname}<Tab>{tagfile}<Tab>{tagaddress}[;"<Tab>{tagfield}..] 가 기본 포맷인데
POINT    test.c    /^} POINT;$/;"    t    file: 를 보면

tagname - POINT
tagfile - test.c
tagaddress - /^} POINT;$/
tagfield - t
tagfield - file:

라는 의미를 지니게 된다. 아래의 POINT 구조체의 x, y 변수는 m(member)로 표기된다.
신고

'프로그램 사용 > ctags & cscope' 카테고리의 다른 글

ctags 제약사항  (0) 2011.10.28
kscope 에서 특정 확장자 추가하기  (0) 2009.11.04
kscope 프로젝트 생성하기  (0) 2009.08.20
ctags format - CTAGS 출력 포맷/양식  (0) 2009.06.14
ctags  (0) 2009.01.07
Posted by 구차니

댓글을 달아 주세요

Linux2009.05.06 23:57
Gedit에 플러그인 중에 Ctags 기능을 확장해주는 것이 있다.
일단 몇가지는 설치를 하려면 Gedit 소스코드가 있어야 하고 꽤나 복잡해서 성공한건 두개 뿐이다.

Class Browser

A class browser located in the side pane. Based on ctags, it supports a wide range of languages. Download: http://www.stambouliote.de/projects/gedit_plugins.html

Function browser

GEdit function browser plugin provides an easy way to navigate through sources files with GEdit. This plugin uses Exuberant CTags for parsing process and returned back results in GEdit left panel. Mostly tested under C and C++ files. A Bookmarking support has been delivered in version 0.2. More: http://sourceforge.net/projects/gedit-funcbrows/


위의 링크에서 다운로드 받아, 위의 경로에 압축을 해제한다.
그리고 Gedit를 다시 시작하고 Plugin을 설정해준다.


Class Browser를 실행한 예제

Functions Browser를 실행한 예제


신고
Posted by 구차니
TAG ctags, gedit

댓글을 달아 주세요

ctags는 말 그대로 c 언어 파일의 keyword, identifier를 출력해 주는 툴이다.

 ctags -R
을 실행하면 tags라는 파일이 생성이 된다.

source code [test.c]

command [ctags test.c]
file [tags]
!_TAG_FILE_FORMAT    2    /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED    1    /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert    /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME    Exuberant Ctags    //
!_TAG_PROGRAM_URL    http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION    5.4    //
CHARLEY    test.c    /^    CHARLEY,$/;"    e    file:
FALSE    test.c    /^    FALSE$/;"    e    file:
LINDA    test.c    /^    LINDA$/;"    e    file:
TOM    test.c    /^    TOM,$/;"    e    file:
TRUE    test.c    /^    TRUE,$/;"    e    file:
WIN32_VERSION    test.c    3;"    d    file:
boolean    test.c    /^} boolean;$/;"    t    file:
main    test.c    /^int main(int argc,char argv**)$/;"    f
test_int    test.c    /^int test_int;$/;"    v
test_int_static    test.c    /^static int test_int_static;$/;"    v    file:

command [ctags -n -u test.c]
file [tags]
!_TAG_FILE_FORMAT    2    /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED    0    /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert    /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME    Exuberant Ctags    //
!_TAG_PROGRAM_URL    http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION    5.4    //
WIN32_VERSION    test.c    3;"    d    file:
test_int_static    test.c    5;"    v    file:
test_int    test.c    6;"    v
TRUE    test.c    10;"    e    file:
FALSE    test.c    11;"    e    file:
boolean    test.c    12;"    t    file:
TOM    test.c    16;"    e    file:
CHARLEY    test.c    17;"    e    file:
LINDA    test.c    18;"    e    file:
main    test.c    21;"    f

Wikipedia의 ctags file format 에 관련된 내용

더보기


ctags의 옵션(도움말)

더보기


---
2011.10.28 추가

ctags 지원 언어

더보기

 
신고

'프로그램 사용 > ctags & cscope' 카테고리의 다른 글

ctags 제약사항  (0) 2011.10.28
kscope 에서 특정 확장자 추가하기  (0) 2009.11.04
kscope 프로젝트 생성하기  (0) 2009.08.20
ctags format - CTAGS 출력 포맷/양식  (0) 2009.06.14
ctags  (0) 2009.01.07
Posted by 구차니

댓글을 달아 주세요