Skip to main content

DebuggerSession

Struct DebuggerSession 

Source
pub struct DebuggerSession { /* private fields */ }
Expand description

Debugger session

与 Evaluator 共享同一个 DebuggerState(Rc<RefCell<>>), 因此命令对断点/执行模式的修改立即对求值器生效。 求值器状态(变量、调用栈)在暂停回调时通过 &mut Evaluator 传入。

Implementations§

Source§

impl DebuggerSession

Source

pub fn new(state: Rc<RefCell<DebuggerState>>) -> Self

Create a new debugger session around a shared debugger state

Source

pub fn set_source(&mut self, source: String, file: String)

Set the source code for listing

Source

pub fn set_breakable_lines(&mut self, lines: HashSet<usize>)

注入可命中的语句起始行集合(供 break N 校验)

Source

pub fn shared_state(&self) -> Rc<RefCell<DebuggerState>>

共享的调试器状态(供宿主调用 Evaluator::attach_debugger)

Source

pub fn is_terminated(&self) -> bool

用户是否已通过 quit 终止程序(宿主据此把 DebugPause 排除出错误处理)

Source

pub fn start(&mut self)

Start the debugger session

Source

pub fn run_pause_loop(&mut self, ev: &mut Evaluator) -> bool

暂停时的交互循环:打印位置与源码上下文,逐条读取命令直到继续/退出。

返回 true 表示终止程序(求值器将以 DebugPause 传播)。 stdin 读到 EOF 时停用调试器并放行到程序结束,避免无限 EOF 循环。

Source

pub fn handle_command( &mut self, ev: &mut Evaluator, cmd: &str, ) -> (String, CommandAction)

Handle a debugger command, returning (message, action)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.