-
Notifications
You must be signed in to change notification settings - Fork 298
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
Add support for stack argument #773
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
@tamird |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one nit.
The rest looks good. I like the tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Co-authored-by: vadorovsky <[email protected]>
@liyan-ah, this pull request is now in conflict and requires a rebase. |
@tamird @vadorovsky |
|
||
//read argument, and send event | ||
fn try_stack_argument(ctx: ProbeContext) -> Result<i32, i64> { | ||
let _ = ARGS.insert(&0, &ctx.arg(0).ok_or(255)?, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid these _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There would be warning if no let _
.
warning: unused `Result` that must be used
--> test/integration-ebpf/src/stack_argument.rs:23:5
|
23 | ARGS.insert(&0, &ctx.arg(0).ok_or(255)?, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
23 | let _ = ARGS.insert(&0, &ctx.arg(0).ok_or(255)?, 0);
| +++++++
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the proper thing to do is handle these errors rather than silently ignore them. You probably want to return from the program on any error.
} | ||
} | ||
|
||
//read argument, and send event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what event? I don't understand this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment modified.
rustfmt.toml
Outdated
@@ -1,3 +1,4 @@ | |||
edition = "2021" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
HashMap::try_from(bpf.take_map("ARGS").unwrap()).unwrap(); | ||
trigger_stack_argument(0, 1, 2, 3, 4, 5, 6, 7); | ||
|
||
tokio::time::sleep(std::time::Duration::from_millis(100)).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we sleeping here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sleeping could be removed, and it works okay in my local environment. The sleeping
is added just as referred in integration-test/src/tests/log.rs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
a_3: u64, | ||
a_4: u64, | ||
a_5: u64, | ||
//in x86_64, from arg6, stack_argument would be used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please write a proper sentence and add a space after the //
.
can you add a citation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
citation added.
//read argument, and send event | ||
fn try_stack_argument(ctx: ProbeContext) -> Result<i32, i64> { | ||
let _ = ARGS.insert(&0, &ctx.arg(0).ok_or(255)?, 0); | ||
let _ = ARGS.insert(&1, &ctx.arg(1).ok_or(255)?, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the story with these .ok_or(255)? I don't understand why this function returns a Result where the only possible "error" is 255
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no means for 255, just to make sure the test in stack_argument
would failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but I do not think this is an appropriate thing to do. If these methods fail, we should just return from this program.
assert_eq!(args_map.keys().count(), 8); | ||
for iter in args_map.iter() { | ||
let iter_v = iter.unwrap(); | ||
assert_eq!(iter_v.0 as u64, iter_v.1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please destructure instead of these point accesses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this. Any problems with map.iter()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let (key, value) = iter.unwrap()
@liyan-ah, this pull request is now in conflict and requires a rebase. |
Please test this locally before pinging again. |
@tamird |
@tamird |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm running out of patience with this PR. Every revision is ridden with bugs. I'm inclined to stop reviewing this TBH.
|
||
//read argument, and send event | ||
fn try_stack_argument(ctx: ProbeContext) -> Result<i32, i64> { | ||
let _ = ARGS.insert(&0, &ctx.arg(0).ok_or(255)?, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the proper thing to do is handle these errors rather than silently ignore them. You probably want to return from the program on any error.
//read argument, and send event | ||
fn try_stack_argument(ctx: ProbeContext) -> Result<i32, i64> { | ||
let _ = ARGS.insert(&0, &ctx.arg(0).ok_or(255)?, 0); | ||
let _ = ARGS.insert(&1, &ctx.arg(1).ok_or(255)?, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but I do not think this is an appropriate thing to do. If these methods fail, we should just return from this program.
@@ -10,6 +10,7 @@ assert_matches = { workspace = true } | |||
aya = { workspace = true } | |||
aya-log = { workspace = true } | |||
aya-obj = { workspace = true } | |||
bytes = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this?
// Notice that other languages, like Golang, or in other archs, like aarch64, may | ||
// have different convention rules. | ||
_a_6: u64, | ||
_a_7: i64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this a different type?
assert_eq!(args_map.keys().count(), 8); | ||
for iter in args_map.iter() { | ||
let iter_v = iter.unwrap(); | ||
assert_eq!(iter_v.0 as u64, iter_v.1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let (key, value) = iter.unwrap()
break; | ||
} | ||
if stack { | ||
let _ = ARGS.insert(&arg, &ctx.arg(arg as usize).ok_or(255)?, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be stack_arg?
Sorry about that. From my view, the mainly errors are |
@liyan-ah, this pull request is now in conflict and requires a rebase. |
Would reopen when I get some spare time. |
Add support for stack argument
related to #659