Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- run: cargo test --release

check:
name: Check formatting, linter and unused dependencies
name: Check formatting, linter, docs and unused dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down
35 changes: 25 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2024"

[dependencies]
anyhow = "1.0"
cairo-annotations = { version = "0.8.0", features = ["cairo-lang"] }
cairo-annotations = { git = "https://github.com/software-mansion/cairo-annotations", rev = "ff307d9f0ab4c6514b90698e3ce29d91f8e0ce56", features = ["cairo-lang"] }
cairo-lang-casm = "2.17.0"
cairo-lang-sierra = "2.17.0"
cairo-lang-sierra-to-casm = "2.17.0"
Expand Down
33 changes: 27 additions & 6 deletions src/debugger/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ use cairo_annotations::annotations::debugger::DebuggerAnnotationsV1 as Functions
use cairo_annotations::annotations::profiler::{
FunctionName, ProfilerAnnotationsV1 as SierraFunctionNames,
};
use cairo_annotations::annotations::type_names::{
EnumInfo, SierraTypeId, StructInfo, TypeNamesAnnotationsV1 as TypeNames,
};
use cairo_annotations::{MappingResult, map_pc_to_sierra_statement_id};
use cairo_lang_sierra::extensions::core::CoreConcreteLibfunc;
use cairo_lang_sierra::extensions::core::{CoreConcreteLibfunc, CoreTypeConcrete};
use cairo_lang_sierra::extensions::lib_func::BranchSignature;
use cairo_lang_sierra::extensions::types::TypeInfo;
use cairo_lang_sierra::extensions::{ConcreteLibfunc, ConcreteType};
Expand Down Expand Up @@ -52,6 +55,7 @@ struct SierraContext {
program_registry_info: ProgramRegistryInfo,
code_locations: SierraCodeLocations,
function_names: SierraFunctionNames,
type_names: Option<TypeNames>,
}

impl Context {
Expand All @@ -75,6 +79,7 @@ impl Context {
let function_names = SierraFunctionNames::try_from_debug_info(&debug_info).context(
"statements functions debug info is missing - enable generating it in your Scarb.toml",
)?;
let type_names = TypeNames::try_from_debug_info(&debug_info).ok();

// TODO(#61)
let casm_debug_info =
Expand All @@ -87,8 +92,13 @@ impl Context {
#[cfg(feature = "dev")]
let labels = readable_sierra_ids::extract_labels(&program);

let sierra_context =
SierraContext { program, program_registry_info, code_locations, function_names };
let sierra_context = SierraContext {
program,
program_registry_info,
code_locations,
function_names,
type_names,
};

Ok(Self {
#[cfg(feature = "dev")]
Expand Down Expand Up @@ -233,14 +243,25 @@ impl Context {
&branch_signature.vars[var_index].ty
}

#[expect(dead_code)]
pub fn type_size(&self, type_id: &ConcreteTypeId) -> i16 {
pub fn type_size(&self, type_id: &ConcreteTypeId) -> usize {
*self
.sierra_context
.program_registry_info
.type_sizes
.get(type_id)
.expect("type id is expected to exist in type size map")
.expect("type id is expected to exist in type size map") as usize
}

pub fn get_concrete_type(&self, type_id: &ConcreteTypeId) -> Option<&CoreTypeConcrete> {
self.sierra_context.program_registry_info.registry().get_type(type_id).ok()
}

pub fn struct_info(&self, type_id: &ConcreteTypeId) -> Option<&StructInfo> {
self.sierra_context.type_names.as_ref()?.structs.get(&SierraTypeId(type_id.id))
}

pub fn enum_info(&self, type_id: &ConcreteTypeId) -> Option<&EnumInfo> {
self.sierra_context.type_names.as_ref()?.enums.get(&SierraTypeId(type_id.id))
}

fn statement_idx_to_statement(&self, statement_idx: StatementIdx) -> &Statement {
Expand Down
8 changes: 2 additions & 6 deletions src/debugger/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tracing::{error, trace};

use crate::debugger::MAX_OBJECT_REFERENCE;
use crate::debugger::context::{Context, Line};
use crate::debugger::state::{RequestedVariables, State};
use crate::debugger::state::State;

pub struct HandlerResponse {
pub response_body: ResponseBody,
Expand Down Expand Up @@ -154,11 +154,7 @@ pub fn handle_request(
Ok(ResponseBody::Scopes(ScopesResponse { scopes }).into())
}
Command::Variables(VariablesArguments { variables_reference, .. }) => {
let variables = state.call_stack.get_variables(
RequestedVariables::VariablesReference(*variables_reference),
ctx,
vm,
);
let variables = state.call_stack.get_variables(*variables_reference, ctx, vm);
Ok(ResponseBody::Variables(VariablesResponse { variables }).into())
}

Expand Down
2 changes: 0 additions & 2 deletions src/debugger/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ type SourcePath = String;
mod call_stack;
mod ui_state;

pub use call_stack::RequestedVariables;

pub struct State {
configuration_done: bool,
execution_stopped: bool,
Expand Down
Loading