@@ -918,7 +918,7 @@ namespace Ark
918918 args.push_back (*popAndResolveAsPtr (context));
919919 throw types::TypeCheckingError (
920920 " append" ,
921- { { types::Contract { { types::Typedef (" list" , ValueType::List), types::Typedef (" value" , ValueType::Any, /* variadic = */ true ) } } } },
921+ { { types::Contract { { types::Typedef (" list" , ValueType::List), types::Typedef (" value" , ValueType::Any, /* is_variadic = */ true ) } } } },
922922 args);
923923 }
924924
@@ -1188,8 +1188,11 @@ namespace Ark
11881188 {
11891189 {
11901190 const Value cond = *popAndResolveAsPtr (context);
1191- if (cond == Builtins::trueSym) // todo: trigger debugger
1192- {}
1191+ if (cond == Builtins::trueSym)
1192+ {
1193+ initDebugger (context);
1194+ m_debugger->run ();
1195+ }
11931196 }
11941197 DISPATCH ();
11951198 }
@@ -2254,13 +2257,24 @@ namespace Ark
22542257 fmt::join (arg_names, " " )));
22552258 }
22562259
2257- void VM::showBacktraceWithException (const std::exception& e, internal::ExecutionContext& context)
2260+ void VM::initDebugger (internal::ExecutionContext& context)
2261+ {
2262+ if (!m_debugger)
2263+ m_debugger = std::make_unique<Debugger>(context);
2264+ else
2265+ m_debugger->saveState (context);
2266+ }
2267+
2268+ void VM::showBacktraceWithException (const std::exception& e, ExecutionContext& context)
22582269 {
22592270 std::string text = e.what ();
22602271 if (!text.empty () && text.back () != ' \n ' )
22612272 text += ' \n ' ;
22622273 fmt::println (" {}" , text);
22632274
2275+ if (m_state.m_features & FeatureVMDebugger)
2276+ initDebugger (context);
2277+
22642278 const std::size_t saved_ip = context.ip ;
22652279 const std::size_t saved_pp = context.pp ;
22662280 const uint16_t saved_sp = context.sp ;
@@ -2274,9 +2288,10 @@ namespace Ark
22742288 fmt::styled (saved_pp, fmt::fg (fmt::color::green)),
22752289 fmt::styled (saved_sp, fmt::fg (fmt::color::yellow)));
22762290
2277- if (m_state. m_features & FeatureVMDebugger )
2291+ if (m_debugger )
22782292 {
2279- // TODO: launch debugger
2293+ m_debugger->resetContextToErrorState (context);
2294+ m_debugger->run ();
22802295 }
22812296
22822297#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
0 commit comments