#include "uccompat.h"
+#ifdef STACKCHECK
+extern void live_check(const char *file,int line);
+extern void live_disable(int how);
+#define LIVE live_check(__FILE__,__LINE__)
+#define LIVE_DISABLE live_disable(1)
+#define LIVE_ENABLE live_disable(-1)
+#else /* STACKCHECK */
+#define LIVE
+#define LIVE_DISABLE
+#define LIVE_ENABLE
+#endif /* STACKCHECK */
+
#endif /* __CONFIG_H__ */
}
#endif /* DEBUG */
+static char SigHandler_buffer[255];
+
static void SigHandler(int status)
{
-
- unsigned char buffer[2048];
-
int count, res;
- res = device_read(buffer, 255);
+ LIVE_DISABLE;
+ LIVE;
+
+ res = device_read(SigHandler_buffer, sizeof(SigHandler_buffer));
for (count = 0; count < res ; count ++) {
- Protocol->StateMachine(buffer[count]);
+ Protocol->StateMachine(SigHandler_buffer[count]);
}
+ LIVE_ENABLE;
}
#target_m68k=1
enable_debug=1
+#stack_check=1
cfg_port="ttyS0"
exec 2>&1
test -n "$AR" || export AR="m68k-pic-coff-ar"
test -n "$CFLAGS" || export CFLAGS="-O2 -Wall -fPIC"
test -n "$CPPFLAGS" || export CPPFLAGS="-DUCCOMPAT=1 $CPPFLAGS"
+ if [ -n "$stack_check" -a -n "$enable_debug" ];then
+ export CPPFLAGS="-DSTACKCHECK=1 $CPPFLAGS"
+ fi
test -n "$LDFLAGS" || export LDFLAGS="gnokii/cleanup.c"
+# if [ -n "$enable_debug" ];then
+# export CFLAGS="-pg $CFLAGS"
+# export LDFLAGS="gnokii/mcount.c $LDFLAGS"
+# fi
fi
export CPPFLAGS="-DUCLINUX=1 $CPPFLAGS"
./configure --with-cfg-model=5110 --with-cfg-port=/dev/"$cfg_port" --without-x \
+#ifdef GNOKII_MAIN
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
void _cleanup(void)
{
/* hack for pic32 gcc */
}
+
+#ifdef STACKCHECK
+
+static volatile int live_check_disable=0;
+
+void live_check(const char *file,int line)
+{
+static volatile char *top=NULL,*top_printed=NULL;
+static volatile size_t largest=0,largest_printed=0;
+volatile char mark;
+
+ if (&mark > top)
+ top=&mark;
+ if (live_check_disable<=0 && top!=top_printed) {
+ printf("live_check [%s:%d]: new top=0x%08lX\n",file,line,(long)top);
+ fflush(stdout);
+ top_printed=top;
+ }
+ if (largest < top-&mark)
+ largest = top-&mark;
+ if (live_check_disable<=0 && largest!=largest_printed) {
+ printf("live_check [%s:%d]: largest=%ld\n",file,line,(long)largest);
+ fflush(stdout);
+ largest_printed=largest;
+ }
+ if (largest >= 12000) {
+ if (live_check_disable<=0)
+ puts("live_check - aborting!");
+ _exit(99);
+ }
+}
+
+void live_disable(int how)
+{
+ live_check_disable+=how;
+}
+
+#endif /* STACKCHECK */
{ 0, 0, 0, 0 },
};
+ LIVE;
+
opterr = 0;
/* For GNU gettext */
fprintf(stderr, _("Unknown memory type %s!\n"), argv[0]);
return (-1);
}
+
GetMemoryTypeString(memory_type_string, &entry.MemoryType);
if (argv[argc-1][0] == '-')
/* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */
char imei[64], model[64], rev[64], manufacturer[64];
+ LIVE;
fbusinit(NULL);
+ LIVE;
while (GSM->GetIMEI(imei) != GE_NONE) sleep(1);
+ LIVE;
while (GSM->GetRevision(rev) != GE_NONE) sleep(1);
+ LIVE;
while (GSM->GetModel(model) != GE_NONE) sleep(1);
+ LIVE;
strcpy(manufacturer, "(unknown)");
+ LIVE;
GSM->GetManufacturer(manufacturer);
+ LIVE;
fprintf(stdout, _("IMEI: %s\n"), imei);
fprintf(stdout, _("Model: %s %s (%s)\n"), manufacturer, GetModelName (model), model);
fprintf(stdout, _("Revision: %s\n"), rev);
+ LIVE;
GSM->Terminate();
+ LIVE;
return 0;
}
--- /dev/null
+#include <stdio.h>
+
+int main(void)
+{
+ puts("hello");
+ return 0;
+}
--- /dev/null
+#ifdef GNOKII_MAIN
+#include "config.h"
+#endif
+
+#ifdef STACKCHECK
+
+#include <stdio.h>
+
+void mcount(void)
+{
+#ifdef __m68k__X
+static void *arg;
+
+#if 0
+ asm("movel %%a0,%0" : "=r" (arg) : /* input */ : "a0");
+#endif
+ asm("movel %%fp@(+4),%0" : "=r" (arg) : /* input */);
+
+ printf("mcount(0x%08lX)\n",(long)arg);
+#endif /* __m68k__ */
+#ifdef LIVEX
+ LIVE;
+#endif /* LIVE */
+}
+
+#endif /* STACKCHECK */