Skip to content

Commit

Permalink
Enable AIO_DEBUG by default on the Mac debug VMs. Add a -aiolog switc…
Browse files Browse the repository at this point in the history
…h to mac

& unix VMs when AIO_DEBUG is defined.  If -DAIO_DEBUG=1 turn on logging by
default (otherwise use the -aiolog switch).  Fix a glitch in SSL debug printing
which will crash the VM if SSL is not yet intialized (e.g. state left over from
a snapshot). [ci skip]
  • Loading branch information
eliotmiranda committed Oct 6, 2020
1 parent 5343750 commit a717c66
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.macos32x86/common/Makefile.plugin
Expand Up @@ -33,7 +33,7 @@ BUILD:=buildast
else
OFLAGS:= -g -O0 -fno-omit-frame-pointer
AT_MOST_OPT_LEVEL_ONE:=-O0
DEBUGVM=-DDEBUGVM=1
DEBUGVM=-DDEBUGVM=1 -DAIO_DEBUG
BUILD:=builddbg
endif

Expand Down
2 changes: 1 addition & 1 deletion build.macos32x86/common/Makefile.vm
Expand Up @@ -104,7 +104,7 @@ endif
# VM config flags.
ifeq ($(CONFIGURATION),debug)
OFLAGS:= -g -O0 -fno-omit-frame-pointer
DEBUGVM=-DDEBUGVM=1
DEBUGVM=-DDEBUGVM=1 -DAIO_DEBUG
INTERPFLAGS:=-DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0'
else ifeq ($(CONFIGURATION),assert)
OFLAGS:= -g -O1 -fno-omit-frame-pointer
Expand Down
2 changes: 1 addition & 1 deletion build.macos64ARMv8/common/Makefile.plugin
Expand Up @@ -33,7 +33,7 @@ BUILD:=buildast
else
OFLAGS:= -g -O0 -fno-omit-frame-pointer
AT_MOST_OPT_LEVEL_ONE:=-O0
DEBUGVM=-DDEBUGVM=1
DEBUGVM=-DDEBUGVM=1 -DAIO_DEBUG
BUILD:=builddbg
endif

Expand Down
2 changes: 1 addition & 1 deletion build.macos64ARMv8/common/Makefile.vm
Expand Up @@ -104,7 +104,7 @@ endif
# VM config flags.
ifeq ($(CONFIGURATION),debug)
OFLAGS:= -g -O0 -fno-omit-frame-pointer
DEBUGVM=-DDEBUGVM=1
DEBUGVM=-DDEBUGVM=1 -DAIO_DEBUG
INTERPFLAGS:=-DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0'
else ifeq ($(CONFIGURATION),assert)
OFLAGS:= -g -O1 -fno-omit-frame-pointer
Expand Down
2 changes: 1 addition & 1 deletion build.macos64x64/common/Makefile.plugin
Expand Up @@ -33,7 +33,7 @@ BUILD:=buildast
else
OFLAGS:= -g -O0 -fno-omit-frame-pointer
AT_MOST_OPT_LEVEL_ONE:=-O0
DEBUGVM=-DDEBUGVM=1
DEBUGVM=-DDEBUGVM=1 -DAIO_DEBUG
BUILD:=builddbg
endif

Expand Down
2 changes: 1 addition & 1 deletion build.macos64x64/common/Makefile.vm
Expand Up @@ -104,7 +104,7 @@ endif
# VM config flags.
ifeq ($(CONFIGURATION),debug)
OFLAGS:= -g -O0 -fno-omit-frame-pointer
DEBUGVM=-DDEBUGVM=1
DEBUGVM=-DDEBUGVM=1 -DAIO_DEBUG
INTERPFLAGS:=-DAllocationCheckFiller=0xADD4E55 -D'VM_LABEL(foo)=0'
else ifeq ($(CONFIGURATION),assert)
OFLAGS:= -g -O1 -fno-omit-frame-pointer
Expand Down
4 changes: 2 additions & 2 deletions platforms/iOS/plugins/SqueakSSL/sqMacSSL.c
Expand Up @@ -98,8 +98,8 @@ static int printf_status(OSStatus status, const char* restrict format, ...)
}

/* By convention, the sqSSL object is named ssl and has its logLevel >= 0 */
#define logprintf if (ssl->loglevel) printf
#define logprintf_status if (ssl->loglevel) printf_status
#define logprintf if (ssl && ssl->loglevel) printf
#define logprintf_status if (ssl && ssl->loglevel) printf_status

/* sqSSLFromHandle: Maps a handle to an SSL */
static sqSSL* sqSSLFromHandle(sqInt handle)
Expand Down
10 changes: 10 additions & 0 deletions platforms/iOS/vm/OSX/sqSqueakOSXApplication.m
Expand Up @@ -246,6 +246,13 @@ - (int) parseArgument: (NSString *) argData peek: (char *) peek
}
#endif

