views:

210

answers:

4

I'm looking for a tool that, given a bit of C, will tell you what symbols (types, precompiler definitions, functions, etc) are used from a given header file. I'm doing a port of a large driver from Solaris to Windows and figuring out where things are coming from is getting to be difficult, so this would be a huge help. Any ideas?

Edit: Not an absolute requirement, but tools that work on Windows would be a plus.

Edit #2: To clarify what I'm trying to do, I have a codebase I'm trying to port, which brings in a large number of headers. What I'd like is a tool that, given foo.c, will tell me which symbols it uses from bar.h.

+1  A: 
Johannes Schaub - litb
Hmm, looks very nice. Looks like it'll be a bit of work to get on windows, though, unfortunately. I should add that qualifier to the question. That said, it may be worth the effort to get it working.
Cody Brocious
+1  A: 

I use on both Linux and Windows : gvim + ctags + cscope.
Same environment will work on solaris as well, but this is of course force you to use vim as editor, i pretty sure that emacs can work with both ctags and cscope as well.
You might want give a try to vim, it's a bit hard at first, but soon you can't work another way. The most efficient editor (IMHO).

Comment replay:

Look into the cscope man:

...

Find functions called by this function:
Find functions calling this function:

...

I think it's exactly what are you looking for ... Please clarify if not.

Comment replay 2:

ok, now i understand you. The tools i suggested can help you understand code flow, and find there certain symbol is defined, but not what are you looking for.

Not what you asking for but since we are talking i have some experience with porting and drivers (feel free to ignore)

It seems like compiler is good enough for your task. You just starting with original file and let compiler find what missing part, it will be a lot of empty stubs and you will get you code compiled.

At least for beginning i suggest you to create a lot of stubs and modifying original code as less as possible, later on once you get it working you can optimize.

It's might be more complex depending on the type of driver your are porting (I'm assuming kernel driver), the Windows and Solaris subsystems are not so alike. We do have a driver working on both solaris and windows, but it was designed to be multi platform from the beginning.

Ilya
I'd looked at cscope, but I didn't see any way to see which symbols from one file were used in another. I'll look harder, thanks.
Cody Brocious
I looked through their docs a bit, but I don't see a way to only see what a given piece of code uses from a specified header. Is there a way to drill down? Thanks
Cody Brocious
still note sure i understand what are you trying to achieve it's might be useful if you give more detailed example in your question itself (comments are to short)
Ilya
Added that, thanks.
Cody Brocious
Thanks for the input. I'm doing a port of DTrace, so the problem is that it hooks into a bunch of different places, so when i see things like sockets.h being included for apparently no reason, it can throw me off for a while, hence why I'm looking for the tool. Anyway, I think perl will do ;)
Cody Brocious
A: 

Try DoxyGen, it can produce graphs and/or HTML and highly customizable

Dmitry Khalatov
if i'm not mistaken doxygen does not work directly on the code, if code was not written with doxygen documentation it will produce nothing.
Ilya
You are. It can produce graphs based on a code only.
Dmitry Khalatov
Good to know, thanks
Ilya
A: 

emacs and etags.

And I leverage make to run the tag indexing for me---that way I can index a large project with one command. I've been thinking about building a master index and separate module indecies, but haven't gotten around to implementing this yet...


@Ilya: Would pistols at dawn be acceptable?

dmckee