Set debug file locations to DEFAULT_DIR

This commit is contained in:
OV2 2010-10-02 00:49:23 +02:00
parent 851839cdea
commit 918a376010
4 changed files with 11 additions and 13 deletions

View File

@ -3642,7 +3642,7 @@ static void Op42 (void)
S9xMessage(S9X_DEBUG, S9X_DEBUG_OUTPUT, buf); S9xMessage(S9X_DEBUG, S9X_DEBUG_OUTPUT, buf);
if (trace != NULL) if (trace != NULL)
fclose(trace); fclose(trace);
trace = fopen("WDMtrace.log", "ab"); ENSURE_TRACE_OPEN(trace,"WDMtrace.log","ab")
} }
break; break;

View File

@ -1532,8 +1532,7 @@ static void debug_process_command (char *Line)
if (SA1.Flags & TRACE_FLAG) if (SA1.Flags & TRACE_FLAG)
{ {
printf("SA1 CPU instruction tracing enabled.\n"); printf("SA1 CPU instruction tracing enabled.\n");
if (trace2 == NULL) ENSURE_TRACE_OPEN(trace2,"trace_sa1.log","wb")
trace2 = fopen("trace_sa1.log", "wb");
} }
else else
{ {
@ -1549,8 +1548,7 @@ static void debug_process_command (char *Line)
if (CPU.Flags & TRACE_FLAG) if (CPU.Flags & TRACE_FLAG)
{ {
printf("CPU instruction tracing enabled.\n"); printf("CPU instruction tracing enabled.\n");
if (trace == NULL) ENSURE_TRACE_OPEN(trace,"trace.log","wb")
trace = fopen("trace.log", "wb");
} }
else else
{ {
@ -2580,8 +2578,7 @@ void S9xTrace (void)
{ {
char msg[512]; char msg[512];
if (trace == NULL) ENSURE_TRACE_OPEN(trace,"trace.log","a")
trace = fopen("trace.log", "a");
debug_cpu_op_print(msg, Registers.PB, Registers.PCw); debug_cpu_op_print(msg, Registers.PB, Registers.PCw);
fprintf(trace, "%s\n", msg); fprintf(trace, "%s\n", msg);
@ -2591,8 +2588,7 @@ void S9xSA1Trace (void)
{ {
char msg[512]; char msg[512];
if (trace2 == NULL) ENSURE_TRACE_OPEN(trace2,"trace_sa1.log","a")
trace2 = fopen("trace_sa1.log", "a");
debug_sa1_op_print(msg, SA1Registers.PB, SA1Registers.PCw); debug_sa1_op_print(msg, SA1Registers.PB, SA1Registers.PCw);
fprintf(trace2, "%s\n", msg); fprintf(trace2, "%s\n", msg);

View File

@ -187,6 +187,9 @@ struct SBreakPoint
uint16 Address; uint16 Address;
}; };
#define ENSURE_TRACE_OPEN(fp,file,mode) \
if(!fp) {std::string fn=S9xGetDirectory(DEFAULT_DIR);fn+=SLASH_STR file;fp=fopen(fn.c_str(),mode);}
extern struct SBreakPoint S9xBreakpoint[6]; extern struct SBreakPoint S9xBreakpoint[6];
void S9xDoDebug (void); void S9xDoDebug (void);

View File

@ -193,6 +193,7 @@
#endif #endif
#ifdef DEBUGGER #ifdef DEBUGGER
#include "debug.h"
extern FILE *trace; extern FILE *trace;
#endif #endif
@ -493,8 +494,7 @@ void S9xLoadConfigFiles (char **argv, int argc)
if (conf.GetBool("DEBUG::Trace", false)) if (conf.GetBool("DEBUG::Trace", false))
{ {
if (!trace) ENSURE_TRACE_OPEN(trace,"trace.log","wb")
trace = fopen("trace.log", "wb");
CPU.Flags |= TRACE_FLAG; CPU.Flags |= TRACE_FLAG;
} }
#endif #endif
@ -845,8 +845,7 @@ char * S9xParseArgs (char **argv, int argc)
else else
if (!strcasecmp(argv[i], "-trace")) if (!strcasecmp(argv[i], "-trace"))
{ {
if (!trace) ENSURE_TRACE_OPEN(trace,"trace.log","wb")
trace = fopen("trace.log", "wb");
CPU.Flags |= TRACE_FLAG; CPU.Flags |= TRACE_FLAG;
} }
else else