File: DialogHwBreakpoints.cpp

package info (click to toggle)
edb-debugger 1.3.0-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,124 kB
  • sloc: cpp: 46,241; xml: 4,998; ansic: 3,088; sh: 52; asm: 33; makefile: 5
file content (125 lines) | stat: -rw-r--r-- 3,674 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
Copyright (C) 2006 - 2015 Evan Teran
                          evan.teran@gmail.com

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "DialogHwBreakpoints.h"
#include "IDebugger.h"
#include "IProcess.h"
#include "IThread.h"
#include "State.h"
#include "edb.h"
#include "libHardwareBreakpoints.h"

namespace HardwareBreakpointsPlugin {

/**
 * @brief DialogHwBreakpoints::DialogHwBreakpoints
 * @param parent
 * @param f
 */
DialogHwBreakpoints::DialogHwBreakpoints(QWidget *parent, Qt::WindowFlags f)
	: QDialog(parent, f) {

	ui.setupUi(this);

	connect(ui.cmbType1, SIGNAL(currentIndexChanged(int)), this, SLOT(type1IndexChanged(int)));
	connect(ui.cmbType2, SIGNAL(currentIndexChanged(int)), this, SLOT(type2IndexChanged(int)));
	connect(ui.cmbType3, SIGNAL(currentIndexChanged(int)), this, SLOT(type3IndexChanged(int)));
	connect(ui.cmbType4, SIGNAL(currentIndexChanged(int)), this, SLOT(type4IndexChanged(int)));
}

/**
 * @brief DialogHwBreakpoints::type1IndexChanged
 * @param index
 */
void DialogHwBreakpoints::type1IndexChanged(int index) {
	ui.cmbSize1->setEnabled(index != 0);
}

/**
 * @brief DialogHwBreakpoints::type2IndexChanged
 * @param index
 */
void DialogHwBreakpoints::type2IndexChanged(int index) {
	ui.cmbSize2->setEnabled(index != 0);
}

/**
 * @brief DialogHwBreakpoints::type3IndexChanged
 * @param index
 */
void DialogHwBreakpoints::type3IndexChanged(int index) {
	ui.cmbSize3->setEnabled(index != 0);
}

/**
 * @brief DialogHwBreakpoints::type4IndexChanged
 * @param index
 */
void DialogHwBreakpoints::type4IndexChanged(int index) {
	ui.cmbSize4->setEnabled(index != 0);
}

/**
 * @brief DialogHwBreakpoints::showEvent
 * @param event
 */
void DialogHwBreakpoints::showEvent(QShowEvent *event) {
	Q_UNUSED(event)

	if (IProcess *process = edb::v1::debugger_core->process()) {

		State state;
		process->currentThread()->getState(&state);

		const BreakpointState bp_state1 = breakpoint_state(&state, Register1);
		const BreakpointState bp_state2 = breakpoint_state(&state, Register2);
		const BreakpointState bp_state3 = breakpoint_state(&state, Register3);
		const BreakpointState bp_state4 = breakpoint_state(&state, Register4);

		ui.chkBP1->setChecked(bp_state1.enabled);
		ui.chkBP2->setChecked(bp_state2.enabled);
		ui.chkBP3->setChecked(bp_state3.enabled);
		ui.chkBP4->setChecked(bp_state4.enabled);

		if (bp_state1.enabled) {
			ui.txtBP1->setText(bp_state1.addr.toPointerString());
			ui.cmbSize1->setCurrentIndex(bp_state1.size);
			ui.cmbType1->setCurrentIndex(bp_state1.type);
		}

		if (bp_state2.enabled) {
			ui.txtBP2->setText(bp_state2.addr.toPointerString());
			ui.cmbSize2->setCurrentIndex(bp_state2.size);
			ui.cmbType2->setCurrentIndex(bp_state2.type);
		}

		if (bp_state3.enabled) {
			ui.txtBP3->setText(bp_state3.addr.toPointerString());
			ui.cmbSize3->setCurrentIndex(bp_state3.size);
			ui.cmbType3->setCurrentIndex(bp_state3.type);
		}

		if (bp_state4.enabled) {
			ui.txtBP4->setText(bp_state4.addr.toPointerString());
			ui.cmbSize4->setCurrentIndex(bp_state4.size);
			ui.cmbType4->setCurrentIndex(bp_state4.type);
		}
	}
}

}