Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Standalone Software Fault Injector

Hi Gonçalo

 

At a glance I would say yes you have to create a project. The exception actually happens because you don’t have an originating translation unit for your AST, which you could set manually. But faking a translation unit might not be that simple. The ChangeFormatter will furthermore try to query the project of the translation unit for its formatter options.

 

In principle I see three options:

1.       Work with a project.

2.       Derive the ChangeGenerator and ASTWriting infrastructure (with your own implementation) to avoid the formatting or do it with default options.

3.       Try to create your own translation unit and cproject classes which just satisfy the required operations, which you could set as originating translation unit for your AST.

If possible I would follow the first option and I would really try to avoid the last two options.

 

I hope this helps!

Regards

Thomas

 

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Gonçalo Pereira
Sent: Freitag, 17. April 2015 15:28
To: CDT General developers list.
Subject: [cdt-dev] Standalone Software Fault Injector

 

Hello,

 

I'm trying to do an software to inject software faults in C programs, using CDT.

 

I have some .c files and read them with:

 

translationUnit = GPPLanguage.getDefault().getASTTranslationUnit(fileContent, info, emptyIncludes, null, opts, log);

 

But, when I try rewrite the AST Tree I get a NullPointException in ChangeFormatter.java:92:

 

// Calculate formatting changes for the regions after the refactoring changes.

                                   ICProject project = tu.getCProject();

 

What is my problem? 

What I'm doing wrong? 

I need to have a project with C files? Is mandatory?

 

Cheers

Gonçalo Silva Pereira


Back to the top