Project

General

Profile

Actions

Feature #865

closed

Aspectator: Support for reusable blocks of aspect files

Added by Alexey Khoroshilov about 13 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
High
Category:
-
Start date:
02/18/2011
Due date:
% Done:

0%

Estimated time:
Published in build:
c371769

Description

Aspectator should support something like #include directives in aspect files.

It is required for kernel model and other aspects that are common for several rules.

For example, see a fix for bug #749.


Files

built_in_macros (13.3 KB) built_in_macros Built-in macros on my machine Evgeny Novikov, 06/13/2012 12:43 PM

Related issues 2 (0 open2 closed)

Related to Linux Kernel Safety RuleDB - Feature #2707: IS_ERR kernel core function should be modeled because of it is too complex for our verifiers ClosedEvgeny Novikov04/04/2012

Actions
Related to C Instrumentation Framework - Bug #339: Typedef names in declarations aren't always processedClosedEvgeny Novikov08/05/2010

Actions
Actions #1

Updated by Evgeny Novikov about 13 years ago

  • Status changed from New to Open

It would be great! But after update aspectator up to the new gcc with ldv pretty printer.

Actions #2

Updated by Alexey Khoroshilov almost 13 years ago

  • Priority changed from Normal to High

Another example is to share code that matches same kernel functions (e.g. spinlock or memory functions) between several rules/rule models.

Actions #3

Updated by Pavel Shved over 12 years ago

  • Priority changed from High to Normal
Actions #4

Updated by Evgeny Novikov almost 12 years ago

Don't forget to extract IS_ERR model from 101_1a rule model (issue #2707).

Actions #5

Updated by Evgeny Novikov almost 12 years ago

  • Priority changed from Normal to High

The issue becomes more priority, since we're going to use aspectator more and more actively.

Actions #6

Updated by Evgeny Novikov almost 12 years ago

Hmm, I guess that using of the standard GCC preprocessor is very suitable for this issue.
Aspect defines are coming soon :)

Actions #7

Updated by Alexey Khoroshilov almost 12 years ago

Evgeny Novikov wrote:

Hmm, I guess that using of the standard GCC preprocessor is very suitable for this issue.
Aspect defines are coming soon :)

I am not sure that standard GCC preprocessor is good enough. For example, it will apply and remove #define statements that is not expected at this stage.

Actions #8

Updated by Evgeny Novikov almost 12 years ago

Alexey Khoroshilov wrote:

Evgeny Novikov wrote:

Hmm, I guess that using of the standard GCC preprocessor is very suitable for this issue.
Aspect defines are coming soon :)

I am not sure that standard GCC preprocessor is good enough. For example, it will apply and remove #define statements that is not expected at this stage.

Yes, I have tested the standard preprocessor just on aspects that don't insert defines and includes. But nevertheless, I guess, that it should be used. So, I can teach the "standard" preprocessor to deal with $define and $include directives instead of #define and #include respectively.

Actions #9

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Open to Resolved
Implemented in commit 2387e37 of feature-2958 branch. Following aspect preprocessor directives are tested:
  • @include
  • @define

(I had to to use '@' instead of '$' to avoid conflicts with advice body patterns (like $argN, $ret_type, etc.))
This is rather considerable feature. So, I'm going to test it (especially with including of kernel function model of #2707) and merge to master.
At best neither this feature nor fixes of #2760 and #2954 shouldn't affect the standard workflow anyway.

Actions #10

Updated by Evgeny Novikov almost 12 years ago

As usual header files aspect header files also need guards, so I had to test more aspect preprocessor directives:
  • @ifdef
  • @endif

They work well.

Actions #11

Updated by Evgeny Novikov almost 12 years ago

There is at least one lack in the current implementation. For instance, when there is:

#include <linux/blkdev.h>

in some aspect file, it's treated during aspect preprocessing as:
@include <linux/blkdev.h>

But this is affected by the standard built-in macro:
#define linux 1

that leads after all to an incorrect file name at other stages:
#include <1/blkdev.h>

I guess that the simplest workaround (but not universal, unfortunately) is to make explicit undefines of some standard built-in macros just at the aspectator preprocessing stage. I attached the full list of such built-in macros obtained on my machine. I think that just 'linux' and 'unix' macros may appear in path names. So I'll disable just these definitions.

Actions #12

Updated by Evgeny Novikov almost 12 years ago

One more lack is that model comments are removed during aspect preprocessing, but it has a simple fix: just add at the aspect preprocessing stage, option -C, that keeps comments.

Actions #13

