add further annotation.

pull/773/head
pdliyan 2 years ago
parent 31fb700ad5
commit 581225277e

@ -18,7 +18,7 @@ pub fn test_stack_argument(ctx: ProbeContext) -> i32 {
}
}
//read argument, and send event
// read function arguments, and set to map.
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);

@ -20,7 +20,12 @@ pub extern "C" fn trigger_stack_argument(
a_3: u64,
a_4: u64,
a_5: u64,
//in x86_64, from arg6, stack_argument would be used
// in x86_64 arch, for C language, the first 6 integer or pointer argument
// would be passed in registers. The excess arguments would be passed on the stack.
// This conculusion and further reference could be found from:
// https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI
// Notice that other languages, like Golang, or in other archs, like aarch64, may
// have different convention rules.
a_6: u64,
a_7: i64,
) {
@ -43,7 +48,6 @@ async fn stack_argument() {
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;
assert_eq!(args_map.keys().count(), 8);
for iter in args_map.iter() {
let iter_v = iter.unwrap();

Loading…
Cancel
Save