Skip to content

Commit

Permalink
Bump max frame_depth (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored Sep 10, 2019
1 parent d0949a2 commit 973163b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub const FIRST_SCRATCH_REG: usize = 6;
/// Number of scratch registers
pub const SCRATCH_REGS: usize = 4;
/// Max BPF to BPF call depth
pub const MAX_CALL_DEPTH: usize = 10;
pub const MAX_CALL_DEPTH: usize = 20;
/// ELF dump instruction offset
/// Instruction numbers typically start at 29 in the ELF dump, use this offset
/// when reporting so that trace aligns with the dump.
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ impl CallFrames {

/// Push a frame
fn push(&mut self, saved_reg: &[u64], return_ptr: usize) -> Result<u64, Error> {
if self.frame + 1 >= ebpf::MAX_CALL_DEPTH {
if self.frame + 1 >= self.frames.len() {
return Err(Error::new(ErrorKind::Other,
format!("Exceeded max BPF to BPF call depth of {:?}",
ebpf::MAX_CALL_DEPTH)));
self.frames.len())));
}
self.frames[self.frame].saved_reg[..].copy_from_slice(saved_reg);
self.frames[self.frame].return_ptr = return_ptr;
Expand Down Expand Up @@ -869,7 +869,7 @@ mod tests {
let mut frames = CallFrames::new(DEPTH, SIZE);
let mut ptrs: Vec<MemoryRegion> = Vec::new();
for i in 0..DEPTH - 1 {
let registers = vec![i as u64; 5];
let registers = vec![i as u64; SIZE];
assert_eq!(frames.get_frame_index(), i);
ptrs.push(frames.get_stacks()[i].clone());
assert_eq!(ptrs[i].len, SIZE as u64);
Expand All @@ -881,7 +881,7 @@ mod tests {
assert!(!(ptrs[i].addr_vm <= new_ptrs[i+1].addr_vm && new_ptrs[i+1].addr_vm < ptrs[i].addr_vm + ptrs[i].len));
}
let i = DEPTH - 1;
let registers = vec![i as u64; 5];
let registers = vec![i as u64; SIZE];
assert_eq!(frames.get_frame_index(), i);
ptrs.push(frames.get_stacks()[i].clone());

Expand Down

0 comments on commit 973163b

Please sign in to comment.