]> j8takagi.net git repositories - yacasl2.git/commitdiff
monitor終了時、exitするのではなく、execに戻るよう内部動作を修正
authorj8takagi <j8takagi@nifty.com>
Mon, 6 Jul 2026 09:33:20 +0000 (18:33 +0900)
committerj8takagi <j8takagi@nifty.com>
Mon, 6 Jul 2026 09:33:20 +0000 (18:33 +0900)
- exitの場合、casl2 -mのmonitor終了時にメモリーリーク発生するため
- monitor終了時、execmode.monitorとexecmode.stepをfalseにする
- exec側の処理
  -- execmode.monitorがfalseでexecptr->startがfalseかexecptr->endがtrueuの場合は即時終了
  -- それ以外の場合は、execmode.monitorがfalseのままCOMET IIを実行

include/monitor.h
src/exec.c
src/monitor.c
src/struct.c

index 603505eb376cffa7f2085730cd1bfe74d8d37678..10b179c25c8623425078574ad271be8dc16f443a 100644 (file)
@@ -131,9 +131,8 @@ void freebps();
 /**
  * @brief モニター終了時の処理をする
  *
- * @return エラーがない場合は0、エラーがある場合は1
  */
-int monquit();
+void monquit();
 
 /**
  * @brief COMET IIモニターを起動する
index dc2b2dc2470c98e9f130f6e1682939079b6982b9..5ff61204e67f463e840585b0fb0bd130b3579c92 100644 (file)
@@ -704,6 +704,9 @@ void exec()
                 fprintf(stdout, "%s", monmsg);
             }
             monitor();
+            if(execmode.monitor == false && (execptr->start == false || execptr->stop == true)) {
+                break;
+            }
         }
         /* プログラムレジスタをチェック */
         if(sys->cpu->pr >= sys->memsize) {
index 5dd7d955d23bf950fccb93a24722a73835b9656d..fa03bea8afde5f399f8c4afa3d558c87b40c7b18 100644 (file)
@@ -367,20 +367,11 @@ void free_moncmdline(MONCMDLINE *moncmdl)
     }
 }
 
-int monquit()
+void monquit()
 {
-    int stat = 0;
-
-    comet2_shutdown();
+    execmode.monitor = false;
+    execmode.step = false;
     freebps();
-    free_cmdtable(HASH_CMDTYPE);
-    free_cmdtable(HASH_CODE);
-
-    if(cerr->num > 0) {
-        stat = 1;
-    }
-    freecerr();
-    return stat;
 }
 
 void monitor()
@@ -396,7 +387,8 @@ void monitor()
         /* EOFの処理 */
         if(buf == NULL) {
             FREE(last_buf);
-            exit(monquit());
+            monquit();
+            break;
         }
         /* 空行(Enterだけ)の場合は、前回のコマンドをリピート */
         if(buf[0] == '\0') {
@@ -427,7 +419,8 @@ void monitor()
         if(cmdtype == MONQUIT) {
             FREE(buf);
             FREE(last_buf);
-            exit(monquit());
+            monquit();
+            break;
         }
     } while(cmdtype == MONREPEAT);
     FREE(buf);
index a5d2c2c64264185f77fb10082a9cd54c93ad167c..435b70c24a4b25f13b397c43a9435eaa41c5624e 100644 (file)
@@ -273,7 +273,7 @@ bool code_gr_valid(WORD code)
     WORD gr = 0;
     if(cmdtype == R_ADR_X || cmdtype == R1_R2 || cmdtype == R_) {
         gr = (code & 0x00F0) >> 4;
-        if(gr < 0 || GRSIZE <= gr) {
+        if(gr >= GRSIZE) {
             res = false;
         }
     }