try to invoke set print characters when gdb starts

This commit is contained in:
Roy Qu 2023-07-14 08:30:21 +08:00
parent 41611d6ab6
commit 2c999dd8ed
9 changed files with 439 additions and 377 deletions

View File

@ -1626,11 +1626,10 @@ void DebugReader::handleStack(const QList<GDBMIResultParser::ParseValue> & stack
void DebugReader::handleLocalVariables(const QList<GDBMIResultParser::ParseValue> &variables) void DebugReader::handleLocalVariables(const QList<GDBMIResultParser::ParseValue> &variables)
{ {
QStringList locals; QStringList locals;
QRegularExpression exp("<repeats\\s+(\\d+)\\s+times>");
foreach (const GDBMIResultParser::ParseValue& varValue, variables) { foreach (const GDBMIResultParser::ParseValue& varValue, variables) {
GDBMIResultParser::ParseObject varObject = varValue.object(); GDBMIResultParser::ParseObject varObject = varValue.object();
QString name = QString(varObject["name"].value()); QString name = QString(varObject["name"].value());
QString value = QString(varObject["value"].value()).replace(exp, tr("<repeats \\1 times>")); QString value = QString(varObject["value"].value());
locals.append( locals.append(
QString("%1 = %2") QString("%1 = %2")
.arg( .arg(

View File

@ -2426,7 +2426,8 @@ void MainWindow::debug()
mDebugger->sendCommand("-gdb-set", "confirm off"); mDebugger->sendCommand("-gdb-set", "confirm off");
mDebugger->sendCommand("-gdb-set", "print repeats 10"); mDebugger->sendCommand("-gdb-set", "print repeats 10");
mDebugger->sendCommand("-gdb-set", "print null-stop"); mDebugger->sendCommand("-gdb-set", "print null-stop");
mDebugger->sendCommand("-gdb-set", QString("print elements %1").arg(pSettings->debugger().arrayElements())); // limit array elements to 500 mDebugger->sendCommand("-gdb-set", QString("print elements %1").arg(pSettings->debugger().arrayElements())); // limit array elements to 30
mDebugger->sendCommand("-gdb-set", QString("print characters %1").arg(pSettings->debugger().characters())); // limit array elements to 300
//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()) { if (pSettings->debugger().useGDBServer()) {
mDebugger->sendCommand("-target-select",QString("remote localhost:%1").arg(pSettings->debugger().GDBServerPort())); mDebugger->sendCommand("-target-select",QString("remote localhost:%1").arg(pSettings->debugger().GDBServerPort()));

View File

@ -4010,6 +4010,16 @@ void Settings::Debugger::setArrayElements(int newArrayElements)
mArrayElements = newArrayElements; mArrayElements = newArrayElements;
} }
int Settings::Debugger::characters() const
{
return mCharacters;
}
void Settings::Debugger::setCharacters(int newCharacters)
{
mCharacters = newCharacters;
}
bool Settings::Debugger::useIntelStyle() const bool Settings::Debugger::useIntelStyle() const
{ {
return mUseIntelStyle; return mUseIntelStyle;
@ -4059,6 +4069,7 @@ void Settings::Debugger::doSave()
saveValue("memory_view_rows",mMemoryViewRows); saveValue("memory_view_rows",mMemoryViewRows);
saveValue("memory_view_columns",mMemoryViewColumns); saveValue("memory_view_columns",mMemoryViewColumns);
saveValue("array_elements",mArrayElements); saveValue("array_elements",mArrayElements);
saveValue("string_characters",mCharacters);
} }
void Settings::Debugger::doLoad() void Settings::Debugger::doLoad()
@ -4087,7 +4098,8 @@ void Settings::Debugger::doLoad()
mGDBServerPort = intValue("gdb_server_port",41234); mGDBServerPort = intValue("gdb_server_port",41234);
mMemoryViewRows = intValue("memory_view_rows",16); mMemoryViewRows = intValue("memory_view_rows",16);
mMemoryViewColumns = intValue("memory_view_columns",16); mMemoryViewColumns = intValue("memory_view_columns",16);
mArrayElements = intValue("array_elements",300); mArrayElements = intValue("array_elements",100);
mCharacters = intValue("string_characters",300);
} }
Settings::CodeCompletion::CodeCompletion(Settings *settings):_Base(settings, SETTING_CODE_COMPLETION) Settings::CodeCompletion::CodeCompletion(Settings *settings):_Base(settings, SETTING_CODE_COMPLETION)

View File

@ -1288,6 +1288,9 @@ public:
int arrayElements() const; int arrayElements() const;
void setArrayElements(int newArrayElements); void setArrayElements(int newArrayElements);
int characters() const;
void setCharacters(int newCharacters);
private: private:
bool mEnableDebugConsole; bool mEnableDebugConsole;
bool mShowDetailLog; bool mShowDetailLog;
@ -1306,6 +1309,7 @@ public:
int mMemoryViewRows; int mMemoryViewRows;
int mMemoryViewColumns; int mMemoryViewColumns;
int mArrayElements; int mArrayElements;
int mCharacters;
// _Base interface // _Base interface
protected: protected:

View File

@ -24,6 +24,7 @@ DebugGeneralWidget::DebugGeneralWidget(const QString& name, const QString& group
ui(new Ui::DebugGeneralWidget) ui(new Ui::DebugGeneralWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->panelCharacters->setVisible(false);
} }
DebugGeneralWidget::~DebugGeneralWidget() DebugGeneralWidget::~DebugGeneralWidget()
@ -57,6 +58,7 @@ void DebugGeneralWidget::doLoad()
ui->spinMemoryViewRows->setValue(pSettings->debugger().memoryViewRows()); ui->spinMemoryViewRows->setValue(pSettings->debugger().memoryViewRows());
ui->spinMemoryViewColumns->setValue(pSettings->debugger().memoryViewColumns()); ui->spinMemoryViewColumns->setValue(pSettings->debugger().memoryViewColumns());
ui->spinArrayElements->setValue(pSettings->debugger().arrayElements()); ui->spinArrayElements->setValue(pSettings->debugger().arrayElements());
ui->spinCharacters->setValue(pSettings->debugger().characters());
} }
void DebugGeneralWidget::doSave() void DebugGeneralWidget::doSave()
@ -81,6 +83,7 @@ void DebugGeneralWidget::doSave()
pSettings->debugger().setMemoryViewRows(ui->spinMemoryViewRows->value()); pSettings->debugger().setMemoryViewRows(ui->spinMemoryViewRows->value());
pSettings->debugger().setMemoryViewColumns(ui->spinMemoryViewColumns->value()); pSettings->debugger().setMemoryViewColumns(ui->spinMemoryViewColumns->value());
pSettings->debugger().setArrayElements(ui->spinArrayElements->value()); pSettings->debugger().setArrayElements(ui->spinArrayElements->value());
pSettings->debugger().setCharacters(ui->spinCharacters->value());
pSettings->debugger().save(); pSettings->debugger().save();
pMainWindow->updateDebuggerSettings(); pMainWindow->updateDebuggerSettings();

View File

@ -66,6 +66,51 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QWidget" name="panelCharacters" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Max characters of a string displayed</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinCharacters">
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="grpUseGDBServer"> <widget class="QGroupBox" name="grpUseGDBServer">
<property name="title"> <property name="title">

View File

@ -928,11 +928,8 @@
<source>Columns</source> <source>Columns</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context>
<context>
<name>DebugReader</name>
<message> <message>
<source>&lt;repeats \1 times&gt;</source> <source>Max characters of a string displayed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>

File diff suppressed because it is too large Load Diff

View File

@ -789,11 +789,8 @@
<source>Columns</source> <source>Columns</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context>
<context>
<name>DebugReader</name>
<message> <message>
<source>&lt;repeats \1 times&gt;</source> <source>Max characters of a string displayed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>