Luiz-Monad / aspectc

Automatically exported from code.google.com/p/aspectc
0 stars 0 forks source link

Around, After, Before cannot accept function pointers. #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. In a C file, write code like this:
int (*pt2Fun)(float, char, char) = NULL;   //define function prt.

pt2Fun = (Function);   //give pointer an address

*pt2Fun(float, char, char)   //call function with the pointer.

2. Write ACC file that will execute some code before and after a call to 
this function
3. Compile and run

What is the expected output? What do you see instead?
It should execute code before and after a call to the function, both 
through function pointer, and direct call.

Currently, ACC will ONLY output things when a direct call to the function 
is executed. 

What version of the product are you using? On what operating system?
any

Please provide any additional information below.

Original description: 
From: Janne 

Greetings

I'm a research assistant at the Aalto University School of Science and
Technology (former Helsinki University of Technology), and I'm working in a
project called LIME2 (LightweIght formal Methods for distributed component-
based
Embedded systems). We have been using AspeCt-oriented C as a part of our
toolchain to implement something called "interface monitors" for C programs
(more information available in the project website at
http://www.tcs.hut.fi/Research/Logic/LIME2/), and now recently ran into a
problem with ACC ignoring function calls made through function pointers
completely.

The problem appears as functions called via function pointers (at least 
when the
values for these pointers are generated during the program execution) not
getting instrumented properly, so "around" -advices for these functions are 
not
executed with the functions at all. Since there are no warnings or errors 
during
the compilation process and ACC is still under development, I assume this 
is
a missing feature and would thus like to inquire what are your possible 
plans on
implementing the support for function pointers in your tool. If this is an
actual bug you were previously unaware of (I tried checking your bugzilla 
but
the page seems to be unavailable, so at least the link on your web site,
http://www.msrg.utoronto.ca/bugzilla/, seems to be broken at the moment), 
please
let me know and I'd be happy to provide you with a program that reproduces 
the
issue.

Original issue reported on code.google.com by lzmliz...@gmail.com on 13 May 2010 at 7:40

GoogleCodeExporter commented 8 years ago
Test Case:
see the atteched file. m.c and mm.acc

to run the test simply type:
>tacc m.c mm.acc     //tacc compile m.c and mm.acc
>./a.out

Expected Output:

calling foo
 a is '2'
calling foo
 a is '3'
since function foo is called by the function pointer pt2Fun.

Actual Output:

 a is '2'
calling foo
 a is '3'

The first call of function foo is not taking in consider by the compiler.
Therefore, there is an error occur. 

Original comment by kedeng1...@gmail.com on 13 May 2010 at 9:38

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by lzmliz...@gmail.com on 14 May 2010 at 3:56

GoogleCodeExporter commented 8 years ago
This problem can be resolved by callp() instead of call(). callp() is for 
function 
pointers and call() is for direct call to the function.

If you want to execute code in ACC when a function is called through both 
function 
pointer and direct calls, you can use lines like:

before(): callp(int foo(int)) || call(int foo(int))

to solve the problem.

Original comment by lzmliz...@gmail.com on 18 May 2010 at 8:36