473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C code analisys tool

Hello,
I am looking for C code analysing tool,

My problem is:
To discover the portion of code that depends on(deals with) a number
of specified structures and variables.
Sample:

void funct(struct header* h)
{
.....

memcpy(buff,h,sizeof(struct header));
func2(buff)
.....
a kind of other code....

}
The idea is to detect all the code that depends on or deals with "h"

Do you know the tools that can solve the problem?

Thanks a lot.
Andrey

May 11 '06 #1
16 1869
kazak a écrit :
Hello,
I am looking for C code analysing tool,

My problem is:
To discover the portion of code that depends on(deals with) a number
of specified structures and variables.
Sample:

void funct(struct header* h)
{
....

memcpy(buff,h,sizeof(struct header));
func2(buff)
....
a kind of other code....

}
The idea is to detect all the code that depends on or deals with "h"

Do you know the tools that can solve the problem?

Thanks a lot.
Andrey


If you are using the lcc-win32 IDE put the cursor in your identifier and
press CTRL+F8. This will display all usages of that identifier in all
loaded files. If you want to display the usage just within a function
right click in the identifier and choose the "Locals in <function name>"
option from the context menu that appears.

The second option will show a slice of all lines that use the given
identifier ignoring all lines where the identifier does not appear. This
is very handy for seeing the actual usage of a variable

http://www.cs.virginia.edu/~lcc-win32

May 11 '06 #2
kazak wrote:
Hello,
I am looking for C code analysing tool,

This sort of thing might be provided by you tool chain, check the docs.

--
Ian Collins.
May 11 '06 #3
Ian Collins a écrit :
kazak wrote:
Hello,
I am looking for C code analysing tool,


This sort of thing might be provided by you tool chain, check the docs.


Probably not. This very common option is absent, for instance, in the
latest version of Visual Studio (VC8) even if that software takes 3GB
disk space and as a zillion options.

The gcc IDE DevC++ doesn't do it either. Under linux, most IDEs do not
do any syntax analysis.

Of course

grep MyId *.c

will do it (sort of) but it will not eliminate comments and doesn't
follow scopes.
May 11 '06 #4
vim+ctags :)
kazak wrote:
Hello,
I am looking for C code analysing tool,

My problem is:
To discover the portion of code that depends on(deals with) a number
of specified structures and variables.
Sample:

void funct(struct header* h)
{
....

memcpy(buff,h,sizeof(struct header));
func2(buff)
....
a kind of other code....

}
The idea is to detect all the code that depends on or deals with "h"

Do you know the tools that can solve the problem?

Thanks a lot.
Andrey

May 11 '06 #5
jacob navia wrote:
Ian Collins a écrit :
kazak wrote:
Hello,
I am looking for C code analysing tool,

This sort of thing might be provided by you tool chain, check the docs.


Probably not. This very common option is absent, for instance, in the
latest version of Visual Studio (VC8) even if that software takes 3GB
disk space and as a zillion options.

The gcc IDE DevC++ doesn't do it either. Under linux, most IDEs do not
do any syntax analysis.

That does appear to be a common trend. Bit of a pain for legacy code
support.
Of course

grep MyId *.c

will do it (sort of) but it will not eliminate comments and doesn't
follow scopes.


But it does encourage meaningful names, try greping for 'h'...

--
Ian Collins.
May 11 '06 #6
pi***@tin.it a écrit :
vim+ctags :)


ctags will give you all usage of a variable within a function?

How do you do that?
Just curious...

jacob
May 11 '06 #7
It sounds to me like you just want to cross reference this h variable.
I would use vim with ctags and/or cscope. To learn how to use any of
these tools w/ vim just check out vim's help system.

Mark

kazak wrote:
Hello,
I am looking for C code analysing tool,

My problem is:
To discover the portion of code that depends on(deals with) a number
of specified structures and variables.
Sample:

void funct(struct header* h)
{
....

memcpy(buff,h,sizeof(struct header));
func2(buff)
....
a kind of other code....

}
The idea is to detect all the code that depends on or deals with "h"

Do you know the tools that can solve the problem?

Thanks a lot.
Andrey


May 12 '06 #8
On 2006-05-11, jacob navia <ja***@jacob.remcomp.fr> wrote:
pi***@tin.it a écrit :
vim+ctags :)


ctags will give you all usage of a variable within a function?

How do you do that?


I don't know if you can do that with ctags, but cscope can give you all
the references to a variable, and, in some versions, all the assignments
to a variable.

But the OP's problem is much harder than this:

OP> My problem is: To discover the portion of code that depends on(deals
OP> with) a number of specified structures and variables. Sample:

OP> void funct(struct header* h)
OP> {
OP> ....
OP>
OP> memcpy(buff,h,sizeof(struct header));
OP> func2(buff)
OP> ....
OP> a kind of other code....
OP>
OP> }

