Skip to content

Commit

Permalink
[Qt] Highlight breakpoints + clear all breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
shonumi committed Dec 23, 2015
1 parent afc49af commit c1fd1a8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
28 changes: 28 additions & 0 deletions src/qt/debug_dmg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ dmg_debug::dmg_debug(QWidget *parent) : QDialog(parent)

db_next_button = new QPushButton("Next");
db_set_bp_button = new QPushButton("Set Breakpoint");
db_clear_bp_button = new QPushButton("Clear Breakpoints");
db_continue_button = new QPushButton("Continue");
db_reset_button = new QPushButton("Reset");
db_reset_run_button = new QPushButton("Reset + Run");
Expand All @@ -530,6 +531,7 @@ dmg_debug::dmg_debug(QWidget *parent) : QDialog(parent)
regs_layout->addWidget(db_next_button);
regs_layout->addWidget(db_continue_button);
regs_layout->addWidget(db_set_bp_button);
regs_layout->addWidget(db_clear_bp_button);
regs_layout->addWidget(db_reset_button);
regs_layout->addWidget(db_reset_run_button);
regs_set->setLayout(regs_layout);
Expand Down Expand Up @@ -561,6 +563,7 @@ dmg_debug::dmg_debug(QWidget *parent) : QDialog(parent)
connect(dasm, SIGNAL(cursorPositionChanged()), this, SLOT(highlight()));
connect(db_next_button, SIGNAL(clicked()), this, SLOT(db_next()));
connect(db_continue_button, SIGNAL(clicked()), this, SLOT(db_continue()));
connect(db_clear_bp_button, SIGNAL(clicked()), this, SLOT(db_clear_bp()));
connect(db_set_bp_button, SIGNAL(clicked()), this, SLOT(db_set_bp()));
connect(db_reset_button, SIGNAL(clicked()), this, SLOT(db_reset()));
connect(db_reset_run_button, SIGNAL(clicked()), this, SLOT(db_reset_run()));
Expand Down Expand Up @@ -793,6 +796,8 @@ void dmg_debug::refresh()
dasm->setText(dasm_text);
debug_reset = false;
refresh();

original_format = dasm->textCursor().blockFormat();
}

//Update register values
Expand Down Expand Up @@ -992,6 +997,12 @@ void dmg_debug::db_set_bp()
if(main_menu::gbe_plus->db_unit.last_command != "c") { main_menu::gbe_plus->db_unit.last_command = "bp"; }
}

/****** Clears all breakpoints ******/
void dmg_debug::db_clear_bp()
{
if(main_menu::gbe_plus->db_unit.last_command != "c") { main_menu::gbe_plus->db_unit.last_command = "cbp"; }
}

/****** Resets emulation then stops ******/
void dmg_debug::db_reset() { main_menu::gbe_plus->db_unit.last_command = "rs"; }

Expand Down Expand Up @@ -1043,6 +1054,23 @@ void dmg_debug_step()
{
main_menu::gbe_plus->db_unit.breakpoints.push_back(main_menu::dmg_debugger->highlighted_dasm_line);
main_menu::gbe_plus->db_unit.last_command = "";

QTextCursor* temp = new QTextCursor;

QTextCursor cursor(main_menu::dmg_debugger->dasm->textCursor());
QTextBlockFormat format = cursor.blockFormat();

format.setBackground(QColor(Qt::yellow));
cursor.setBlockFormat(format);
}

//Clears all breakpoints
else if(main_menu::gbe_plus->db_unit.last_command == "cbp")
{
main_menu::dmg_debugger->dasm->setText(main_menu::dmg_debugger->dasm_text);
main_menu::gbe_plus->db_unit.last_command = "";
main_menu::gbe_plus->db_unit.breakpoints.clear();
main_menu::dmg_debugger->auto_refresh();
}

//Resets debugging, then stops
Expand Down
12 changes: 8 additions & 4 deletions src/qt/debug_dmg.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class dmg_debug : public QDialog

u32 highlighted_dasm_line;

QTextEdit* dasm;
QString dasm_text;
QString counter_text;

void auto_refresh();

private:
Expand Down Expand Up @@ -79,12 +83,8 @@ class dmg_debug : public QDialog
QScrollBar* mem_scrollbar;

//Disassembler widgets
QTextEdit* dasm;
QTextEdit* counter;

QString dasm_text;
QString counter_text;

QScrollBar* dasm_scrollbar;

QLabel* af_label;
Expand All @@ -97,10 +97,13 @@ class dmg_debug : public QDialog

QPushButton* db_next_button;
QPushButton* db_set_bp_button;
QPushButton* db_clear_bp_button;
QPushButton* db_continue_button;
QPushButton* db_reset_button;
QPushButton* db_reset_run_button;

QTextBlockFormat original_format;

bool text_select;

int last_start;
Expand All @@ -126,6 +129,7 @@ class dmg_debug : public QDialog
void db_next();
void db_continue();
void db_set_bp();
void db_clear_bp();
void db_reset();
void db_reset_run();
};
Expand Down

0 comments on commit c1fd1a8

Please sign in to comment.