#if defined(AIO_DEBUG)
if ([argData isEqualToString: VMOPTIONOBJ("aiolog")]) {
extern long aioDebugLogging;
aioDebugLogging = 1;
return 1;
}
#endif
#if COGVM
if ([argData compare: VMOPTIONOBJ("trace") options: NSLiteralSearch range: NSMakeRange(0,VMOPTIONLEN(6))] == NSOrderedSame) {
extern int traceFlags;
Expand Down Expand Up @@ -554,6 +561,9 @@ - (void) printUsage {
printf(" "VMOPTION("blockonerror")" on error or segv block, not exit. useful for attaching gdb\n");
printf(" "VMOPTION("blockonwarn")" on warning block, don't warn. useful for attaching gdb\n");
printf(" "VMOPTION("exitonwarn")" treat warnings as errors, exiting on warn\n");
#if defined(AIO_DEBUG)
printf(" "VMOPTION("aiolog")" print async io logging info\n");
#endif
}

- (void) printUsageNotes
Expand Down
6 changes: 5 additions & 1 deletion platforms/unix/vm/aio.c
Expand Up @@ -106,7 +106,11 @@ extern void addIdleUsecs(long idleUsecs);
#if defined(AIO_DEBUG)
long aioLastTick = 0;
long aioThisTick = 0;

# if AIO_DEBUG
long aioDebugLogging = 1;
# else
long aioDebugLogging = 0;
# endif
#endif

#define _DO_FLAG_TYPE() do { _DO(AIO_R, rd) _DO(AIO_W, wr) _DO(AIO_X, ex) } while (0)
Expand Down
8 changes: 5 additions & 3 deletions platforms/unix/vm/sqUnixMain.c
Expand Up @@ -1552,6 +1552,9 @@ static int vm_parseArgument(int argc, char **argv)
else if (!strcmp(argv[0], VMOPTION("nojit"))) { useJit = 0; return 1; }
else if (!strcmp(argv[0], VMOPTION("spy"))) { withSpy = 1; return 1; }
#endif /* !STACKVM && !COGVM */
#if defined(AIO_DEBUG)
else if (!strcmp(argv[0], VMOPTION("aiolog"))) { aioDebugLogging = 1; return 1; }
#endif
#if (STACKVM || NewspeakVM) && !COGVM
else if (!strcmp(argv[0], VMOPTION("sendtrace"))) { extern sqInt sendTrace; sendTrace = 1; return 1; }
#endif
Expand Down Expand Up @@ -1703,9 +1706,8 @@ static void vm_printUsage(void)
#endif
printf(" "VMOPTION("noevents")" disable event-driven input support\n");
printf(" "VMOPTION("nohandlers")" disable sigsegv & sigusr1 handlers\n");
printf(" "VMOPTION("pollpip")" (0|1) output on each poll for input\n");
printf(" "VMOPTION("checkpluginwrites")" check for writes past end of object in plugins\n");
printf(" "VMOPTION("pathenc")" <enc> set encoding for pathnames (default: UTF-8)\n");
#if defined(AIO_DEBUG)
printf(" "VMOPTION("aiolog")" output async io logging info\n");
printf(" "VMOPTION("plugins")" <path> specify alternative plugin location (see manpage)\n");
printf(" "VMOPTION("textenc")" <enc> set encoding for external text (default: UTF-8)\n");
printf(" "VMOPTION("version")" print version information, then exit\n");
Expand Down
11 changes: 6 additions & 5 deletions platforms/unix/vm/sqaio.h
Expand Up @@ -109,16 +109,17 @@ extern unsigned long long ioUTCMicrosecondsNow(void);
platReportError((os_error *)&privateErr); \
} while (0)
# else /* !ACORN */
extern long aioLastTick, aioThisTick, ioMSecs(void);
extern long aioLastTick, aioThisTick, aioDebugLogging, ioMSecs(void);
extern const char *__shortFileName(const char *);
# define FPRINTF(X) do { \
# define FPRINTF(X) do { if (aioDebugLogging) { \
aioThisTick = ioMSecs(); \
fprintf(stderr, "%8ld %4ld %s:%d ", aioThisTick, aioThisTick - aioLastTick,\
fprintf(stderr, "%8ld %4ld %s:%d ", \
aioThisTick, aioThisTick - aioLastTick, \
__shortFileName(__FILE__),__LINE__); \
aioLastTick = aioThisTick; \
fprintf X; } while (0)
fprintf X; } } while (0)
# endif /* ACORN */
#else /* !DEBUG */
#else /* !AIO_DEBUG */
# define FPRINTF(X)
#endif

Expand Down

0 comments on commit a717c66

Please sign in to comment.