Sfoglia il codice sorgente

Gsoc 2025 debugger (#396)

* fix an fatal error

* fix bug : rerefrence invaild

* implement better exception support

* fix bug : might crash when eval executes
lightovernight 5 mesi fa
parent
commit
5657989e27
1 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 8 2
      src/debugger/dap.c

+ 8 - 2
src/debugger/dap.c

@@ -175,6 +175,7 @@ void c11_dap_handle_evaluate(py_Ref arguments, c11_sbuf* buffer) {
     // [eval, nil, expression,  globals, locals]
     // vectorcall would pop the above 5 items
     // so we don't need to pop them manually
+    py_StackRef p0 = py_peek(0);
     py_Ref py_eval = py_pushtmp();
     py_pushnil();
     py_Ref expression = py_pushtmp();
@@ -188,9 +189,14 @@ void c11_dap_handle_evaluate(py_Ref arguments, c11_sbuf* buffer) {
     c11_sbuf__write_cstr(buffer, "\"body\":");
     if(!ok) {
         result = py_formatexc();
+        py_clearexc(p0);
     } else {
-        py_str(py_retval());
-        result = c11_strdup(py_tostr(py_retval()));
+        py_Ref py_result = py_pushtmp();
+        py_assign(py_result, py_retval());
+        py_str(py_result);
+        py_assign(py_result, py_retval());
+        result = c11_strdup(py_tostr(py_result));
+        py_pop();
     }
 
     c11_sv result_sv = {.data = result, .size = strlen(result)};