diff --git a/NEWS.md b/NEWS.md index a454e886..78b5bc9b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,9 +10,11 @@ Version 0.2.2 - enhancement: redesign charset selection in the project options dialog's file widget - fix: can't correctly load last open files / project with non-asii characters in path - fix: can't coorectly load last open project + - fix: can't coorectly show code completion for array elements - enhancement: show caret when show code/header completions - fix: correctly display pointer info in watch console - enhancement: search in project + - enhancement: view memory when debugging Version 0.2.1 - fix: crash when load last opens diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index 4cc6142d..dee41697 100644 Binary files a/RedPandaIDE/RedPandaIDE_zh_CN.qm and b/RedPandaIDE/RedPandaIDE_zh_CN.qm differ diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index 7867d260..75360066 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -27,17 +27,17 @@ BacktraceModel - + Function 函数 - + Filename 文件名 - + Line @@ -45,17 +45,17 @@ BreakpointModel - + Filename 文件名 - + Line - + Condition 条件 @@ -702,28 +702,28 @@ Are you really want to continue? 找不到调试器程序"%1" - - + + Execute to evaluate 执行以求值 - + Not found in current context 不在当前语境中 - + Compile 编译 - + Source file is more recent than executable. 源文件比程序文件新。 - + Recompile? 重新编译? @@ -2304,7 +2304,7 @@ Are you really want to continue? - + Issues 编译器 @@ -2314,29 +2314,29 @@ Are you really want to continue? 编译日志 - + File 文件 - + Tools 工具 - - + + Run 运行 - + Edit 编辑 - + Project 项目 @@ -2361,81 +2361,81 @@ Are you really want to continue? - - - + + + Debug 调试 - + Evaluate: 求值 - + Debug Console 调试主控台 - + Call Stack 调用栈 - + Breakpoints 断点 - + Locals 本地变量 - - + + Search 查找 - + History: 历史: - + Search Again 重新查找 - + Replace with: 替换为: - + Replace 替换 - + Close 关闭 - + Execute 运行 - - + + Code 代码 - + Window 窗口 @@ -2453,558 +2453,569 @@ Are you really want to continue? 新建 - + Ctrl+N Ctrl+N - + Open... 打开... - + Ctrl+O Ctrl+O - + Save 保存 - + Ctrl+S Ctrl+S - + Save As... 另存为... - + Save As 另存为 - + Save All 全部保存 - + Ctrl+Shift+S Ctrl+Shift+S - + Options 选项 - - - - - - - + + + + + + + Compile 编译 - + F9 F9 - + F10 F10 - + Undo 恢复 - + Ctrl+Z Ctrl+Z - + Redo 重做 - + Ctrl+Y Ctrl+Y - + Cut 剪切 - + Ctrl+X Ctrl+X - - + + Copy 复制 - + Ctrl+C Ctrl+C - + Paste 粘贴 - + Ctrl+V Ctrl+V - + Select All 选择全部 - + Ctrl+A Ctrl+A - + Indent 缩进 - + UnIndent 取消缩进 - + Toggle Comment 切换注释 - + Ctrl+/ Ctrl+/ - + Collapse All 全部收起 - + Uncollapse All 全部展开 - + Encode in ANSI 使用ANSI编码 - + Encode in UTF-8 使用UTF-8编码 - + Auto Detect 自动检测 - + Convert to ANSI 转换为ANSI编码 - + Convert to UTF-8 转换为UTF-8编码 - - + + Compile & Run 编译运行 - + F11 F11 - - + + Rebuild All 全部重编译 - + F12 F12 - + Stop Execution 停止执行 - + F6 F6 - + F5 F5 - + Step Over 单步跳过 - + F7 F7 - + Step Into 单步进入 - + + Memory + 内存 + + + + Address Expression: + Address: + 地址表达式: + + + Main 主工具栏 - + Compiler Set 编译器配置集 - - + + New Source File 新建源代码文件 - + F8 F8 - + Step Out 单步跳出 - + Ctrl+F8 Ctrl+F8 - + Run To Cursor 执行到光标处 - + Ctrl+F5 Ctrl+F5 - + Continue 继续执行 - + F4 F4 - + Add Watch... 添加监视 - + View CPU Window... 打开CPU信息窗口... - + Exit 退出 - + Find... 查找... - + Ctrl+F Ctrl+F - + Find in Files... 在文件中查找... - + Ctrl+Shift+F Ctrl+Shift+F - + Replace... 替换 - + Ctrl+R Ctrl+R - + Find Next 查找下一个 - + F3 F3 - + Find Previous 查找前一个 - + Shift+F3 Shift+F3 - + Remove Watch 删除监视 - + Remove All 清除全部监视 - + Modify Watch... 修改监视值 - + Reformat Code 对代码重新排版 - + Ctrl+Shift+A Ctrl+Shift+A - + Go back 前一次编辑位置 - + Ctrl+Alt+Left Ctrl+Alt+Left - + Forward 后一次编辑位置 - + Ctrl+Alt+Right Ctrl+Alt+Right - + Ctrl+W Ctrl+W - + Close All 全部关闭 - + Ctrl+Shift+W Ctrl+Shift+W - + Maximize Editor 最大化编辑器 - + Ctrl+F11 Ctrl+F11 - + Next 下一窗口 - + Ctrl+Tab Ctrl+Tab - + Previous 前一窗口 - + Ctrl+Shift+Tab Ctrl+Shift+Tab - + Toggle breakpoint 切换断点 - + Ctrl+F4 Ctrl+F4 - - + + Clear all breakpoints 删除所有断点 - + Breakpoint property... 设置断点条件... - + Goto Declaration 跳转到声明处 - + Goto Definition 跳转到定义处 - + Find references 查找符号的引用 - + Open containing folder 打开所在的文件夹 - + Ctrl+B Ctrl+B - + Open a terminal here 打开命令行窗口 - + File Properties... 文件属性... - + Close Project 关闭项目 - + Project options 项目属性 - + New Project... 新建项目... - + New File 新建项目文件 - + Add to project... 添加到项目... - + Remove from project 从项目删除 - + View Makefile 查看Makefile - + Clean 清理构建文件 - + Open Folder in Explorer 在浏览器中打开 - + Open In Terminal 在终端中打开 - + File Encoding 文件编码 @@ -3014,32 +3025,32 @@ Are you really want to continue? 文件历史 - - + - + + Debugging 正在调试 - - + - + + Running 正在运行 - - + - + + Compiling 正在编译 @@ -3048,349 +3059,349 @@ Are you really want to continue? 行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5 - + Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5 行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5 - + Read Only 只读 - + Insert 插入 - + Overwrite 覆写 - + Close project 关闭项目 - + Are you sure you want to close %1? 你确定要关闭'%1'吗? - - + + Confirm 确认 - - - + + + Source file is not compiled. 源文件尚未编译。 - - + + Compile now? 现在编译? - - + + Source file is more recent than executable. 源文件比可执行程序新。 - + Recompile now? 重新编译? - + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - - + + Enable debugging 启用调试参数 - - + + You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now? 当前编译设置中未启用调试选项(-g3),或启用了信息剥除选项(-s)<br /><br/>是否纠正这一问题? - + Project not built 项目尚未构建 - + Project hasn't been built. Build it now? 项目尚未构建。是否构建? - + Host applcation missing 宿主程序不存在 - + DLL project needs a host application to run. 动态链接库(DLL)需要一个宿主程序来运行。 - + But it's missing. 但它不存在。 - + Host application not exists 宿主程序不存在 - + Host application file '%1' doesn't exist. 宿主程序'%1'不存在。 - + Recompile? 重新编译? - - + + Save last open info error 保存上次打开信息失败 - + Can't remove old last open information file '%1' 无法删除旧上次打开信息文件'%1' - + Can't save last open info file '%1' 无法保存上次打开信息文件'%1' - + Load last open info error 载入上次打开信息失败 - + Can't load last open info file '%1' 无法载入上次打开信息文件'%1' - + Copy all 全部复制 - + Clear 清除 - + Remove this search 清除这次搜索 - + Clear all searches 删除所有搜索 - + Breakpoint condition... 断点条件... - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Remove all breakpoints 清除所有断点 - + Rename File 重命名文件 - - + + Add Folder 添加文件夹 - + New folder 新文件夹 - + Folder name: 文件夹: - + Rename Folder 重命名 - + Remove Folder 删除文件夹 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - + Character sets 字符集 - + %1 files autosaved 已自动保存%1个文件 - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - + Do you want to save it? 需要保存吗? - + Do you really want to clear all breakpoints in this file? 您真的要清除该文件的所有断点吗? - + New project 新建项目 - + Close %1 and start new project? 关闭'%1'以打开新项目? - + Folder not exist 文件夹不存在 - + Folder '%1' doesn't exist. Create it now? 文件夹'%1'不存在。是否创建? - + Can't create folder 无法创建文件夹 - + Failed to create folder '%1'. 创建文件夹'%1'失败。 - + Save new project as - + Red panda Dev-C++ project file (*.dev) 小熊猫Dev-C++项目文件 (*.dev) - + New project fail 新建项目失败 - + Can't assign project template 无法使用模板创建项目 - + Add to project 添加到项目 - - - - - - - - - + + + + + + + + + Error 错误 @@ -3400,75 +3411,75 @@ Are you really want to continue? 项目历史 - + File '%1' was changed. 磁盘文件'%1'已被修改。 - + Reload its content from disk? 是否重新读取它的内容? - + File '%1' was removed. 磁盘文件'%1'已被删除。 - + Keep it open? 是否保持它在小熊猫C++中打开的编辑窗口? - + Open 打开 - + Compile Failed 编译失败 - + Run Failed 运行失败 - - + + Confirm Convertion 确认转换 - - + + The editing file will be saved using %1 encoding. <br />This operation can't be reverted. <br />Are you sure to continue? 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗? - + New Watch Expression 新监视表达式 - + Enter Watch Expression (it is recommended to use 'this->' for class members): 输入监视表达式 - + Parsing file %1 of %2: "%3" (%1/%2)正在解析文件"%3" - - + + Done parsing %1 files in %2 seconds 完成%1个文件的解析,用时%2秒 - + (%1 files per second) (每秒%1个文件) @@ -3813,7 +3824,7 @@ Are you really want to continue? 编码 - + Override build command: 自定义构建命令 @@ -3824,9 +3835,13 @@ Are you really want to continue? - ANSI(System default) + ANSI ANSI + + ANSI(System default) + ANSI + UTF-8 @@ -4860,17 +4875,17 @@ Are you really want to continue? RegisterModel - + Register 寄存器 - + Value(Hex) 值(HEX) - + Value(Dec) 值(DEC) @@ -4984,8 +4999,8 @@ Are you really want to continue? - - + + Find 查找 @@ -4995,19 +5010,19 @@ Are you really want to continue? 取消 - + Find in files 在文件中查找 - - - + + + Replace 替换 - + Replace this occurrence of ''%1''? 替换这里的"%1"? @@ -5445,12 +5460,12 @@ Are you really want to continue? WatchModel - + Expression 表达式 - + Value diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index ba0308e4..be138e8f 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -48,8 +48,7 @@ bool Debugger::start() connect(mReader, &QThread::finished,this,&Debugger::clearUpReader); connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection); connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline); - connect(mReader, &DebugReader::addLocalLine,this,&Debugger::onAddLocalLine); - connect(mReader, &DebugReader::clearLocals,this,&Debugger::onClearLocals); + connect(this, &Debugger::localsReady,pMainWindow,&MainWindow::onLocalsReady); connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions); connect(mReader, &DebugReader::cmdFinished,pMainWindow, &MainWindow::enableDebugActions); @@ -102,16 +101,6 @@ void Debugger::clearUpReader() } } -void Debugger::onAddLocalLine(const QString &text) -{ - pMainWindow->txtLocals()->appendPlainText(text); -} - -void Debugger::onClearLocals() -{ - pMainWindow->txtLocals()->clear(); -} - RegisterModel *Debugger::registerModel() const { return mRegisterModel; @@ -458,6 +447,18 @@ void Debugger::syncFinishedParsing() mReader->doevalready = false; } + if (mReader->doupdatememoryview) { + emit memoryExamineReady(mReader->mMemoryValue); + mReader->mMemoryValue.clear(); + mReader->doupdatememoryview=false; + } + + if (mReader->doupdatelocal) { + emit localsReady(mReader->mLocalsValue); + mReader->mLocalsValue.clear(); + mReader->doupdatelocal=false; + } + // show command output if (pSettings->debugger().showCommandLog() || (mReader->mCurrentCmd && mReader->mCurrentCmd->showInConsole)) { @@ -648,6 +649,8 @@ AnnotationType DebugReader::getAnnotation(const QString &s) } else if ((mCurrentCmd) && (mCurrentCmd->command == "disas")) { // Another hack to catch assembler result = AnnotationType::TInfoAsm; + } else if ((mCurrentCmd) && (mCurrentCmd->command.startsWith("x/"))) { + result = AnnotationType::TMemory; } return result; } else if (s == "error-begin") { @@ -980,7 +983,7 @@ void DebugReader::handleLocalOutput() line += s; // emit addLocalWithoutLinebreak(s); } else { - emit addLocalLine(line); + mLocalsValue.append(line); line = s; } nobreakLine=false; @@ -992,18 +995,42 @@ void DebugReader::handleLocalOutput() break; } if (!line.isEmpty()) { - emit addLocalLine(line); + mLocalsValue.append(line); } } void DebugReader::handleLocals() { - emit clearLocals(); + mLocalsValue.clear(); handleLocalOutput(); } +void DebugReader::handleMemory() +{ + doupdatememoryview = true; + // name(spaces)hexvalue(tab)decimalvalue + mMemoryValue.clear(); + QString s = getNextFilledLine(); + bool isAnnotation = false; + while (true) { + if (!s.startsWith("\032\032")) { + s = s.trimmed(); + if (!s.isEmpty()) { + mMemoryValue.append(s); + } + isAnnotation = false; + } else { + isAnnotation = true; + } + s = getNextLine(); + if (!isAnnotation && s.isEmpty()) + break; + } +} + void DebugReader::handleParams(){ handleLocalOutput(); + doupdatelocal = true; } void DebugReader::handleRegisters() @@ -1129,6 +1156,8 @@ void DebugReader::processDebugOutput() dodisassemblerready = false; doregistersready = false; doevalready = false; + doupdatememoryview = false; + doupdatelocal = false; doprocessexited = false; doupdateexecution = false; doreceivedsignal = false; @@ -1168,6 +1197,9 @@ void DebugReader::processDebugOutput() case AnnotationType::TParam: handleParams(); break; + case AnnotationType::TMemory: + handleMemory(); + break; case AnnotationType::TErrorBegin: handleError(); break; diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index 0f24fb17..687a414f 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -36,7 +36,7 @@ enum class AnnotationType { TFieldBegin, TFieldEnd, TFieldValue, TFieldNameEnd, TInfoReg, TInfoAsm, TUnknown, TEOF, - TLocal, TParam + TLocal, TParam, TMemory }; struct DebugCommand{ @@ -238,6 +238,8 @@ public: signals: void evalValueReady(const QString& s); + void memoryExamineReady(const QStringList& s); + void localsReady(const QStringList& s); public slots: void stop(); @@ -252,8 +254,7 @@ private slots: void syncFinishedParsing(); void onChangeDebugConsoleLastline(const QString& text); void clearUpReader(); - void onAddLocalLine(const QString& text); - void onClearLocals(); + private: bool mExecuting; bool mCommandChanged; @@ -291,8 +292,6 @@ signals: void updateWatch(); void processError(QProcess::ProcessError error); void changeDebugConsoleLastLine(const QString& text); - void addLocalLine(const QString& text); - void clearLocals(); void cmdStarted(); void cmdFinished(); private: @@ -312,6 +311,7 @@ private: void handleFrames(); void handleLocalOutput(); void handleLocals(); + void handleMemory(); void handleParams(); void handleRegisters(); void handleSignal(); @@ -348,6 +348,8 @@ private: QString mBreakPointFile; QString mOutput; QString mEvalValue; + QStringList mMemoryValue; + QStringList mLocalsValue; QString mSignal; bool mUseUTF8; @@ -361,6 +363,8 @@ private: bool doupdateexecution; bool doreceivedsignal; bool doreceivedsfwarning; + bool doupdatememoryview; + bool doupdatelocal; bool mStop; friend class Debugger; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 636f581a..f65b8553 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -120,6 +120,8 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->debugConsole,&QConsole::commandInput,this,&MainWindow::onDebugCommandInput); connect(ui->cbEvaluate->lineEdit(), &QLineEdit::returnPressed, this, &MainWindow::onDebugEvaluateInput); + connect(ui->cbMemoryAddress->lineEdit(), &QLineEdit::returnPressed, + this, &MainWindow::onDebugMemoryAddressInput); mSearchResultTreeModel = std::make_shared(&mSearchResultModel); mSearchResultListModel = std::make_shared(&mSearchResultModel); @@ -556,6 +558,7 @@ void MainWindow::updateDebugEval(const QString &value) { ui->txtEvalOutput->clear(); ui->txtEvalOutput->appendPlainText(value); + ui->txtEvalOutput->moveCursor(QTextCursor::Start); } void MainWindow::rebuildOpenedFileHisotryMenu() @@ -2124,6 +2127,7 @@ void MainWindow::disableDebugActions() ui->actionRun_To_Cursor->setEnabled(false); ui->actionContinue->setEnabled(false); ui->cbEvaluate->setEnabled(false); + ui->cbMemoryAddress->setEnabled(false); } void MainWindow::enableDebugActions() @@ -2134,6 +2138,7 @@ void MainWindow::enableDebugActions() ui->actionRun_To_Cursor->setEnabled(true); ui->actionContinue->setEnabled(true); ui->cbEvaluate->setEnabled(true); + ui->cbMemoryAddress->setEnabled(true); } void MainWindow::prepareProjectForCompile() @@ -3017,6 +3022,16 @@ void MainWindow::onDebugEvaluateInput() } } +void MainWindow::onDebugMemoryAddressInput() +{ + QString s=ui->cbMemoryAddress->currentText().trimmed(); + if (!s.isEmpty()) { + connect(mDebugger, &Debugger::memoryExamineReady, + this, &MainWindow::onMemoryExamineReady); + mDebugger->sendCommand("x/64bx",s,false); + } +} + void MainWindow::onParserProgress(const QString &fileName, int total, int current) { // Mention every 5% progress @@ -3068,6 +3083,27 @@ void MainWindow::onEvalValueReady(const QString &value) this, &MainWindow::onEvalValueReady); } +void MainWindow::onMemoryExamineReady(const QStringList &value) +{ + ui->txtMemoryView->clear(); + foreach (QString s, value) { + s.replace("\t"," "); + ui->txtMemoryView->appendPlainText(s); + } + ui->txtMemoryView->moveCursor(QTextCursor::Start); + disconnect(mDebugger, &Debugger::memoryExamineReady, + this, &MainWindow::onMemoryExamineReady); +} + +void MainWindow::onLocalsReady(const QStringList &value) +{ + ui->txtLocals->clear(); + foreach (QString s, value) { + ui->txtLocals->appendPlainText(s); + } + ui->txtLocals->moveCursor(QTextCursor::Start); +} + void MainWindow::on_actionFind_triggered() { Editor *e = mEditorList->getEditor(); diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index ef506e72..ac3206f7 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -88,7 +88,6 @@ public: void saveLastOpens(); void loadLastOpens(); - QPlainTextEdit* txtLocals(); CPUDialog *cpuDialog() const; @@ -125,10 +124,13 @@ public slots: void cleanUpCPUDialog(); void onDebugCommandInput(const QString& command); void onDebugEvaluateInput(); + void onDebugMemoryAddressInput(); void onParserProgress(const QString& fileName, int total, int current); void onStartParsing(); void onEndParsing(int total, int updateView); void onEvalValueReady(const QString& value); + void onMemoryExamineReady(const QStringList& value); + void onLocalsReady(const QStringList& value); void onEditorContextMenu(const QPoint& pos); void onEditorTabContextMenu(const QPoint& pos); void disableDebugActions(); diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 1db97d3c..091c2b7a 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -288,7 +288,7 @@ QTabWidget::South - 3 + 2 @@ -416,67 +416,43 @@ QFrame::Raised - + - 0 + 11 - 0 + 11 - 0 + 11 - 0 + 11 - - - - QFrame::StyledPanel + + + + Evaluate: - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Evaluate: - - - - - - - - 0 - 0 - - - - true - - - QComboBox::InsertAtTop - - - - - + + + + + 0 + 0 + + + + true + + + QComboBox::InsertAtTop + + + + false @@ -493,7 +469,7 @@ QTabWidget::North - 3 + 4 @@ -623,6 +599,46 @@ + + + Memory + + + + + + Address Expression: + + + + + + + + 0 + 0 + + + + true + + + QComboBox::InsertAtTop + + + + + + + QPlainTextEdit::NoWrap + + + true + + + + + @@ -801,7 +817,7 @@ 0 0 946 - 25 + 22 diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index 2eb50a3b..81cd2f83 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -3,6 +3,8 @@ #include +#define DEVCPP_VERSION "0.2.2" + #ifdef Q_OS_WIN #define APP_SETTSINGS_FILENAME "redpandacpp.ini" #define GCC_PROGRAM "gcc.exe" @@ -51,8 +53,6 @@ #error "Only support windows and linux now!" #endif -#define DEVCPP_VERSION "0.2.0" - class SystemConsts { public: