]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
debugmem stack frame tracker overflow check
authorToni Wilen <twilen@winuae.net>
Sat, 3 Dec 2022 12:18:12 +0000 (14:18 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 3 Dec 2022 12:18:12 +0000 (14:18 +0200)
debugmem.cpp

index a182ff86f2745ec5de3383bb47f29b7e3d7a363b..ac15b80e6cf39de7fa8915096e03173694dfa4fd 100644 (file)
@@ -512,13 +512,21 @@ void branch_stack_pop_rts(uaecptr oldpc)
 
 void branch_stack_push(uaecptr oldpc, uaecptr newpc)
 {
-       if (!stackframes)
+       if (!stackframes) {
                return;
+       }
        if (!stackframemode) {
-               if (debug_waiting || (!regs.s && get_long_host(exec_thistask) != debug_task))
+               if (debug_waiting || (!regs.s && get_long_host(exec_thistask) != debug_task)) {
                        return;
+               }
        }
        int cnt = regs.s ? stackframecntsuper : stackframecnt;
+       if (cnt >= MAX_STACKFRAMES) {
+               write_log(_T("Stack frame %c max limit reached!\n"), regs.s ? 'S' : 'U');
+               stackframecntsuper = 0;
+               stackframecnt = 0;
+               return;
+       }
        struct debugstackframe *sf = regs.s ? &stackframessuper[cnt] : &stackframes[cnt];
        sf->current_pc = regs.instruction_pc;
        sf->next_pc = newpc;