Add -rpt option to generate error map and asm files if linker fails
This commit is contained in:
parent
76975e93aa
commit
8eebad4d8a
|
@ -120,6 +120,7 @@ The compiler is command line driven, and creates an executable .prg file.
|
|||
* -Os : optimize for size
|
||||
* -Oi : enable auto inline of small functions (part of O2/O3)
|
||||
* -Oa : optimize inline assembler (part of O2/O3)
|
||||
* -Oa : optimize inline assembler (part of O2/O3)
|
||||
* -Oz : enable auto placement of global variables in zero page (part of O3)
|
||||
* -Op : optimize constant parameters
|
||||
* -g : create source level debug info and add source line numbers to asm listing
|
||||
|
@ -133,6 +134,7 @@ The compiler is command line driven, and creates an executable .prg file.
|
|||
* -cid : cartridge type ID, used by vice emulator
|
||||
* -pp : compile in C++ mode
|
||||
* -psci : use PETSCII encoding for all strings without prefix
|
||||
* -rpt : generate error files .error.map, .error.asm when linker fails
|
||||
|
||||
A list of source files can be provided.
|
||||
|
||||
|
|
|
@ -223,8 +223,8 @@ void * memmove(void * dst, const void * src, int size)
|
|||
int sz = size;
|
||||
if (sz > 0)
|
||||
{
|
||||
char * d = dst;
|
||||
const char * s = src;
|
||||
char * d = (char *)dst;
|
||||
const char * s = (const char *)src;
|
||||
if (d < s)
|
||||
{
|
||||
do {
|
||||
|
@ -245,7 +245,7 @@ void * memmove(void * dst, const void * src, int size)
|
|||
|
||||
int memcmp(const void * ptr1, const void * ptr2, int size)
|
||||
{
|
||||
const char * p = ptr1, * q = ptr2;
|
||||
const char * p = (const char *)ptr1, * q = (const char *)ptr2;
|
||||
char c, d;
|
||||
|
||||
while (size--)
|
||||
|
|
|
@ -1188,6 +1188,82 @@ bool Compiler::BuildLZO(const char* targetPath)
|
|||
}
|
||||
}
|
||||
|
||||
bool Compiler::RemoveErrorFile(const char* targetPath)
|
||||
{
|
||||
char prgPath[200], mapPath[200], asmPath[200], intPath[200];
|
||||
char basePath[200];
|
||||
|
||||
strcpy_s(basePath, targetPath);
|
||||
ptrdiff_t i = strlen(basePath);
|
||||
while (i > 0 && basePath[i - 1] != '/' && basePath[i - 1] != '\\' && basePath[i - 1] != ':')
|
||||
i--;
|
||||
if (i > 0)
|
||||
basePath[i] = 0;
|
||||
|
||||
strcpy_s(prgPath, targetPath);
|
||||
i = strlen(prgPath);
|
||||
while (i > 0 && prgPath[i - 1] != '.')
|
||||
i--;
|
||||
if (i > 0)
|
||||
prgPath[i] = 0;
|
||||
|
||||
strcpy_s(mapPath, prgPath);
|
||||
strcpy_s(asmPath, prgPath);
|
||||
strcpy_s(intPath, prgPath);
|
||||
|
||||
strcat_s(mapPath, "error.map");
|
||||
strcat_s(asmPath, "error.asm");
|
||||
strcat_s(intPath, "error.int");
|
||||
|
||||
remove(mapPath);
|
||||
remove(asmPath);
|
||||
remove(intPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Compiler::WriteErrorFile(const char* targetPath)
|
||||
{
|
||||
char prgPath[200], mapPath[200], asmPath[200], intPath[200];
|
||||
char basePath[200];
|
||||
|
||||
strcpy_s(basePath, targetPath);
|
||||
ptrdiff_t i = strlen(basePath);
|
||||
while (i > 0 && basePath[i - 1] != '/' && basePath[i - 1] != '\\' && basePath[i - 1] != ':')
|
||||
i--;
|
||||
if (i > 0)
|
||||
basePath[i] = 0;
|
||||
|
||||
strcpy_s(prgPath, targetPath);
|
||||
i = strlen(prgPath);
|
||||
while (i > 0 && prgPath[i - 1] != '.')
|
||||
i--;
|
||||
if (i > 0)
|
||||
prgPath[i] = 0;
|
||||
|
||||
strcpy_s(mapPath, prgPath);
|
||||
strcpy_s(asmPath, prgPath);
|
||||
strcpy_s(intPath, prgPath);
|
||||
|
||||
strcat_s(mapPath, "error.map");
|
||||
strcat_s(asmPath, "error.asm");
|
||||
strcat_s(intPath, "error.int");
|
||||
|
||||
if (mCompilerOptions & COPT_VERBOSE)
|
||||
printf("Writing <%s>\n", mapPath);
|
||||
mLinker->WriteMapFile(mapPath);
|
||||
|
||||
if (mCompilerOptions & COPT_VERBOSE)
|
||||
printf("Writing <%s>\n", asmPath);
|
||||
mLinker->WriteAsmFile(asmPath, mVersion);
|
||||
|
||||
if (mCompilerOptions & COPT_VERBOSE)
|
||||
printf("Writing <%s>\n", intPath);
|
||||
mInterCodeModule->Disassemble(intPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Compiler::WriteOutputFile(const char* targetPath, DiskImage * d64)
|
||||
{
|
||||
char prgPath[200], mapPath[200], asmPath[200], lblPath[200], intPath[200], bcsPath[200], dbjPath[200];
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
bool ParseSource(void);
|
||||
bool GenerateCode(void);
|
||||
bool WriteOutputFile(const char* targetPath, DiskImage * d64);
|
||||
bool WriteErrorFile(const char* targetPath);
|
||||
bool RemoveErrorFile(const char* targetPath);
|
||||
int ExecuteCode(bool profile, int trace);
|
||||
|
||||
void AddDefine(const Ident* ident, const char* value);
|
||||
|
|
|
@ -39,6 +39,7 @@ static const uint64 COPT_DEBUGINFO = 1ULL << 51;
|
|||
|
||||
static const uint64 COPT_CPLUSPLUS = 1ULL << 52;
|
||||
static const uint64 COPT_PETSCII = 1ULL << 53;
|
||||
static const uint64 COPT_ERROR_FILES = 1ULL << 54;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1675,6 +1675,8 @@ bool Linker::WriteMapFile(const char* filename)
|
|||
LinkerObject* obj = mObjects[i];
|
||||
|
||||
if (obj->mFlags & LOBJF_REFERENCED)
|
||||
{
|
||||
if (obj->mRegion)
|
||||
{
|
||||
if (banked)
|
||||
{
|
||||
|
@ -1686,6 +1688,7 @@ bool Linker::WriteMapFile(const char* filename)
|
|||
else
|
||||
fprintf(file, "--:");
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->mIdent)
|
||||
fprintf(file, "%04x - %04x : %s, %s:%s\n", obj->mAddress, obj->mAddress + obj->mSize, obj->mIdent->mString, LinkerObjectTypeNames[obj->mType], obj->mSection->mIdent->mString);
|
||||
|
@ -1728,6 +1731,8 @@ bool Linker::WriteMapFile(const char* filename)
|
|||
{
|
||||
const LinkerObject* obj = so[i];
|
||||
|
||||
if (obj->mRegion)
|
||||
{
|
||||
if (banked)
|
||||
{
|
||||
int k = 0;
|
||||
|
@ -1738,6 +1743,7 @@ bool Linker::WriteMapFile(const char* filename)
|
|||
else
|
||||
fprintf(file, "--:");
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(file, "%04x (%04x) : %s, %s:%s\n", obj->mAddress, obj->mSize, obj->mIdent->mString, LinkerObjectTypeNames[obj->mType], obj->mSection->mIdent->mString);
|
||||
}
|
||||
|
@ -1926,7 +1932,9 @@ bool Linker::WriteAsmFile(const char* filename, const char* version)
|
|||
mByteCodeDisassembler.Disassemble(file, mMemory, -1, obj->mAddress, obj->mSize, obj->mProc, obj->mIdent, this);
|
||||
break;
|
||||
case LOT_NATIVE_CODE:
|
||||
if (obj->mRegion->mCartridgeBanks)
|
||||
if (!obj->mRegion)
|
||||
mNativeDisassembler.Disassemble(file, obj->mData, -1, 0, obj->mSize, obj->mProc, obj->mIdent, this, obj->mFullIdent);
|
||||
else if (obj->mRegion->mCartridgeBanks)
|
||||
{
|
||||
int i = 0;
|
||||
while (!(obj->mRegion->mCartridgeBanks & (1ULL << i)))
|
||||
|
@ -1939,7 +1947,9 @@ bool Linker::WriteAsmFile(const char* filename, const char* version)
|
|||
mNativeDisassembler.Disassemble(file, mMemory, -1, obj->mAddress, obj->mSize, obj->mProc, obj->mIdent, this, obj->mFullIdent);
|
||||
break;
|
||||
case LOT_DATA:
|
||||
if (obj->mRegion->mCartridgeBanks)
|
||||
if (!obj->mRegion)
|
||||
mNativeDisassembler.DumpMemory(file, obj->mData, -1, 0, obj->mSize, obj->mProc, obj->mIdent, this, obj);
|
||||
else if (obj->mRegion->mCartridgeBanks)
|
||||
{
|
||||
int i = 0;
|
||||
while (!(obj->mRegion->mCartridgeBanks & (1ULL << i)))
|
||||
|
|
|
@ -312,6 +312,10 @@ int main2(int argc, const char** argv)
|
|||
compiler->mCompilerOptions |= COPT_CPLUSPLUS;
|
||||
compiler->AddDefine(Ident::Unique("__cplusplus"), "1");
|
||||
}
|
||||
else if (arg[1] == 'r' && arg[2] == 'm' && arg[3] == 'p')
|
||||
{
|
||||
compiler->mCompilerOptions |= COPT_ERROR_FILES;
|
||||
}
|
||||
else
|
||||
compiler->mErrors->Error(loc, EERR_COMMAND_LINE, "Invalid command line argument", arg);
|
||||
}
|
||||
|
@ -524,6 +528,8 @@ int main2(int argc, const char** argv)
|
|||
printf("Starting %s %s\n", strProductName, strProductVersion);
|
||||
}
|
||||
|
||||
compiler->WriteErrorFile(targetPath);
|
||||
|
||||
{
|
||||
char dstring[100], tstring[100];
|
||||
time_t now = time(NULL);
|
||||
|
@ -579,6 +585,10 @@ int main2(int argc, const char** argv)
|
|||
if (emulate)
|
||||
compiler->ExecuteCode(profile, trace);
|
||||
}
|
||||
else if (compiler->mCompilerOptions & COPT_ERROR_FILES)
|
||||
{
|
||||
compiler->WriteErrorFile(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (compiler->mErrors->mErrorCount != 0)
|
||||
|
|
Loading…
Reference in New Issue