check windows version and decide if the debug info in the executable files is utf8 encoded.

This commit is contained in:
Roy Qu 2023-06-27 11:50:43 +08:00
parent b85b70bb4b
commit 0e1decad65
9 changed files with 693 additions and 642 deletions

View File

@ -12,6 +12,7 @@ Red Panda C++ Version 2.23
- enhancement: improve parsing for multiple vars defined in one line
- enhancement: improve parsing result for function parameters like 'Node (&node)[10]'
- fix: Can't copy by ctrl+dray&drop to current selection's begin/end
- enhancement: Support debug executable files generated by mingw-w64 gcc 13.1 and filepath contains non-ascii chars.
Red Panda C++ Version 2.22

View File

@ -85,6 +85,27 @@ bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStrin
return false;
}
setForceUTF8(CompilerInfoManager::forceUTF8InDebugger(compilerSet->compilerType()));
setDebugInfosUsingUTF8(false);
#ifdef Q_OS_WIN
bool isOk;
int productVersion = QSysInfo::productVersion().toInt(&isOk);
// qDebug()<<productVersion<<isOk;
if (!isOk) {
if (QSysInfo::productVersion().startsWith("7"))
productVersion=7;
else if (QSysInfo::productVersion().startsWith("10"))
productVersion=10;
else if (QSysInfo::productVersion().startsWith("11"))
productVersion=11;
else
productVersion=10;
}
if (compilerSet->mainVersion()>=13 && compilerSet->compilerType()==CompilerType::GCC
&& productVersion>=10)
setDebugInfosUsingUTF8(true);
#endif
if (compilerSet->debugger().endsWith(LLDB_MI_PROGRAM))
setDebuggerType(DebuggerType::LLDB_MI);
else
@ -560,6 +581,16 @@ void Debugger::fetchVarChildren(const QString &varName)
}
}
bool Debugger::debugInfosUsingUTF8() const
{
return mDebugInfosUsingUTF8;
}
void Debugger::setDebugInfosUsingUTF8(bool newDebugInfosUsingUTF8)
{
mDebugInfosUsingUTF8 = newDebugInfosUsingUTF8;
}
DebuggerType Debugger::debuggerType() const
{
return mDebuggerType;
@ -1356,6 +1387,13 @@ void DebugReader::runNextCmd()
//clang compatibility
if (mDebugger->forceUTF8()) {
params = pCmd->params.toUtf8();
} else if (mDebugger->debugInfosUsingUTF8() &&
(pCmd->command=="-break-insert"
|| pCmd->command=="-var-create"
|| pCmd->command=="-data-read-memory"
|| pCmd->command=="-data-evaluate-expression"
)) {
params = pCmd->params.toUtf8();
}
if (pCmd->command == "-var-create") {
//hack for variable creation,to easy remember var expression
@ -1493,7 +1531,7 @@ void DebugReader::handleBreakpoint(const GDBMIResultParser::ParseObject& breakpo
{
QString filename;
// gdb use system encoding for file path
if (mDebugger->forceUTF8())
if (mDebugger->forceUTF8() || mDebugger->debugInfosUsingUTF8())
filename = breakpoint["fullname"].utf8PathValue();
else
filename = breakpoint["fullname"].pathValue();
@ -1511,7 +1549,8 @@ void DebugReader::handleFrame(const GDBMIResultParser::ParseValue &frame)
if (!ok)
mCurrentAddress=0;
mCurrentLine = frameObj["line"].intValue();
if (mDebugger->forceUTF8())
if (mDebugger->forceUTF8()
|| mDebugger->debugInfosUsingUTF8())
mCurrentFile = frameObj["fullname"].utf8PathValue();
else
mCurrentFile = frameObj["fullname"].pathValue();
@ -1526,7 +1565,7 @@ void DebugReader::handleStack(const QList<GDBMIResultParser::ParseValue> & stack
GDBMIResultParser::ParseObject frameObject = frameValue.object();
PTrace trace = std::make_shared<Trace>();
trace->funcname = frameObject["func"].value();
if (mDebugger->forceUTF8())
if (mDebugger->forceUTF8() || mDebugger->debugInfosUsingUTF8())
trace->filename = frameObject["fullname"].utf8PathValue();
else
trace->filename = frameObject["fullname"].pathValue();

View File

@ -372,6 +372,9 @@ public:
DebuggerType debuggerType() const;
void setDebuggerType(DebuggerType newDebuggerType);
bool debugInfosUsingUTF8() const;
void setDebugInfosUsingUTF8(bool newDebugInfosUsingUTF8);
signals:
void evalValueReady(const QString& s);
void memoryExamineReady(const QStringList& s);
@ -414,6 +417,7 @@ private:
DebugReader *mReader;
DebugTarget *mTarget;
bool mForceUTF8;
bool mDebugInfosUsingUTF8;
DebuggerType mDebuggerType;
int mLeftPageIndexBackup;
qint64 mLastLoadtime;

View File

@ -2417,7 +2417,7 @@ void MainWindow::debug()
mDebugger->sendCommand("-gdb-set", "confirm off");
mDebugger->sendCommand("-gdb-set", "print repeats 0"); // don't repeat elements
mDebugger->sendCommand("-gdb-set", QString("print elements %1").arg(pSettings->debugger().arrayElements())); // limit array elements to 500
mDebugger->sendCommand("-environment-cd", QString("\"%1\"").arg(extractFileDir(filePath))); // restore working directory
//mDebugger->sendCommand("-environment-cd", QString("\"%1\"").arg(extractFileDir(filePath))); // restore working directory
if (pSettings->debugger().useGDBServer()) {
mDebugger->sendCommand("-target-select",QString("remote localhost:%1").arg(pSettings->debugger().GDBServerPort()));
if (!debugInferiorhasBreakpoint() || !debugEnabled) {
@ -9942,4 +9942,3 @@ void MainWindow::on_actionClose_Others_triggered()
}
mClosing = false;
}

View File

@ -183,7 +183,7 @@
</message>
<message>
<source>Disassemble</source>
<translation>Disassemble</translation>
<translation type="vanished">Disassemble</translation>
</message>
<message>
<source>Step over one machine instruction</source>
@ -205,6 +205,10 @@
<source>Blend Mode</source>
<translation>Modo mesclado</translation>
</message>
<message>
<source>Callstack</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CharsetInfoManager</name>

File diff suppressed because it is too large Load Diff

View File

@ -161,10 +161,6 @@
<source>CPU Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disassemble</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Step over one machine instruction</source>
<translation type="unfinished"></translation>
@ -185,6 +181,10 @@
<source>Blend Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Callstack</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChooseThemeDialog</name>

View File

@ -66,10 +66,41 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="btnStepOverInstruction">
<property name="toolTip">
<string>Step over one machine instruction</string>
</property>
<property name="text">
<string>Step over one machine instruction</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/052-next.png</normaloff>:/icons/images/newlook24/052-next.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnStepIntoInstruction">
<property name="toolTip">
<string>Step into one machine instruction</string>
</property>
<property name="text">
<string>Step into one machine instruction</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/040-goto.png</normaloff>:/icons/images/newlook24/040-goto.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Disassemble</string>
<string>Callstack</string>
</property>
</widget>
</item>
@ -120,37 +151,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="btnStepOverInstruction">
<property name="toolTip">
<string>Step over one machine instruction</string>
</property>
<property name="text">
<string>Step over one machine instruction</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/052-next.png</normaloff>:/icons/images/newlook24/052-next.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnStepIntoInstruction">
<property name="toolTip">
<string>Step into one machine instruction</string>
</property>
<property name="text">
<string>Step into one machine instruction</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/040-goto.png</normaloff>:/icons/images/newlook24/040-goto.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

View File

@ -1,6 +1,6 @@
####################################################################
# Startup
!define COMPILERNAME \"MinGW-w64 X86_64 GCC 11.4\"
!define COMPILERNAME \"MinGW-w64 X86_64 GCC 13.1\"
!define DEVCPP_VERSION \"$${APP_VERSION}\"