Skip to contentSkip to conversation

Sparse Ctags

PATCH In review Christopher Li 2 participants 2 messages Dec 8, 2006

Subsystems (2)
lore
Share & tools
lore

Christopher Li

author maintainer
#0 lore raw

PATCH 1/1 Sparse Ctags

Here is my attempt to write a Ctags base on sparse.
It depend on the result from actually preprocessing the C source file. It can handle the tags from macro expansion.

It works well enough for me to locate "int32_t" and "clear_token_alloc".

symbol.h +4 -0
Index: sparse/symbol.h
===================================================================
@@ -133,6 +133,10 @@ struct symbol {
 	union /* backend */ {
 		struct basic_block *bb_target;	/* label */
 		void *aux;			/* Auxiliary info, eg. backend information */
+		struct {			/* sparse ctags */
+			char kind;
+			unsigned int visited:1;
+		};
 	};
 	pseudo_t pseudo;
 };
Makefile +5 -1
Index: sparse/Makefile
===================================================================
@@ -22,7 +22,7 @@ LIBDIR=$(PREFIX)/lib
 INCLUDEDIR=$(PREFIX)/include
 PKGCONFIGDIR=$(PREFIX)/share/pkgconfig
 
-PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example test-unssa test-dissect
+PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example test-unssa test-dissect sctags
 INST_PROGRAMS=sparse cgcc
 
 LIB_H=    token.h parse.h lib.h symbol.h scope.h expression.h target.h \
@@ -93,6 +93,9 @@ test-unssa: test-unssa.o $(LIBS)
 test-dissect: test-dissect.o $(LIBS)
 	$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
 
+sctags: sctags.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
+
 $(LIB_FILE): $(LIB_OBJS)
 	$(AR) rcs $@ $(LIB_OBJS)
 
@@ -122,6 +125,7 @@ test-lexing.o: $(LIB_H)
 test-parsing.o: $(LIB_H)
 test-linearize.o: $(LIB_H)
 test-dissect.o: $(LIB_H)
+sctags.o: $(LIB_H)
 compile.o: $(LIB_H) compile.h
 compile-i386.o: $(LIB_H) compile.h
 tokenize.o: $(LIB_H)
sctags.c +202 -0

202 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · Christopher Li

Here is my attempt to write a Ctags base on sparse.
It depend on the result from actually preprocessing the C source file. It can handle the tags from macro expansion.

It works well enough for me to locate "int32_t" and "clear_token_alloc".

Hey, cool. One of my long-term projects is to implement the POSIX utilities[1], and ctags is on the list[2] of utilities I want to implement.

I was hoping that I, or someone else, could take libsparse and use it to provide a ctags(1) utility. Other utilities I hope can be implemented include cflow[3] and cxref[4]. And c99(1), of course ;-)

Jeff

[1] git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/posixutils.git
[2] http://www.opengroup.org/onlinepubs/009695399/idx/utilities.html
[3] http://www.opengroup.org/onlinepubs/009695399/utilities/cflow.html
[4] http://www.opengroup.org/onlinepubs/009695399/utilities/cxref.html