2 // brkWin.cpp - Breakpoints
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- -----------------------------------------------------------
10 // JPM 30/08/2017 Created this file
16 #include "debugger/brkWin.h"
18 #include "debugger/DBGManager.h"
22 BrkWindow::BrkWindow(QWidget
* parent
/*= 0*/) : QWidget(parent
, Qt::Dialog
),
23 layout(new QVBoxLayout
), text(new QTextBrowser
),
24 // layout(new QVBoxLayout), text(new QLabel),
25 // refresh(new QPushButton(tr("Refresh"))),
26 address(new QLineEdit
)
27 // go(new QPushButton(tr("Go"))),
32 setWindowTitle(tr("Breakpoints window"));
35 // address->setInputMask("hhhhhh");
36 // QHBoxLayout * hbox1 = new QHBoxLayout;
37 // hbox1->addWidget(refresh);
38 // hbox1->addWidget(address);
39 // hbox1->addWidget(go);
41 // Need to set the size as well...
44 QFont
fixedFont("Lucida Console", 8, QFont::Normal
);
45 // QFont fixedFont("", 8, QFont::Normal);
46 fixedFont
.setStyleHint(QFont::TypeWriter
);
47 text
->setFont(fixedFont
);
48 //// layout->setSizeConstraint(QLayout::SetFixedSize);
51 layout
->addWidget(text
);
52 // layout->addWidget(refresh);
53 // layout->addLayout(hbox1);
55 // connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
56 // connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
62 BrkWindow::~BrkWindow(void)
72 void BrkWindow::RefreshContents(void)
83 if (NbWatch
= DBGManager_GetNbGlobalVariables())
85 PtrWatchInfo
= (WatchInfo
*)calloc(NbWatch
, sizeof(WatchInfo
));
87 #pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!")
89 #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!"
92 for (uint32_t i
= 0; i
< NbWatch
; i
++)
94 PtrWatchInfo
[i
].PtrVariableName
= DBGManager_GetGlobalVariableName(i
+ 1);
95 PtrWatchInfo
[i
].addr
= DBGManager_GetExternalVariableAdr(i
+ 1);
96 PtrWatchInfo
[i
].TypeTag
= DBGManager_GetExternalVariableTypeTag(i
+ 1);
97 if (!strlen(PtrWatchInfo
[i
].PtrVariableBaseTypeName
= DBGManager_GetGlobalVariableTypeName(i
+ 1)))
99 PtrWatchInfo
[i
].PtrVariableBaseTypeName
= (char *)"<font color='#ff0000'>N/A</font>";
105 for (uint32_t i
= 0; i
< NbWatch
; i
++)
107 if (PtrWatchInfo
[i
].PtrVariableName
&& PtrWatchInfo
[i
].PtrVariableBaseTypeName
)
109 sprintf(string
, "%i : %s | %s | 0x%06X | %s", (i
+ 1), PtrWatchInfo
[i
].PtrVariableBaseTypeName
, PtrWatchInfo
[i
].PtrVariableName
, PtrWatchInfo
[i
].addr
, (PtrWatchInfo
[i
].TypeTag
& 0x8) ? "" : DBGManager_GetExternalVariableValue(i
+ 1));
110 WatchAll
+= QString(string
);
111 sprintf(string
, "<br>");
112 WatchAll
+= QString(string
);
117 text
->setText(WatchAll
);
124 void BrkWindow::keyPressEvent(QKeyEvent
* e
)
126 if (e
->key() == Qt::Key_Escape
)
132 if (e
->key() == Qt::Key_PageUp
)
145 if (e
->key() == Qt::Key_PageDown
)
150 if (memBase
> (0x200000 - 480))
151 memBase
= 0x200000 - 480;
158 if (e
->key() == Qt::Key_Up
|| e
->key() == Qt::Key_Minus
)
171 if (e
->key() == Qt::Key_Down
|| e
->key() == Qt::Key_Equal
)
176 if (memBase
> (0x200000 - 480))
177 memBase
= 0x200000 - 480;
184 if (e
->key() == Qt::Key_Return
)
197 void BrkWindow::RefreshBrkList(size_t Address
)
202 // Go to the requested address
203 // Address can be an hexa, decimal or a symbol name
204 void BrkWindow::GoToAddress(void)
210 newAddress
= address
->text();
212 if ((newAddress
.at(0) == QChar('0')) && (newAddress
.at(1) == QChar('x')))
214 Address
= newAddress
.toUInt(&ok
, 16);
218 if (!(Address
= DBGManager_GetAdrFromSymbolName(newAddress
.toLatin1().data())))
220 Address
= newAddress
.toUInt(&ok
, 10);
224 RefreshBrkList(Address
);