Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No results for big projects? #14

Open
elmart opened this issue Jan 12, 2015 · 5 comments
Open

No results for big projects? #14

elmart opened this issue Jan 12, 2015 · 5 comments
Assignees

Comments

@elmart
Copy link

elmart commented Jan 12, 2015

Hi, I'm issuing a simple command to look for usages of a given struct field:

coccigrep -t <type> -a <field> -o used src/*.[ch]

But I'm getting no output.
Strangely, if I run the same command on a few files, typing each of them manually, then I get results.

So, does coccigrep have a maximum number of files, beyond which it stops working?

@regit
Copy link
Owner

regit commented Jan 12, 2015

That's strange. It is not supposed to have. Maybe you reach the size limit on the shell prompt. I frequently running it on suricata who got 600 source files.

You can try to give it only the directory as param (it will recurse on C file) or you may want to try the -l FILE_LIST, --file-list FILE_LIST option to give your file ist in input. Also don't forget to set the number of CPUs (via -p) to parallelize the search on your available CPUs.

@regit regit self-assigned this Jan 12, 2015
@elmart
Copy link
Author

elmart commented Jan 12, 2015

I don't think it's a shell limit problem. I don't have so many files. Look at this sample output:

eliseo@ubuntu:~/projects/os/neovim/neovim$ ls src/nvim/*.c
src/nvim/arabic.c        src/nvim/ex_cmds2.c     src/nvim/garray.c     src/nvim/main.c     src/nvim/misc1.c    src/nvim/popupmnu.c    src/nvim/strings.c
src/nvim/buffer.c        src/nvim/ex_cmds.c      src/nvim/getchar.c    src/nvim/map.c      src/nvim/misc2.c    src/nvim/profile.c     src/nvim/syntax.c
src/nvim/charset.c       src/nvim/ex_docmd.c     src/nvim/hardcopy.c   src/nvim/mark.c     src/nvim/mouse.c    src/nvim/quickfix.c    src/nvim/tag.c
src/nvim/cursor.c        src/nvim/ex_eval.c      src/nvim/hashtab.c    src/nvim/mbyte.c    src/nvim/move.c     src/nvim/regexp.c      src/nvim/tempfile.c
src/nvim/cursor_shape.c  src/nvim/ex_getln.c     src/nvim/if_cscope.c  src/nvim/memfile.c  src/nvim/normal.c   src/nvim/regexp_nfa.c  src/nvim/term.c
src/nvim/diff.c          src/nvim/farsi.c        src/nvim/indent.c     src/nvim/memline.c  src/nvim/ops.c      src/nvim/screen.c      src/nvim/ui.c
src/nvim/digraph.c       src/nvim/fileio.c       src/nvim/indent_c.c   src/nvim/memory.c   src/nvim/option.c   src/nvim/search.c      src/nvim/undo.c
src/nvim/edit.c          src/nvim/file_search.c  src/nvim/keymap.c     src/nvim/menu.c     src/nvim/os_unix.c  src/nvim/sha256.c      src/nvim/version.c
src/nvim/eval.c          src/nvim/fold.c         src/nvim/log.c        src/nvim/message.c  src/nvim/path.c     src/nvim/spell.c       src/nvim/window.c
eliseo@ubuntu:~/projects/os/neovim/neovim$ coccigrep -t prt_text_attr_T -a bold -o used src/nvim/hardcopy.c
src/nvim/hardcopy.c:860 (prt_text_attr_T attr):         prt_set_font(attr.bold, attr.italic, attr.underline);
src/nvim/hardcopy.c:363 (prt_text_attr_T *pattr):   pattr->bold = (highlight_has_attr(hl_id, HL_BOLD, modec) != NULL);
eliseo@ubuntu:~/projects/os/neovim/neovim$ coccigrep -t prt_text_attr_T -a bold -o used src/nvim/*.c
eliseo@ubuntu:~/projects/os/neovim/neovim$

So, as you can see, I have only 63 files.
Running coccigrep on one of them (hardcopy.c) gives results.
Doing the same on all *.c files gives no results.
I'm on an Ubuntu VM, my host OS being OSX Yosemite.
Any idea?

@regit
Copy link
Owner

regit commented Jan 13, 2015

Hello @elmart,

I've just run the same 'src/*c' coccigrep command in neovim source and it is working (got the two same matches)

What version of cocigrep are you using ?

@elmart
Copy link
Author

elmart commented Jan 13, 2015

I cloned coccigrep git repo and installed from sources (sudo python setup.py install).
Reported version is 1.14.
I had previously installed coccinelle (packaged version for Ubuntu, through apt-get install). Reported spatch version is:
spatch version 1.0.0-rc22 with Python support and with PCRE support

@Forty-Bot
Copy link

Hey just want to note that I ran into this issue. A naïve coccigrep -l $(git ls-files) failed with no output. Switching to something like coccigrep -l $(git grep -l interesting_struct) worked.

I think the problem is in fact due to long command lines. When I ran the failing command line with -p, I saw spatch being invoked with very long command lines:

spatch --recursive-includes -sp_file /tmp/tmpg9zue7rh.cocci -I drivers/usb/host drivers/usb/host/ehci-omap.c drivers/usb/host/ehci-pci.c drivers/usb/host/ehci-tegra.c drivers/usb/host/ehci-vf.c drivers/usb/host/ehci-zynq.c drivers/usb/host/ehci.h drivers/usb/host/ohci-at91.c drivers/usb/host/ohci-da8xx.c drivers/usb/host/ohci-generic.c drivers/usb/host/ohci-hcd.c drivers/usb/host/ohci-lpc32xx.c drivers/usb/host/ohci-npcm.c drivers/usb/host/ohci-pci.c drivers/usb/host/ohci.h drivers/usb/host/r8a66597-hcd.c drivers/usb/host/r8a66597.h drivers/usb/host/usb-sandbox.c drivers/usb/host/usb-uclass.c drivers/usb/host/usb_bootdev.c drivers/usb/host/xhci-brcm.c drivers/usb/host/xhci-dwc3.c drivers/usb/host/xhci-exynos5.c drivers/usb/host/xhci-fsl.c drivers/usb/host/xhci-mem.c drivers/usb/host/xhci-mtk.c drivers/usb/host/xhci-mvebu.c drivers/usb/host/xhci-omap.c drivers/usb/host/xhci-pci.c drivers/usb/host/xhci-rcar-r8a779x_usb3_v3.h drivers/usb/host/xhci-rcar.c drivers/usb/host/xhci-ring.c drivers/usb/host/xhci.c ... (I cut off the rest but it just keeps going)

On my system, I am limited to 2088502 bytes of command line arguments:

$ xargs --show-limits </dev/null
Your environment variables take up 3301 bytes
POSIX upper limit on argument length (this system): 2091803
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2088502
Size of command buffer we are actually using: 131072
Maximum parallelism (--max-procs must be no greater): 2147483647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants