473,848 Members | 1,630 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 1925
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
5622
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
19149
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 that and actual code. The reason I'm looking is, I find that once I get 8 or so classes in my...
2
5139
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
1281
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)); Catch(Exception) handles all of the possibilities and i don't know how to choose more detailed exception...
40
2822
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
1685
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
2209
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 there, but not the 2.0 tool. How do you configure code access without that tool? Chris
26
25630
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
9892
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9735
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10997
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10718
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9497
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7067
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4542
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
2
4134
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3172
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.