OP> The idea is to detect all the code that depends on or deals with "h"

The type of buff isn't given, but let's assume it's char * for the sake
of argument.

So now anything that deals with buff deals with *h, and we have to follow
a memcpy to see this.

I think a runtime tool would be an easier task than a static tool here.
What's needed is a kind of "radioactive data" where the actual bytes
comprising *h can be made to glow in the dark so we can follow them
through the system.

You could possibly set something up with a combination of gdb's
watchpoints and commands, but if *h is big this might be difficult.

DTrace from Solaris may be able to do the job:

http://www.sun.com/bigadmin/content/dtrace/
May 12 '06 #9
No greps or cross references can help, cause I don't care about
variable only, I want discover all code that deals with it(it's
execution depends on that variable, but it can be copied in "buff" for
example and tool must look for buff dependent code and futher more...)

Static analisys is the way, have found a lot of tools like CIL, ACL2
and other, but using them does not seem to be a trivial task.

I am going to do it for the piece of code in Linux kernel

May 12 '06 #10
Any solutions?

May 15 '06 #11
kazak said:
Any solutions?


What kind of solutions? I can do you a nice saline if you like. What are you
talking about? Where's the context?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
May 15 '06 #12
kazak a écrit :
Any solutions?

There is no solution.
Nobody has ever done what you want with C in a comprehensive, final way,
because of pointer/address analysis, the difficulties of following
pointers through all possible paths, etc.

For more than VERY simple problems there is no solution.

jacob
May 15 '06 #13
On 12 May 2006 01:58:30 -0700, "kazak" <an************@gmail.com>
wrote:
No greps or cross references can help, cause I don't care about
variable only, I want discover all code that deals with it(it's
execution depends on that variable, but it can be copied in "buff" for
example and tool must look for buff dependent code and futher more...)

Static analisys is the way, have found a lot of tools like CIL, ACL2
and other, but using them does not seem to be a trivial task.
You're right, it's non-trivial. There are two approaches that I have
used, neither very attractive. First, you can use the static analysis
tools plus manual bookkeeping to track all affected uses. In
relatively simple cases this is feasible. Second, you can do something
to 'break" the variable (perhaps just eliminate it) and see what else
breaks. Some things may be broken at compile time, and others only at
run time. This can lead to some hairy debugging, and you'll probably
never be sure you got everything.
I am going to do it for the piece of code in Linux kernel


--
Al Balmer
Sun City, AZ
May 15 '06 #14
"kazak" <an************@gmail.com> writes:
Any solutions?


For what?

Read <http://cfaj.freeshell.org/google/>.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 15 '06 #15
kazak wrote:

Any solutions?


To what, or of what?

In general on usenet you should realize that readers may very well
not have convenient access to previous articles in a thread. That
means that your reply articles should include adequate context, so
that they stand by themselves. Google is NOT usenet, it is only a
very poor interface to the real usenet system. To include proper
context when using google, see my sig. below. Please be sure to
read the referenced URLs.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
May 15 '06 #16
Got it all.
Thanks to every one.

CBFalconer пиÑал(а):
kazak wrote:

Any solutions?


To what, or of what?

In general on usenet you should realize that readers may very well
not have convenient access to previous articles in a thread. That
means that your reply articles should include adequate context, so
that they stand by themselves. Google is NOT usenet, it is only a
very poor interface to the real usenet system. To include proper
context when using google, see my sig. below. Please be sure to
read the referenced URLs.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


May 17 '06 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Maurice LING | last post by:
Hi, Is there any UML tools that is able to take UML and generate Python codes? Cheers Maurice
3
by: John Gabriele | last post by:
Can anyone please point me to a good UML tutorial that contains C++ example code? The stuff I've found on the web and on the bookstore shelves doesn't contain any actual C++ code. Googling, so far...
2
by: CaptRespect | last post by:
We've been using CVS for our HTML, JAVA etc.. Now we would like to use it for our SQL CODE to. We have a large database with many stored procedures. I would like to have something using Ant...
6
by: YK | last post by:
All, What is the best way to protect IL code? --------------------------------------------------- Typical scenario: Visual Studio .NET 2003 includes Dotfuscator Community Edition, which...
12
by: Jacek Jurkowski | last post by:
.... is warning me not to use catch(Exception e) as too general. But how to determine what exception type should I use if try section may cause a few exception types? How to determine what kind of...
40
by: GTi | last post by:
Is there any source code documentation tools available for Visual Studio 2005 ? I have created a LIB that must be documented. Must I do it by hand or is it some kind of tools to pre document my...
2
by: Allerdyce.John | last post by:
Is there a python library to parse C++ code file? If yes, can you please tell me where is it? Thank you.
4
by: Chris Dunaway | last post by:
We have an app that will be run from a network share. I know that on the machine that will run the app, I need to grant the proper permissions. On the laptop, I installed the .Net framework...
26
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.