Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HIS): add AP_CG_CYCLE his metric #67

Draft
wants to merge 5 commits into
base: wip/his-metrics
Choose a base branch
from

Conversation

AfonsoSantos96
Copy link
Member

@AfonsoSantos96 AfonsoSantos96 commented Oct 23, 2023

This PR introduces the feature of checking if there is any recursive function on the source files.
The existence of recursive functions is forbidden on HIS metrics.
For this check is used the cflow tool.

Checklist:

  • The changes generate no new warnings when building the project. If so, I have justified above.
  • I have run the CI checkers before submitting the PR to avoid unnecessary runs of the workflow.

Comment on lines +83 to +116
for file in files.files:
if file.endswith(".c"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be right. Since you check one file at a time, this will only detect functions that directly recurse on themselves, or maybe that recurse through some other function that is in the same source file. Also you don't considered static inline functions that can be defined in header files.

This check is defined by HIS metrics as for checking for "Call graph recursions". Therefore, the case when one function A calls a function B defined in a different source files, that itself calls function A, must be detected.

Copy link
Member

@danielRep danielRep Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good observation. However, after some testing the cflow tool can observe the following recursions for this example https://github.com/bao-project/bao-his-tests/tree/main/src/ap_ag_cycle :

$ cflow -l -Isrc/ap_ag_cycle/inc src/ap_ag_cycle/ap_ag_cycle1.c src/ap_ag_cycle/ap_ag_cycle2.c --no-cpp
{   0} main() <int main (void) at src/ap_ag_cycle/ap_ag_cycle1.c:65>:
{   1}     funcA() <void funcA (int val) at src/ap_ag_cycle/ap_ag_cycle1.c:10> (R):
{   2}         printf()
{   2}         funcA() <void funcA (int val) at src/ap_ag_cycle/ap_ag_cycle1.c:10> (recursive: see 2)
{   1}     funcB() <void funcB (int *val) at src/ap_ag_cycle/ap_ag_cycle1.c:29> (R):
{   2}         printf()
{   2}         funcC() <void funcC (void) at src/ap_ag_cycle/ap_ag_cycle1.c:42> (R):
{   3}             printf()
{   3}             funcD() <void funcD (void) at src/ap_ag_cycle/ap_ag_cycle1.c:47> (R):
{   4}                 printf()
{   4}                 funcB() <void funcB (int *val) at src/ap_ag_cycle/ap_ag_cycle1.c:29> (recursive: see 5)
{   1}     funcE() <void funcE (int *val) at src/ap_ag_cycle/ap_ag_cycle1.c:52>:
{   2}         printf()
{   2}         funcF()

The (R) notation marks functions that recursively call themselves. However, as I see from the output that detecting the case that you described (>function A calls a function B defined in a different source files, that itself calls function A) can't be detected. I still didn't found another alternatives for a tool to this particular case. I would keep looking.

@AfonsoSantos96 AfonsoSantos96 changed the base branch from wip/his_calls to wip/his-metrics October 27, 2023 15:13
@danielRep danielRep force-pushed the wip/his-metrics branch 5 times, most recently from c1452fe to 4a2edbb Compare February 27, 2024 17:00
@danielRep danielRep changed the title feat(HIS): add detection of recursive functions feat(HIS): add AP_CG_CYCLE his metric Feb 29, 2024
@danielRep danielRep marked this pull request as draft February 29, 2024 13:41
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
Signed-off-by: Afonso Santos <afomms@gmail.com>
@danielRep danielRep force-pushed the feat/his_recursive_functions branch from cfdca74 to 240d0c0 Compare March 8, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants