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

lib/syscall_shim: Extend prsyscall (print structs, ...) #836

Conversation

marcrittinghaus
Copy link
Member

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.pl on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): [N/A]
  • Platform(s): [N/A]
  • Application(s): [N/A]

Additional configuration

Description of changes

This PR adds a number of features to the strace-like printing in lib/syscall_shim (prsyscall). New features are:

  • Printing of structs
    image
    image
    Structs can also be nested. The number and selection of fields that should be printed is specified per struct definition.
  • Printing of PT_OUT-values only on success
    Especially, if structs are printed, it can become confusing (and also cause crashes) if a syscall fails and the uninitialized target struct is printed. The PR changes behavior so that values are only printed on success. On failure, only the type and virtual address are printed.
  • Add PT_OCTAL
  • Add 0x prefix for PT_HEX to avoid confusion with decimal values
  • Add printing for further syscalls and their dependent types

Have fun!

Previously, we are printing buffers and output strings also when the
call fails. However, in that case it will usually contain no meaningful
value so we reduce trace output by just printing the buffer's target
address.

Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: TRAILING_SEMICOLON
Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
There are already types for decimal and hexadecimal printing.
This commit adds a type for octals.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Currently, it is hard to know if a value is a hexadecimal or decimal
number if there are no letters in the output. This commit adds the
hex prefix 0x to avoid the confusion.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
This commit adds macros for printing selected members of
struct types in the prsyscall output just like strace. The PT_STRUCT
macro takes the struct's name to form a new parameter type name.
The PR_STRUCT macro prints the fields specified in the var args. Nested
printing of struct fields members is supported for structs pointers as
well as for embedded structs. Whenever fields that are usually pointers
(e.g., PT_CHARP or PT_STRUCT) are embedded, the `PT_SVAL` flag must
be specified.

Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
This commit adds a definition of the timespec struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
@marcrittinghaus marcrittinghaus added kind/enhancement New feature or request area/lib Internal Unikraft Microlibrary lib/syscall_shim lang/c Issues or PRs to do with C/C++ topic/syscall Related to syscalls labels Apr 14, 2023
@marcrittinghaus marcrittinghaus requested a review from a team as a code owner April 14, 2023 16:51
@skuenzer skuenzer assigned skuenzer and unassigned nderjung Apr 17, 2023
@razvand razvand requested review from razvand and removed request for a team April 25, 2023 09:50
@razvand razvand added this to the v0.13.0 (Atlas) milestone Apr 25, 2023
Copy link
Contributor

@razvand razvand left a comment

Choose a reason for hiding this comment

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

Hi, @marcrittinghaus. I tested it and it works. Please use Add instead of add in one of the commit message you created. Then it's all go.

@marcrittinghaus
Copy link
Member Author

@razvand,

thanks for pointing that out. Fixed.

@razvand razvand self-requested a review April 25, 2023 11:45
Copy link
Contributor

@razvand razvand left a comment

Choose a reason for hiding this comment

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

Thanks, @marcrittinghaus.

Reviewed-by: Razvan Deaconescu razvand@unikraft.io

Copy link
Member

@craciunoiuc craciunoiuc left a comment

Choose a reason for hiding this comment

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

All good here. Thanks!

Reviewed-by: Cezar Craciunoiu cezar.craciunoiu@unikraft.io

This commit adds a definition of the stat struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
@marcrittinghaus
Copy link
Member Author

@craciunoiuc,

Thanks for mentioning the dependency on posix-sysinfo. I made the definition of the utsname struct optional, depending on the inclusion of the library.

@craciunoiuc
Copy link
Member

oh so you actually fixed it here, whoops, I thought it would be done in another PR

