Skip to content

Caching information about definitions of differing macros#333

Merged
viktormalik merged 3 commits intodiffkemp:masterfrom
PLukas2018:def-of-diff-macros
May 23, 2024
Merged

Caching information about definitions of differing macros#333
viktormalik merged 3 commits intodiffkemp:masterfrom
PLukas2018:def-of-diff-macros

Conversation

@PLukas2018
Copy link
Copy Markdown
Collaborator

First part of commits from #314 .
This PR adds:

  • caching of Syntax difference kind (because there can be multiple kinds of syntax differences - macro, assembly, macro-function, function-macro) -- I think it could be useful to have this saved in Python, personally I used this information for visualisation of function-macro/macro-function differences in the result viewer, but right now I am thinking it is not absolutely necessary because I should be able to deduce this based on names of the differing 'objects', but I am still thinking it could be useful to have it.
  • caching of the definition of differing/last macro in Syntax difference -- this is useful for showing code/differences of the macro in the result viewer.

I will reference comments/questions from #314 which are relevant to this PR.

@PLukas2018 PLukas2018 requested a review from viktormalik April 25, 2024 10:00
Copy link
Copy Markdown
Collaborator

@viktormalik viktormalik left a comment

Choose a reason for hiding this comment

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

LGTM! Just a couple of nits and questions to clear up some things.

The `kind` informs about a kind of difference
(macro, function-macro, macro-function, assembly).
@PLukas2018 PLukas2018 force-pushed the def-of-diff-macros branch from dfb7cfa to 39c51ae Compare May 15, 2024 21:30
Create `CodeLocation` struct for storing information about
an 'object' code location (filename and line).
This struct could be also used for storing info about definition
of differing macro in SyntaxDifference, function definitions,
call locations, ...

Also changed the type of line to unsigned which makes more sense.
The Simpll library now contains addition information
for `SyntaxDifference` (respectively for macro difference) about
definition of differing macros.
The information is then stored from simpll yaml output
to ComparisonGraph so it can be used later.
This info will be useful for eg. visualising the difference
in the code of macros in the result viewer.
@PLukas2018 PLukas2018 force-pushed the def-of-diff-macros branch from 39c51ae to 33abbc2 Compare May 16, 2024 14:29
Copy link
Copy Markdown
Collaborator

@viktormalik viktormalik left a comment

Choose a reason for hiding this comment

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

LGTM!

PLukas2018 added a commit to PLukas2018/diffkemp that referenced this pull request May 22, 2024
Eg. from this snippet of call stack

```
free_pages_prepare at mm/page_alloc.c:1273
PAGE_FLAGS_CHECK_AT_PREP (macro) at mm/page_alloc.c:1049
NR_PAGEFLAGS (macro) at ./include/linux/page-flags.h:759
```

we are able to extract that `NR_PAGEFLAGS` is used from macro
`PAGE_FLAGS_CHECK_AT_PREP` which is located in
`./include/linux/page-flags.h` file and starts on line `759`.
Note: If the `PAGE_FLAGS_CHECK_AT_PREP` was function the line
`759` would meant line on which the `NR_PAGEFLAGS` macro is used,
but because `PAGE_FLAGS_CHECK_AT_PREP` is macro and not a function
it means line where the `PAGE_FLAGS_CHECK_AT_PREP` macro definition
starts.

For the last/differing macro in the call stack it is not possible to
extract information about its definition from the call stack, but it
can be extracted from `SyntaxDiff` in `ComparisonGraph` which includes
info about the definition of differing macros from the call stacks
(see PR diffkemp#333 for more info).
@viktormalik viktormalik merged commit 4b94c9a into diffkemp:master May 23, 2024
PLukas2018 added a commit to PLukas2018/diffkemp that referenced this pull request May 23, 2024
Eg. from this snippet of call stack

```
free_pages_prepare at mm/page_alloc.c:1273
PAGE_FLAGS_CHECK_AT_PREP (macro) at mm/page_alloc.c:1049
NR_PAGEFLAGS (macro) at ./include/linux/page-flags.h:759
```

we are able to extract that `NR_PAGEFLAGS` is used from macro
`PAGE_FLAGS_CHECK_AT_PREP` which is located in
`./include/linux/page-flags.h` file and starts on line `759`.
Note: If the `PAGE_FLAGS_CHECK_AT_PREP` was function the line
`759` would meant line on which the `NR_PAGEFLAGS` macro is used,
but because `PAGE_FLAGS_CHECK_AT_PREP` is macro and not a function
it means line where the `PAGE_FLAGS_CHECK_AT_PREP` macro definition
starts.

For the last/differing macro in the call stack it is not possible to
extract information about its definition from the call stack, but it
can be extracted from `SyntaxDiff` in `ComparisonGraph` which includes
info about the definition of differing macros from the call stacks
(see PR diffkemp#333 for more info).
@PLukas2018 PLukas2018 deleted the def-of-diff-macros branch May 23, 2024 12:44
viktormalik pushed a commit that referenced this pull request May 23, 2024
Eg. from this snippet of call stack

```
free_pages_prepare at mm/page_alloc.c:1273
PAGE_FLAGS_CHECK_AT_PREP (macro) at mm/page_alloc.c:1049
NR_PAGEFLAGS (macro) at ./include/linux/page-flags.h:759
```

we are able to extract that `NR_PAGEFLAGS` is used from macro
`PAGE_FLAGS_CHECK_AT_PREP` which is located in
`./include/linux/page-flags.h` file and starts on line `759`.
Note: If the `PAGE_FLAGS_CHECK_AT_PREP` was function the line
`759` would meant line on which the `NR_PAGEFLAGS` macro is used,
but because `PAGE_FLAGS_CHECK_AT_PREP` is macro and not a function
it means line where the `PAGE_FLAGS_CHECK_AT_PREP` macro definition
starts.

For the last/differing macro in the call stack it is not possible to
extract information about its definition from the call stack, but it
can be extracted from `SyntaxDiff` in `ComparisonGraph` which includes
info about the definition of differing macros from the call stacks
(see PR #333 for more info).
PLukas2018 added a commit to PLukas2018/diffkemp that referenced this pull request Aug 11, 2025
Eg. from this snippet of call stack

```
free_pages_prepare at mm/page_alloc.c:1273
PAGE_FLAGS_CHECK_AT_PREP (macro) at mm/page_alloc.c:1049
NR_PAGEFLAGS (macro) at ./include/linux/page-flags.h:759
```

we are able to extract that `NR_PAGEFLAGS` is used from macro
`PAGE_FLAGS_CHECK_AT_PREP` which is located in
`./include/linux/page-flags.h` file and starts on line `759`.
Note: If the `PAGE_FLAGS_CHECK_AT_PREP` was function the line
`759` would meant line on which the `NR_PAGEFLAGS` macro is used,
but because `PAGE_FLAGS_CHECK_AT_PREP` is macro and not a function
it means line where the `PAGE_FLAGS_CHECK_AT_PREP` macro definition
starts.

For the last/differing macro in the call stack it is not possible to
extract information about its definition from the call stack, but it
can be extracted from `SyntaxDiff` in `ComparisonGraph` which includes
info about the definition of differing macros from the call stacks
(see PR diffkemp#333 for more info).
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.

2 participants