- fix: Crash when debug project that has nasm files.

- enhancement: Generate debug info for nasm files in Linux/MacOS.
  - enhancement: Compile/Run/Debug GAS source files.
  - enhancement: Compile/Debug GAS source files in project.
This commit is contained in:
Roy Qu 2023-02-12 12:53:14 +08:00
parent a6cae34a99
commit 0e3441e604
11 changed files with 54 additions and 20 deletions

View File

@ -5,6 +5,11 @@ Red Panda C++ Version 2.12
- enhancement: Code folding for #if/#endif - enhancement: Code folding for #if/#endif
- enhancement: When folding "if", don't fold "else"; - enhancement: When folding "if", don't fold "else";
- fix: Confirm if recompile, when start to debug and project files has modifications. - fix: Confirm if recompile, when start to debug and project files has modifications.
- fix: Crash when debug project that has nasm files.
- enhancement: Generate debug info for nasm files in Linux/MacOS.
- enhancement: Compile/Run/Debug GAS source files.
- enhancement: Compile/Debug GAS source files in project.
Red Panda C++ Version 2.11 Red Panda C++ Version 2.11

View File

@ -98,6 +98,13 @@ bool FileCompiler::prepareForCompile()
mArguments += getCharsetArgument(mEncoding, fileType, mOnlyCheckSyntax); mArguments += getCharsetArgument(mEncoding, fileType, mOnlyCheckSyntax);
QString strFileType; QString strFileType;
switch(fileType) { switch(fileType) {
case FileType::GAS:
mArguments += getCCompileArguments(mOnlyCheckSyntax);
mArguments += getCIncludeArguments();
mArguments += getProjectIncludeArguments();
strFileType = "GNU Assembler";
mCompiler = compilerSet()->CCompiler();
break;
case FileType::CSource: case FileType::CSource:
mArguments += getCCompileArguments(mOnlyCheckSyntax); mArguments += getCCompileArguments(mOnlyCheckSyntax);
mArguments += getCIncludeArguments(); mArguments += getCIncludeArguments();

View File

@ -160,7 +160,7 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
continue; continue;
if (fileType == FileType::CSource || fileType == FileType::CppSource if (fileType == FileType::CSource || fileType == FileType::CppSource
|| fileType == FileType::ASM) { || fileType == FileType::ASM || fileType==FileType::GAS) {
if (!mProject->options().objectOutput.isEmpty()) { if (!mProject->options().objectOutput.isEmpty()) {
// ofile = C:\MyProgram\obj\main.o // ofile = C:\MyProgram\obj\main.o
QString fullObjFile = includeTrailingPathDelimiter(mProject->options().objectOutput) QString fullObjFile = includeTrailingPathDelimiter(mProject->options().objectOutput)
@ -285,21 +285,28 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
writeln(file,"WINDRESFLAGS = " + mProject->options().resourceCmd); writeln(file,"WINDRESFLAGS = " + mProject->options().resourceCmd);
#endif #endif
if (compilerSet()->canAssemble()) {
QString asmFlags;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (compilerSet()->canAssemble() && if (Settings::CompilerSets::isTarget64Bit(compilerSet()->target())) {
Settings::CompilerSets::isTarget64Bit(compilerSet()->target())) { if (mProject->getCompileOption(CC_CMD_OPT_POINTER_SIZE)=="32")
if (mProject->getCompileOption(CC_CMD_OPT_POINTER_SIZE)=="32") asmFlags = "-f win32 " + mProject->options().assemblerArgs;
writeln(file,"ASMFLAGS = -f win32 " + mProject->options().assemblerArgs); else
else asmFlags = "-f win64 " + mProject->options().assemblerArgs;
writeln(file,"ASMFLAGS = -f win64 " + mProject->options().assemblerArgs); } else {
} else { asmFlags = "-f win32 " + mProject->options().assemblerArgs;
writeln(file,"ASMFLAGS = -f win32 " + mProject->options().assemblerArgs); }
}
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
writeln(file,"ASMFLAGS = -f elf64"); asmFlags = "-f elf64";
if (mProject->getCompileOption(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON)
asmFlags += " -g ";
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
writeln(file,"ASMFLAGS = -f macho64"); asmFlags = "-f macho64";
if (mProject->getCompileOption(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON)
asmFlags += " -g ";
#endif #endif
writeln(file,"ASMFLAGS = " + asmFlags);
}
// This needs to be put in before the clean command. // This needs to be put in before the clean command.
if (mProject->options().type == ProjectType::DynamicLib) { if (mProject->options().type == ProjectType::DynamicLib) {
@ -379,7 +386,8 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
FileType fileType = getFileType(unit->fileName()); FileType fileType = getFileType(unit->fileName());
// Only process source files // Only process source files
if (fileType!=FileType::CSource && fileType!=FileType::CppSource if (fileType!=FileType::CSource && fileType!=FileType::CppSource
&& fileType!=FileType::ASM) && fileType!=FileType::ASM
&& fileType!=FileType::GAS)
continue; continue;
QString shortFileName = extractRelativePath(mProject->makeFileName(),unit->fileName()); QString shortFileName = extractRelativePath(mProject->makeFileName(),unit->fileName());
@ -494,6 +502,10 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
else else
writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CFLAGS) " + encodingStr); writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CFLAGS) " + encodingStr);
} }
} else if (fileType==FileType::GAS) {
if (!mOnlyCheckSyntax) {
writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CFLAGS) " + encodingStr);
}
} else if (fileType==FileType::ASM) { } else if (fileType==FileType::ASM) {
if (!mOnlyCheckSyntax) { if (!mOnlyCheckSyntax) {
writeln(file, "\t$(ASM) " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(ASMFLAGS) "); writeln(file, "\t$(ASM) " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(ASMFLAGS) ");

View File

@ -3859,6 +3859,8 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/
void Editor::showDebugHint(const QString &s, int line) void Editor::showDebugHint(const QString &s, int line)
{ {
if (!mParser)
return;
PStatement statement = mParser->findStatementOf(mFilename,s,line); PStatement statement = mParser->findStatementOf(mFilename,s,line);
if (statement) { if (statement) {
if (statement->kind != StatementKind::skVariable if (statement->kind != StatementKind::skVariable

View File

@ -696,6 +696,9 @@ void MainWindow::updateCompileActions(const Editor *e)
canGenerateAssembly = true; canGenerateAssembly = true;
canCompile = true; canCompile = true;
canRun = true; canRun = true;
} else if (fileType == FileType::GAS) {
canCompile = true;
canRun = true;
} }
} else { } else {
forProject = (mProject!=nullptr); forProject = (mProject!=nullptr);

View File

@ -951,6 +951,7 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate, b
FileType fileType=getFileType(unit->fileName()); FileType fileType=getFileType(unit->fileName());
if (fileType==FileType::ASM if (fileType==FileType::ASM
|| fileType==FileType::GAS
|| isCFile(unit->fileName()) || isHFile(unit->fileName())) { || isCFile(unit->fileName()) || isHFile(unit->fileName())) {
Editor * editor = mEditorList->newEditor( Editor * editor = mEditorList->newEditor(
unit->fileName(), unit->fileName(),
@ -1277,6 +1278,11 @@ PProjectUnit Project::internalAddUnit(const QString &inFileName, PProjectModelNo
// Determine compilation flags // Determine compilation flags
switch(getFileType(inFileName)) { switch(getFileType(inFileName)) {
case FileType::GAS:
newUnit->setCompile(true);
newUnit->setCompileCpp(false);
newUnit->setLink(true);
break;
case FileType::ASM: case FileType::ASM:
newUnit->setCompile(true); newUnit->setCompile(true);
newUnit->setCompileCpp(false); newUnit->setCompileCpp(false);

View File

@ -84,6 +84,7 @@
#define RES_EXT "res" #define RES_EXT "res"
#define H_EXT "h" #define H_EXT "h"
#define OBJ_EXT "o" #define OBJ_EXT "o"
#define LST_EXT "lst"
#define DEF_EXT "def" #define DEF_EXT "def"
#define LIB_EXT "a" #define LIB_EXT "a"
#define GCH_EXT "gch" #define GCH_EXT "gch"

View File

@ -86,6 +86,9 @@ FileType getFileType(const QString &filename)
if (filename.endsWith(".asm",PATH_SENSITIVITY)) { if (filename.endsWith(".asm",PATH_SENSITIVITY)) {
return FileType::ASM; return FileType::ASM;
} }
if (filename.endsWith(".s",PATH_SENSITIVITY)) {
return FileType::GAS;
}
if (filename.endsWith(".dev",PATH_SENSITIVITY)) { if (filename.endsWith(".dev",PATH_SENSITIVITY)) {
return FileType::Project; return FileType::Project;
} }

View File

@ -33,6 +33,7 @@ using PSimpleIni = std::shared_ptr<SimpleIni>;
enum class FileType{ enum class FileType{
ASM, // asm source file (.asm) ASM, // asm source file (.asm)
GAS, // GNU assembler source file (.s)
CSource, // c source file (.c) CSource, // c source file (.c)
CppSource, // c++ source file (.cpp) CppSource, // c++ source file (.cpp)
CHeader, // c header (.h) CHeader, // c header (.h)

View File

@ -1611,12 +1611,6 @@ int QSynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent
QString trimmedLineText = lineText.trimmed(); QString trimmedLineText = lineText.trimmed();
mSyntaxer->setState(rangePreceeding); mSyntaxer->setState(rangePreceeding);
mSyntaxer->setLine(trimmedLineText,line-1); mSyntaxer->setLine(trimmedLineText,line-1);
int statePrePre;
if (startLine>1) {
statePrePre = mDocument->getSyntaxState(startLine-2).state;
} else {
statePrePre = 0;
}
SyntaxState rangeAfterFirstToken = mSyntaxer->getState(); SyntaxState rangeAfterFirstToken = mSyntaxer->getState();
QString firstToken = mSyntaxer->getToken(); QString firstToken = mSyntaxer->getToken();
PTokenAttribute attr = mSyntaxer->getTokenAttribute(); PTokenAttribute attr = mSyntaxer->getTokenAttribute();

View File

@ -98,7 +98,7 @@ QSet<QString> Syntaxer::keywords() const
return QSet<QString>(); return QSet<QString>();
} }
QString Syntaxer::foldString(QString startLine) QString Syntaxer::foldString(QString /*startLine*/)
{ {
return " ... }"; return " ... }";
} }