Skip to content

Support displaying more-complex syscall arguments#2648

Merged
stevenengler merged 4 commits intoshadow:mainfrom
stevenengler:extended-strace-logging
Jan 10, 2023
Merged

Support displaying more-complex syscall arguments#2648
stevenengler merged 4 commits intoshadow:mainfrom
stevenengler:extended-strace-logging

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

In order to display syscall arguments in strace logging, we sometimes need to know the values of multiple syscall arguments. For example to display the byte buffer for write(), we need to know both const void *buf and size_t count. Shadow previously would just read bytes until a nul or a memory access error, but this wasn't correct since the buffer is often not nul-terminated.

To print a byte buffer like the one in write(), instead of using *const libc::c_char in the log_syscall() macro, we now have two types SyscallStringArg and SyscallBufferArg<const LEN_INDEX: usize> depending on whether the syscall takes a buffer (as in write()) or a nul-terminated string (as in open()). The constant generic in SyscallBufferArg allows us to specify the index of the count argument. This is a little weird, but allows us to continue using rust's type system for specifying how to display syscall arguments.

In the future we can use the same method to display other types of syscall arguments, like socket addresses or socket/ioctl options.

@stevenengler stevenengler self-assigned this Jan 9, 2023
@github-actions github-actions bot added Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable labels Jan 9, 2023
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 9, 2023

Codecov Report

Base: 67.91% // Head: 68.02% // Increases project coverage by +0.11% 🎉

Coverage data is based on head (b798bff) compared to base (e81eab7).
Patch coverage: 79.16% of modified lines in pull request are covered.

❗ Current head b798bff differs from pull request most recent head 4160c79. Consider uploading reports for the commit 4160c79 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2648      +/-   ##
==========================================
+ Coverage   67.91%   68.02%   +0.11%     
==========================================
  Files         202      201       -1     
  Lines       29920    29880      -40     
  Branches     5832     5819      -13     
==========================================
+ Hits        20320    20326       +6     
+ Misses       4982     4924      -58     
- Partials     4618     4630      +12     
Flag Coverage Δ
tests 68.02% <79.16%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/host/syscall/handler/file.rs 80.00% <0.00%> (ø)
src/main/host/syscall/handler/socket.rs 68.30% <50.00%> (-0.40%) ⬇️
src/main/host/syscall/handler/unistd.rs 73.12% <75.00%> (+6.71%) ⬆️
src/main/host/syscall/type_formatting.rs 79.24% <78.26%> (-2.01%) ⬇️
src/main/host/syscall/formatter.rs 80.18% <94.44%> (+1.91%) ⬆️
src/main/host/syscall/handler/ioctl.rs 57.14% <0.00%> (-2.86%) ⬇️
src/main/core/scheduler/pools/bounded.rs 74.50% <0.00%> (-1.97%) ⬇️
src/lib/shadow-shim-helper-rs/src/shim_shmem.rs 74.91% <0.00%> (-1.91%) ⬇️
src/main/core/scheduler/thread_per_core.rs 89.51% <0.00%> (-0.70%) ⬇️
... and 21 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@stevenengler stevenengler force-pushed the extended-strace-logging branch from bbebc64 to b798bff Compare January 10, 2023 02:06
@stevenengler stevenengler force-pushed the extended-strace-logging branch from b798bff to 4160c79 Compare January 10, 2023 17:05
@stevenengler stevenengler merged commit eccbd02 into shadow:main Jan 10, 2023
@stevenengler stevenengler deleted the extended-strace-logging branch January 10, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants