bebbo / libnix

libnix (v4): a C link library for AmigaOS/m68k
15 stars 9 forks source link

Minimap stack with sections #53

Closed BSzili closed 2 years ago

BSzili commented 2 years ago

It looks like the stack swap code no longer runs since the switch to sections. I uploaded a self-contained example to reproduce it with UAE: http://bszili.morphos.me/stuff/stacktest-sect.zip When I run it it prints free stack: 3806, which sounds about right for a default 4096 stack.

I used the previous test program without modifications:

#include <proto/exec.h>
#include <stdio.h>

extern void __stkinit(void);
void * __x = __stkinit;
unsigned long __stack = (32*1024);

int main(void)
{
    struct Task *task = FindTask(NULL);

    if ((ULONG)task->tc_SPUpper >= (ULONG)task->tc_SPReg && (ULONG)task->tc_SPReg >= (ULONG)task->tc_SPLower) 
        printf("free stack: %u\n", (ULONG)task->tc_SPReg - (ULONG)task->tc_SPLower);
    else
        printf("stack pointer is out of bounds\n");

    return 0;
} 

It's built with m68k-amigaos-gcc -noixemul -o stacktest stacktest.c.

BSzili commented 2 years ago

The problem is now resolved, thanks!