/
George_Smith
/
GDBManager
Обзор
Документация
Войти
/
George_Smith
/
GDBManager
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
main.cpp
60 строк
1 KB
Георгий Кузнецов
Controlling GDB via the MI Interface
09 фев 2026, 12:46
09 фев 2026, 12:46
2b0ef22
Код
Авторство
О чём код?
#include <iostream> #include "gdbengine.h" #include <termios.h> #include <unistd.h> using namespace std; int main() { char c; GdbManager dbg; // Настраиваем реакцию интерфейса dbg.setHandler([](const GdbResponse& res) { if (res.className == "stopped") { auto& results = res.results; std::string file = results.count("file") ? results.at("file") : "unknown"; std::string line = results.count("line") ? results.at("line") : "0"; std::cout << "[UI] Stopped at " << file << ":" << line << std::endl; } }); if (!dbg.launch("gdb")) { std::cerr << "Ошибка запуска GDB" << std::endl; return 1; } dbg.loadProcess("./datatransfer"); dbg.setBreakpoint("main.cpp", 10); dbg.run(); std::cout << "n - Step Over, r - Run, i - Interrupt, s - Step Into, o - Step Out, c - Continue Execution q - Quit" << std::endl; while(true) { std::cin >> c; // Ждем нажатия if (c == 'r') { dbg.run(); } else if (c == 'n') { dbg.stepOver(); } else if (c == 'i') { // Interrupt (Пауза) dbg.interrupt(); } else if (c == 's') { dbg.stepInto(); } else if (c == 'o') { // dbg.stepOut(); } else if (c == 'q') { break; } } return 0; }