Skip to content

Commit

Permalink
try to invoke set print characters when gdb starts
Browse files Browse the repository at this point in the history
  • Loading branch information
royqh1979 committed Jul 14, 2023
1 parent 41611d6 commit 2c999dd
Show file tree
Hide file tree
Showing 9 changed files with 439 additions and 377 deletions.
3 changes: 1 addition & 2 deletions RedPandaIDE/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,11 +1626,10 @@ void DebugReader::handleStack(const QList<GDBMIResultParser::ParseValue> & stack
void DebugReader::handleLocalVariables(const QList<GDBMIResultParser::ParseValue> &variables)
{
QStringList locals;
QRegularExpression exp("<repeats\\s+(\\d+)\\s+times>");
foreach (const GDBMIResultParser::ParseValue& varValue, variables) {
GDBMIResultParser::ParseObject varObject = varValue.object();
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(
QString("%1 = %2")
.arg(
Expand Down
3 changes: 2 additions & 1 deletion RedPandaIDE/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,8 @@ void MainWindow::debug()
mDebugger->sendCommand("-gdb-set", "confirm off");
mDebugger->sendCommand("-gdb-set", "print repeats 10");
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
if (pSettings->debugger().useGDBServer()) {
mDebugger->sendCommand("-target-select",QString("remote localhost:%1").arg(pSettings->debugger().GDBServerPort()));
Expand Down
14 changes: 13 additions & 1 deletion RedPandaIDE/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4010,6 +4010,16 @@ void Settings::Debugger::setArrayElements(int newArrayElements)
mArrayElements = newArrayElements;
}

int Settings::Debugger::characters() const
{
return mCharacters;
}

void Settings::Debugger::setCharacters(int newCharacters)
{
mCharacters = newCharacters;
}

bool Settings::Debugger::useIntelStyle() const
{
return mUseIntelStyle;
Expand Down Expand Up @@ -4059,6 +4069,7 @@ void Settings::Debugger::doSave()
saveValue("memory_view_rows",mMemoryViewRows);
saveValue("memory_view_columns",mMemoryViewColumns);
saveValue("array_elements",mArrayElements);
saveValue("string_characters",mCharacters);
}

void Settings::Debugger::doLoad()
Expand Down Expand Up @@ -4087,7 +4098,8 @@ void Settings::Debugger::doLoad()
mGDBServerPort = intValue("gdb_server_port",41234);
mMemoryViewRows = intValue("memory_view_rows",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)
Expand Down
4 changes: 4 additions & 0 deletions RedPandaIDE/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,9 @@ class Settings
int arrayElements() const;
void setArrayElements(int newArrayElements);

int characters() const;
void setCharacters(int newCharacters);

private:
bool mEnableDebugConsole;
bool mShowDetailLog;
Expand All @@ -1306,6 +1309,7 @@ class Settings
int mMemoryViewRows;
int mMemoryViewColumns;
int mArrayElements;
int mCharacters;

// _Base interface
protected:
Expand Down
3 changes: 3 additions & 0 deletions RedPandaIDE/settingsdialog/debuggeneralwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ DebugGeneralWidget::DebugGeneralWidget(const QString& name, const QString& group
ui(new Ui::DebugGeneralWidget)
{
ui->setupUi(this);
ui->panelCharacters->setVisible(false);
}

DebugGeneralWidget::~DebugGeneralWidget()
Expand Down Expand Up @@ -57,6 +58,7 @@ void DebugGeneralWidget::doLoad()
ui->spinMemoryViewRows->setValue(pSettings->debugger().memoryViewRows());
ui->spinMemoryViewColumns->setValue(pSettings->debugger().memoryViewColumns());
ui->spinArrayElements->setValue(pSettings->debugger().arrayElements());
ui->spinCharacters->setValue(pSettings->debugger().characters());
}

void DebugGeneralWidget::doSave()
Expand All @@ -81,6 +83,7 @@ void DebugGeneralWidget::doSave()
pSettings->debugger().setMemoryViewRows(ui->spinMemoryViewRows->value());
pSettings->debugger().setMemoryViewColumns(ui->spinMemoryViewColumns->value());
pSettings->debugger().setArrayElements(ui->spinArrayElements->value());
pSettings->debugger().setCharacters(ui->spinCharacters->value());

pSettings->debugger().save();
pMainWindow->updateDebuggerSettings();
Expand Down
45 changes: 45 additions & 0 deletions RedPandaIDE/settingsdialog/debuggeneralwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,51 @@
</layout>
</widget>
</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>
<widget class="QGroupBox" name="grpUseGDBServer">
<property name="title">
Expand Down
5 changes: 1 addition & 4 deletions RedPandaIDE/translations/RedPandaIDE_pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,11 +928,8 @@
<source>Columns</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DebugReader</name>
<message>
<source>&lt;repeats \1 times&gt;</source>
<source>Max characters of a string displayed</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
Loading

0 comments on commit 2c999dd

Please sign in to comment.