Updated by Alexey Khoroshilov almost 12 years ago

Is it possible to turn off all built-in macros?

Actions #14

Updated by Evgeny Novikov almost 12 years ago

Alexey Khoroshilov wrote:

Is it possible to turn off all built-in macros?

After all, I have found a special option (http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Preprocessor-Options.html):

-undef
    Do not predefine any system-specific macros. The common predefined macros remain defined.

This option turns off almost all built-in macros except:
#define __STDC__ 1
#define __STDC_HOSTED__ 1

STDC_HOSTED cannot be turned off without GCC modification, but I guess that these two macros will not affect aspects. Just if somebody will use them in code, they will be expanded at the aspect preprocessing stage, but this isn't so bad.

Actions #15

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Open to Resolved

728e37f commit of feature-2958 fixed the issue. It's being tested and will be merged to master.

Actions #16

Updated by Evgeny Novikov almost 12 years ago

  • Published in build set to 7775bfe

Merged to the master branch in commit 7775bfe.

Actions #17

Updated by Evgeny Novikov almost 12 years ago

a18d35b of the master branch extracted a common Linux error processing model to a separate aspect (issue #2707).

Actions #18

Updated by Evgeny Novikov almost 12 years ago

QA successfully tested this commit. Alexey, close this feature if you find it to be well enough.

Actions #19

Updated by Alexey Khoroshilov almost 12 years ago

I would prefer to have something like demo for a set of newly implemented aspectator related features to inform all about them and to get more wide feedback.

Actions #20

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Resolved to Open

More one problem was found by night tests: during aspect preprocessing '\'s are eliminated from aspects. This makes gcc unhappy, when there is such the construction is used in aspects:

#define LDV_CHECK_AND_INCREASE(state, value) ldv_assert(state == value); \
                                             state++;

Actions #21

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Open to Resolved
  • Published in build changed from 7775bfe to 41718a0

Commit 41718a0 of the master branch fixed the issue in the following manner: it ignores all backslashes encountered in aspects. Because of this we cannot use backslashes in aspect defines, but still can use them in other cases. QA is running small tests now, big tests will be run at night.

Actions #22

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Resolved to Open
  • Priority changed from High to Urgent

More one issue was found by Denis Efremov. It turns out, that during aspect preprocessing modified preprocessor is called with options intended for a corresponding driver file compilation (preprocessing). This is totally incorrect since there may be such options that do not depend on presence of '#' directives and may affect on preprocessing. For instance:

-D name=definition
    The contents of definition are tokenized and processed as if they appeared during translation phase three in a `#define' directive. In particular, the definition will be truncated by embedded newline characters. 
    ...
-include file
    Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.

    If multiple -include options are given, the files are included in the order they appear on the command line.

Obvious fix is to call the modified preprocessor without options that come from drivers compilation. I don't know why we didn't catch this issue before...

Actions #23

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Open to Resolved
  • Published in build changed from 41718a0 to 983ce20

Commit 983ce20 of the master branch should fix the given issue. Wait for QA will test this commit.

Actions #24

Updated by Evgeny Novikov almost 12 years ago

Let's wait for today night test results.

Actions #25

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Resolved to Open

Again one more issue related! We use a hack to process typedefs at the beginning of function signatures, like:

around: call(#bool func(..))
{
...
}

But at present a line after '#' is considered as a special preprocessor line. In fact those lines can be placed just at the beginning of lines, so we can distinguish them. But it's a workaround since one can write:
around: call(
#bool func(..)
)
{
...
}

that also will lead to fail since line after '#' will be removed.
So, I guess to use an another character for the hack, e.g. '^':
around: call(^bool func(..))
{
...
}

Actions #26

Updated by Evgeny Novikov almost 12 years ago

  • Status changed from Open to Resolved
  • Published in build changed from 983ce20 to c371769

The given issue was fixed in commit c371769 of the master branch that is tested now.

Actions #27

Updated by Evgeny Novikov almost 12 years ago

I think, that we should close this issue, since it works rather stable. But I remember that after all I have to present all new features of aspect development.

Actions #28

Updated by Evgeny Novikov over 11 years ago

  • Project changed from Linux Driver Verification to C Instrumentation Framework
  • Category deleted (15)
Actions #29

Updated by Evgeny Novikov almost 11 years ago

  • Priority changed from Urgent to High

Should be closed at last.

Actions #30

Updated by Evgeny Novikov about 10 years ago

  • Status changed from Resolved to Closed

Close since there was not any objections.

Actions

Also available in: Atom PDF