On Sat, 30 Oct 2010, Eric Noulard wrote:
> 2010/10/29 Julia Lawall <[email protected]>:
> > On Fri, 29 Oct 2010, Eric Noulard wrote:
> >
> >> 2010/10/29 Julia Lawall <[email protected]>:
> >> >
> >> > If someone knows of a free indexing tool, then we could try to support
> >> > that as well. Actually glimpse is not entirely satisfactory because it
> >> > considers _ to be a word separator, leading to many false positives in
> >> > some cases.
> >>
> >>
> >> Would cscope do the job?
> >> http://cscope.sourceforge.net/
> >>
> >> I found cscope very efficient for searching C files, even huge set of them.
> >>
> >> Now you want a "string search" or a "symbol" search?
> >> cscope can do both but I don't know if its efficient for string.
> >>
> >> If symbol search is enough may be ctags would be a good candidates too;
> >> http://ctags.sourceforge.net/
> >>
> >> What kind of indexing do you need?
> >
> > I want an index of identifiers, which could be restricted to function
> > names. Afterwards, I want to be able to run some program on the command
> > line with some form of regular expression containing nested ands and ors,
> > and to receive a list of relevant files. I recall that some tools provide
> > an API, but no command line interface. Perhaps such an API could be used
> > directly from ocaml, which has the ability to call foreign functions, but
> > I haven't looked into it.
>
> Then cscope could fits the needs (I don't know id-utils)
>
> say you know the list of source files you want to search in
> and this list of files is stored in
>
> myfiles.list
>
> cscope -i myfiles.list -k -L -0 "(Prefix_.*|.*rpc.*)"
>
> -i myfiles.list specifies the source files list
> -k is for kernel mode (don't use /usr/include)
> -L is for getting line oriented output
> -0 <regex> search ANY C symbol matching this regex
>
> if you use
>
> -1 <regex> you will only search for function name matching the regex
>
> You'll get a little more than a list of filename since each line
> contains the filename + line number and the match.
> But you have a one liner for that:
>
> cscope -i myfiles.list -k -L -0 "(Prefix_.*|.*rpc.*)" | cut -f 1 -d\ | uniq
>
> which will give you the list of file (unique name) whose content matches
> the regex.
>
> The first time you launch cscope it builds its cross reference file
> (cscope.out if no name is specified)
> you may pre-compute this file before doing any search.
>
> If you really want to search C symbol (var, function etc...) cscope
> should be really fast.
> I don't know if cscope is able to handle fancy regex with
> nesting/and/or but may be it's worth a try.
Thanks for the information and the examples. I will look into it. We
have no need for *s in the regular expression (I guess we would if I took
into account regular expression constraints on identifier metavariables,
but currently I don't). But we do generate complicated nestings of and
and or. This indeed is another problem with glimpse. It only allows
maybe 16 terms in the regular expression, which one can easily exceed if
writing a semantic patch that eg considers all locking functions.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)