unikraft-bot pushed a commit that referenced this pull request Apr 26, 2023
Currently, it is hard to know if a value is a hexadecimal or decimal
number if there are no letters in the output. This commit adds the
hex prefix 0x to avoid the confusion.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
unikraft-bot pushed a commit that referenced this pull request Apr 26, 2023
This commit adds macros for printing selected members of
struct types in the prsyscall output just like strace. The PT_STRUCT
macro takes the struct's name to form a new parameter type name.
The PR_STRUCT macro prints the fields specified in the var args. Nested
printing of struct fields members is supported for structs pointers as
well as for embedded structs. Whenever fields that are usually pointers
(e.g., PT_CHARP or PT_STRUCT) are embedded, the `PT_SVAL` flag must
be specified.

Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
unikraft-bot pushed a commit that referenced this pull request Apr 26, 2023
This commit adds a definition of the timespec struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
unikraft-bot pushed a commit that referenced this pull request Apr 26, 2023
This commit adds a definition of the stat struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
unikraft-bot pushed a commit that referenced this pull request Apr 26, 2023
This commit adds a definition of the utsname struct
and the uname syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
unikraft-bot pushed a commit that referenced this pull request Apr 26, 2023
This commit adds a definition of the pread64 syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
unikraft-bot pushed a commit that referenced this pull request Apr 26, 2023
This commit adds a definition of the (F|R|W|X)_OK flags
and the access syscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
@unikraft-bot unikraft-bot added the ci/merged Merged by CI label Apr 26, 2023
@marcrittinghaus marcrittinghaus deleted the mritting/pr_prsyscall_struct branch May 26, 2023 11:06
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
Previously, we are printing buffers and output strings also when the
call fails. However, in that case it will usually contain no meaningful
value so we reduce trace output by just printing the buffer's target
address.

Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: TRAILING_SEMICOLON
Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
There are already types for decimal and hexadecimal printing.
This commit adds a type for octals.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
Currently, it is hard to know if a value is a hexadecimal or decimal
number if there are no letters in the output. This commit adds the
hex prefix 0x to avoid the confusion.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
This commit adds macros for printing selected members of
struct types in the prsyscall output just like strace. The PT_STRUCT
macro takes the struct's name to form a new parameter type name.
The PR_STRUCT macro prints the fields specified in the var args. Nested
printing of struct fields members is supported for structs pointers as
well as for embedded structs. Whenever fields that are usually pointers
(e.g., PT_CHARP or PT_STRUCT) are embedded, the `PT_SVAL` flag must
be specified.

Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
This commit adds a definition of the timespec struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
This commit adds a definition of the stat struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
This commit adds a definition of the utsname struct
and the uname syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
This commit adds a definition of the pread64 syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
StefanJum pushed a commit to unikraft-upb/unikraft that referenced this pull request Jun 5, 2023
This commit adds a definition of the (F|R|W|X)_OK flags
and the access syscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
Previously, we are printing buffers and output strings also when the
call fails. However, in that case it will usually contain no meaningful
value so we reduce trace output by just printing the buffer's target
address.

Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: TRAILING_SEMICOLON
Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
There are already types for decimal and hexadecimal printing.
This commit adds a type for octals.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
Currently, it is hard to know if a value is a hexadecimal or decimal
number if there are no letters in the output. This commit adds the
hex prefix 0x to avoid the confusion.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
This commit adds macros for printing selected members of
struct types in the prsyscall output just like strace. The PT_STRUCT
macro takes the struct's name to form a new parameter type name.
The PR_STRUCT macro prints the fields specified in the var args. Nested
printing of struct fields members is supported for structs pointers as
well as for embedded structs. Whenever fields that are usually pointers
(e.g., PT_CHARP or PT_STRUCT) are embedded, the `PT_SVAL` flag must
be specified.

Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
This commit adds a definition of the timespec struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
This commit adds a definition of the stat struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
This commit adds a definition of the utsname struct
and the uname syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
This commit adds a definition of the pread64 syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
razvanvirtan pushed a commit to razvanvirtan/unikraft that referenced this pull request Jun 6, 2023
This commit adds a definition of the (F|R|W|X)_OK flags
and the access syscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: unikraft#836
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary ci/merged Merged by CI kind/enhancement New feature or request lang/c Issues or PRs to do with C/C++ lib/syscall_shim topic/syscall Related to syscalls
Projects
Status: Done!
Development

Successfully merging this pull request may close these issues.

7 participants