473,569 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,s izeof(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 1892
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,s izeof(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,s izeof(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,s izeof(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.re mcomp.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,s izeof(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 "radioactiv e 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

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

Similar topics

9
5580
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
19141
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 I've found: http://www.lysator.liu.se/~alla/dia/umltut/ I've looked at the general UML tutorials, but I'm having trouble making the leap between...
2
5128
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 like: Download the latest version of source code. If the SQL patch has been updated, run the patch to update the Database.
6
384
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 intends to protect IL code. However, many .NET applications use data binding in UI forms. For example: Employee e = new Employee();
12
1257
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 exceptions could such lines cause? XmlTextReader xTr = new XmlTextReader(pFileName); XmlSerializer xS = new XmlSerializer(typeof(T)); ...
40
2770
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 source code?
2
1662
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
2202
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 verson 2.0 (dotnetfx) but when I went to the control panel under administrative tools, the .Net 2.0 configuration tool was not there. The 1.1 tool was...
26
25585
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 idea? Thanks you very much
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.