Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/static_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ impl ContextObject for DummyContextObject {
fn get_remaining(&self) -> u64 {
0
}

fn get_nesting_level(&self) -> u32 {
0
}
}

/// Result of the executable analysis
Expand Down
6 changes: 5 additions & 1 deletion src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ pub trait ContextObject {
fn consume(&mut self, amount: u64);
/// Get the number of remaining instructions allowed
fn get_remaining(&self) -> u64;
/// Get the current nesting level
fn get_nesting_level(&self) -> u32;
}

/// Statistic of taken branches (from a recorded trace)
Expand Down Expand Up @@ -314,6 +316,7 @@ impl<'a, C: ContextObject> EbpfVm<'a, C> {
stack_len: usize,
) -> Self {
let config = loader.get_config();
let _nesting_level = context_object.get_nesting_level();
let mut registers = [0u64; 12];
registers[ebpf::FRAME_PTR_REG] =
ebpf::MM_STACK_START.saturating_add(if sbpf_version.dynamic_stack_frames() {
Expand Down Expand Up @@ -342,7 +345,8 @@ impl<'a, C: ContextObject> EbpfVm<'a, C> {
#[cfg(feature = "debugger")]
debug_port: std::env::var("VM_DEBUG_PORT")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of pulling program runtime concepts down here just for debugging. So I would be in favor of instead setting debug_port selectively in the agave repo.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: Here's another approach that basically allows passing an offset to the debug_port from runtime directly when executing a program:
anza-xyz/agave@e241209
Then add this value to the debug_port:
main...procdump:sbpf:debugger_port_offset

Something in this direction? A CPI just needs another debug port to listen on as it takes place in the middle of the ongoing debugging session. If this is in place CPIs can be happily step-debugged.

.ok()
.and_then(|v| v.parse::<u16>().ok()),
.and_then(|v| v.parse::<u16>().ok())
.map(|p| p + _nesting_level.saturating_sub(1) as u16), // Advance port with level
register_trace: Vec::default(),
}
}
Expand Down
4 changes: 4 additions & 0 deletions test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ impl ContextObject for TestContextObject {
fn get_remaining(&self) -> u64 {
self.remaining
}

fn get_nesting_level(&self) -> u32 {
0
}
}

impl TestContextObject {
Expand Down