MCPcopy Create free account
hub / github.com/acking-you/static_flow / capture_stack

Method capture_stack

crates/backend/src/memory_profiler.rs:676–703  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

674 }
675
676 fn capture_stack(&self) -> StackKey {
677 let mut key = StackKey::default();
678 let mut index = 0_usize;
679 let mut skip = self.stack_skip;
680 let max_depth = self.max_stack_depth.min(MAX_STACK_DEPTH);
681 // SAFETY: trace_unsynchronized is safe for sampling the current
682 // thread's stack as long as we avoid concurrent symbolization here.
683 unsafe {
684 trace_unsynchronized(|frame| {
685 let ip = frame.ip() as usize;
686 if ip == 0 {
687 return true;
688 }
689 if skip > 0 {
690 skip -= 1;
691 return true;
692 }
693 if index >= max_depth {
694 return false;
695 }
696 key.frames[index] = ip;
697 index += 1;
698 true
699 });
700 }
701 key.len = index as u8;
702 key
703 }
704
705 fn resolve_symbol(&self, addr: usize) -> String {
706 if let Some(existing) = self.symbols.get(&addr) {

Callers 1

record_allocationMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected