- enhancement: Use lldb-mi as the debugger.

- enhancement: Set lldb-mi as the debugger program for clang, when finding compiler set in folders.
This commit is contained in:
Roy Qu 2023-01-22 22:19:19 +08:00
parent c5331f0597
commit 7d2920198e
7 changed files with 80 additions and 15 deletions

View File

@ -11,6 +11,8 @@ Red Panda C++ Version 2.10
- fix: If buttons in the options dialog / compiler / compiler set page is pressed, they won't release. - fix: If buttons in the options dialog / compiler / compiler set page is pressed, they won't release.
- enhancement: Confirm before remove a compiler set. - enhancement: Confirm before remove a compiler set.
- enhancement: If there is "cppreference.chm" or "cppreference-%locale_name%.chm"(like cppreference-zh_CN.chm) in the redpanda C++'s app folder, open it instead of the cppreference website. - enhancement: If there is "cppreference.chm" or "cppreference-%locale_name%.chm"(like cppreference-zh_CN.chm) in the redpanda C++'s app folder, open it instead of the cppreference website.
- enhancement: Use lldb-mi as the debugger.
- enhancement: Set lldb-mi as the debugger program for clang, when finding compiler set in folders.
Red Panda C++ Version 2.9 Red Panda C++ Version 2.9

View File

@ -35,6 +35,7 @@
Debugger::Debugger(QObject *parent) : QObject(parent), Debugger::Debugger(QObject *parent) : QObject(parent),
mForceUTF8(false), mForceUTF8(false),
mDebuggerType(DebuggerType::GDB),
mLastLoadtime(0), mLastLoadtime(0),
mProjectLastLoadtime(0) mProjectLastLoadtime(0)
{ {
@ -84,6 +85,10 @@ bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStrin
return false; return false;
} }
setForceUTF8(CompilerInfoManager::forceUTF8InDebugger(compilerSet->compilerType())); setForceUTF8(CompilerInfoManager::forceUTF8InDebugger(compilerSet->compilerType()));
if (compilerSet->debugger().endsWith(LLDB_MI_PROGRAM))
setDebuggerType(DebuggerType::LLDB_MI);
else
setDebuggerType(DebuggerType::GDB);
mExecuting = true; mExecuting = true;
QString debuggerPath = compilerSet->debugger(); QString debuggerPath = compilerSet->debugger();
//QFile debuggerProgram(debuggerPath); //QFile debuggerProgram(debuggerPath);
@ -507,8 +512,15 @@ void Debugger::refreshWatchVars()
{ {
if (mExecuting) { if (mExecuting) {
sendAllWatchVarsToDebugger(); sendAllWatchVarsToDebugger();
if (mDebuggerType==DebuggerType::LLDB_MI) {
for (PWatchVar var:mWatchModel->watchVars()) {
if (!var->name.isEmpty())
sendCommand("-var-update",QString(" --all-values %1").arg(var->name));
}
} else {
sendCommand("-var-update"," --all-values *"); sendCommand("-var-update"," --all-values *");
} }
}
} }
void Debugger::fetchVarChildren(const QString &varName) void Debugger::fetchVarChildren(const QString &varName)
@ -518,6 +530,16 @@ void Debugger::fetchVarChildren(const QString &varName)
} }
} }
DebuggerType Debugger::debuggerType() const
{
return mDebuggerType;
}
void Debugger::setDebuggerType(DebuggerType newDebuggerType)
{
mDebuggerType = newDebuggerType;
}
bool Debugger::forceUTF8() const bool Debugger::forceUTF8() const
{ {
return mForceUTF8; return mForceUTF8;
@ -606,10 +628,17 @@ void Debugger::sendBreakpointCommand(PBreakpoint breakpoint)
} }
QString filename = breakpoint->filename; QString filename = breakpoint->filename;
filename.replace('\\','/'); filename.replace('\\','/');
if (debuggerType()==DebuggerType::LLDB_MI) {
sendCommand("-break-insert", sendCommand("-break-insert",
QString("%1 --source \"%2\" --line %3") QString("%1 \"%2:%3\"")
.arg(condition,filename) .arg(condition, filename)
.arg(breakpoint->line)); .arg(breakpoint->line));
} else {
// sendCommand("-break-insert",
// QString("%1 --source \"%2\" --line %3")
// .arg(condition,filename)
// .arg(breakpoint->line));
}
} }
} }
@ -1261,11 +1290,14 @@ void DebugReader::runNextCmd()
} }
//clang compatibility //clang compatibility
if (pCmd->command == "-break-insert" && mDebugger->forceUTF8()) { if (mDebugger->forceUTF8()) {
params = pCmd->params.toUtf8(); params = pCmd->params.toUtf8();
} }
if (pCmd->command == "-var-create") { if (pCmd->command == "-var-create") {
//hack for variable creation,to easy remember var expression //hack for variable creation,to easy remember var expression
if (mDebugger->debuggerType()==DebuggerType::LLDB_MI)
params = " - * "+params;
else
params = " - @ "+params; params = " - @ "+params;
} else if (pCmd->command == "-var-list-children") { } else if (pCmd->command == "-var-list-children") {
//hack for list variable children,to easy remember var expression //hack for list variable children,to easy remember var expression
@ -1565,8 +1597,9 @@ QByteArray DebugReader::removeToken(const QByteArray &line)
void DebugReader::asyncUpdate() void DebugReader::asyncUpdate()
{ {
QMutexLocker locker(&mCmdQueueMutex); QMutexLocker locker(&mCmdQueueMutex);
if (mCmdQueue.isEmpty()) if (mCmdQueue.isEmpty()) {
postCommand("-var-update"," --all-values *",DebugCommandSource::HeartBeat); postCommand("-var-update"," --all-values *",DebugCommandSource::HeartBeat);
}
mAsyncUpdated = false; mAsyncUpdated = false;
} }

View File

@ -39,6 +39,11 @@ enum class DebugCommandSource {
Other Other
}; };
enum class DebuggerType {
GDB,
LLDB_MI
};
struct DebugCommand{ struct DebugCommand{
QString command; QString command;
QString params; QString params;
@ -342,6 +347,7 @@ public:
void sendAllWatchVarsToDebugger(); void sendAllWatchVarsToDebugger();
PWatchVar findWatchVar(const QString& expression); PWatchVar findWatchVar(const QString& expression);
PWatchVar watchVarAt(const QModelIndex& index); PWatchVar watchVarAt(const QModelIndex& index);
void refreshVars();
// void notifyWatchVarUpdated(PWatchVar var); // void notifyWatchVarUpdated(PWatchVar var);
std::shared_ptr<BacktraceModel> backtraceModel(); std::shared_ptr<BacktraceModel> backtraceModel();
@ -360,6 +366,9 @@ public:
bool forceUTF8() const; bool forceUTF8() const;
void setForceUTF8(bool newForceUTF8); void setForceUTF8(bool newForceUTF8);
DebuggerType debuggerType() const;
void setDebuggerType(DebuggerType newDebuggerType);
signals: signals:
void evalValueReady(const QString& s); void evalValueReady(const QString& s);
void memoryExamineReady(const QStringList& s); void memoryExamineReady(const QStringList& s);
@ -402,6 +411,7 @@ private:
DebugReader *mReader; DebugReader *mReader;
DebugTarget *mTarget; DebugTarget *mTarget;
bool mForceUTF8; bool mForceUTF8;
DebuggerType mDebuggerType;
int mLeftPageIndexBackup; int mLeftPageIndexBackup;
qint64 mLastLoadtime; qint64 mLastLoadtime;
qint64 mProjectLastLoadtime; qint64 mProjectLastLoadtime;

View File

@ -374,12 +374,22 @@ int GDBMIResultParser::ParseValue::hexValue(int defaultValue) const
QString GDBMIResultParser::ParseValue::pathValue() const QString GDBMIResultParser::ParseValue::pathValue() const
{ {
//Q_ASSERT(mType == ParseValueType::Value); //Q_ASSERT(mType == ParseValueType::Value);
return QFileInfo(QString::fromLocal8Bit(mValue)).absoluteFilePath(); QByteArray value=mValue;
#ifdef Q_OS_WIN
if (value.startsWith("/") && !value.startsWith("//"))
value=value.mid(1);
#endif
return QFileInfo(QString::fromLocal8Bit(value)).absoluteFilePath();
} }
QString GDBMIResultParser::ParseValue::utf8PathValue() const QString GDBMIResultParser::ParseValue::utf8PathValue() const
{ {
return QFileInfo(QString::fromUtf8(mValue)).absoluteFilePath(); QByteArray value=mValue;
#ifdef Q_OS_WIN
if (value.startsWith("/") && !value.startsWith("//"))
value=value.mid(1);
#endif
return QFileInfo(QString::fromUtf8(value)).absoluteFilePath();
} }
GDBMIResultParser::ParseValueType GDBMIResultParser::ParseValue::type() const GDBMIResultParser::ParseValueType GDBMIResultParser::ParseValue::type() const

View File

@ -1001,11 +1001,13 @@ void MainWindow::removeActiveBreakpoints()
} }
} }
void MainWindow::setActiveBreakpoint(QString FileName, int Line, bool setFocus) void MainWindow::setActiveBreakpoint(QString fileName, int Line, bool setFocus)
{ {
removeActiveBreakpoints(); removeActiveBreakpoints();
if (!fileExists(fileName))
return;
// Then active the current line in the current file // Then active the current line in the current file
Editor *e = openFile(FileName); Editor *e = openFile(fileName);
if (e!=nullptr) { if (e!=nullptr) {
e->setActiveBreakpointFocus(Line,setFocus); e->setActiveBreakpointFocus(Line,setFocus);
} }

View File

@ -2305,8 +2305,13 @@ void Settings::CompilerSet::setExecutables()
if (mCompilerType == CompilerType::Clang) { if (mCompilerType == CompilerType::Clang) {
mCCompiler = findProgramInBinDirs(CLANG_PROGRAM); mCCompiler = findProgramInBinDirs(CLANG_PROGRAM);
mCppCompiler = findProgramInBinDirs(CLANG_CPP_PROGRAM); mCppCompiler = findProgramInBinDirs(CLANG_CPP_PROGRAM);
mDebugger = findProgramInBinDirs(LLDB_MI_PROGRAM);
if (mDebugger.isEmpty()) {
mDebugger = findProgramInBinDirs(GDB_PROGRAM); mDebugger = findProgramInBinDirs(GDB_PROGRAM);
mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM); mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM);
} else {
mDebugServer = findProgramInBinDirs(LLDB_SERVER_PROGRAM);
}
if (mCCompiler.isEmpty()) if (mCCompiler.isEmpty())
mCCompiler = findProgramInBinDirs(GCC_PROGRAM); mCCompiler = findProgramInBinDirs(GCC_PROGRAM);
if (mCppCompiler.isEmpty()) if (mCppCompiler.isEmpty())

View File

@ -36,6 +36,7 @@
#define CLANG_PROGRAM "clang.exe" #define CLANG_PROGRAM "clang.exe"
#define CLANG_CPP_PROGRAM "clang++.exe" #define CLANG_CPP_PROGRAM "clang++.exe"
#define LLDB_MI_PROGRAM "lldb-mi.exe" #define LLDB_MI_PROGRAM "lldb-mi.exe"
#define LLDB_SERVER_PROGRAM "lldb-server.exe"
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
#define CONSOLE_PAUSER "consolepauser" #define CONSOLE_PAUSER "consolepauser"
#define GCC_PROGRAM "gcc" #define GCC_PROGRAM "gcc"
@ -52,6 +53,7 @@
#define CLANG_PROGRAM "clang" #define CLANG_PROGRAM "clang"
#define CLANG_CPP_PROGRAM "clang++" #define CLANG_CPP_PROGRAM "clang++"
#define LLDB_MI_PROGRAM "lldb-mi" #define LLDB_MI_PROGRAM "lldb-mi"
#define LLDB_SERVER_PROGRAM "lldb-server"
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
#define GCC_PROGRAM "gcc" #define GCC_PROGRAM "gcc"
#define GPP_PROGRAM "g++" #define GPP_PROGRAM "g++"
@ -67,8 +69,9 @@
#define CLANG_PROGRAM "clang" #define CLANG_PROGRAM "clang"
#define CLANG_CPP_PROGRAM "clang++" #define CLANG_CPP_PROGRAM "clang++"
#define LLDB_MI_PROGRAM "lldb-mi" #define LLDB_MI_PROGRAM "lldb-mi"
#define LLDB_SERVER_PROGRAM "lldb-server"
#else #else
#error "Only support windows and linux now!" #error "Only support windows, Linux and MacOS now!"
#endif #endif
#define DEV_PROJECT_EXT "dev" #define DEV_PROJECT_EXT "dev"