2 // allwatch.cpp - All Watch
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- -----------------------------------------------------------
10 // JPM 12/07/2017 Created this file
16 #include "debugger\allwatchbrowser.h"
18 #include "debugger\DBGManager.h"
21 AllWatchBrowserWindow::AllWatchBrowserWindow(QWidget
* parent
/*= 0*/) : QWidget(parent
, Qt::Dialog
),
22 layout(new QVBoxLayout
), text(new QTextBrowser
),
23 // layout(new QVBoxLayout), text(new QLabel),
24 // refresh(new QPushButton(tr("Refresh"))),
25 // address(new QLineEdit),
26 // go(new QPushButton(tr("Go"))),
31 setWindowTitle(tr("All Watch"));
33 // address->setInputMask("hhhhhh");
34 // QHBoxLayout * hbox1 = new QHBoxLayout;
35 // hbox1->addWidget(refresh);
36 // hbox1->addWidget(address);
37 // hbox1->addWidget(go);
39 // Need to set the size as well...
42 QFont
fixedFont("Lucida Console", 8, QFont::Normal
);
43 // QFont fixedFont("", 8, QFont::Normal);
44 fixedFont
.setStyleHint(QFont::TypeWriter
);
45 text
->setFont(fixedFont
);
46 //// layout->setSizeConstraint(QLayout::SetFixedSize);
49 layout
->addWidget(text
);
50 // layout->addWidget(refresh);
51 // layout->addLayout(hbox1);
53 // connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
54 // connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
59 AllWatchBrowserWindow::~AllWatchBrowserWindow(void)
67 void AllWatchBrowserWindow::RefreshContents(void)
77 if (NbWatch
= DBGManager_GetNbExternalVariables())
79 PtrWatchInfo
= (WatchInfo
*)calloc(NbWatch
, sizeof(WatchInfo
));
81 #pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!")
83 #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!"
86 for (uint32_t i
= 0; i
< NbWatch
; i
++)
88 PtrWatchInfo
[i
].PtrVariableName
= DBGManager_GetExternalVariableName(i
+ 1);
89 PtrWatchInfo
[i
].addr
= DBGManager_GetExternalVariableAdr(i
+ 1);
90 PtrWatchInfo
[i
].TypeTag
= DBGManager_GetExternalVariableTypeTag(i
+ 1);
91 if (!strlen(PtrWatchInfo
[i
].PtrVariableBaseTypeName
= DBGManager_GetExternalVariableTypeName(i
+ 1)))
93 PtrWatchInfo
[i
].PtrVariableBaseTypeName
= (char *)"<font color='#ff0000'>N/A</font>";
99 for (uint32_t i
= 0; i
< NbWatch
; i
++)
101 if (PtrWatchInfo
[i
].PtrVariableName
&& PtrWatchInfo
[i
].PtrVariableBaseTypeName
)
103 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));
104 WatchAll
+= QString(string
);
105 sprintf(string
, "<br>");
106 WatchAll
+= QString(string
);
111 text
->setText(WatchAll
);
117 void AllWatchBrowserWindow::keyPressEvent(QKeyEvent
* e
)
119 if (e
->key() == Qt::Key_Escape
)
121 else if (e
->key() == Qt::Key_PageUp
)
130 else if (e
->key() == Qt::Key_PageDown
)
134 if (memBase
> (0x200000 - 480))
135 memBase
= 0x200000 - 480;
139 else if (e
->key() == Qt::Key_Up
|| e
->key() == Qt::Key_Minus
)
148 else if (e
->key() == Qt::Key_Down
|| e
->key() == Qt::Key_Equal
)
152 if (memBase
> (0x200000 - 480))
153 memBase
= 0x200000 - 480;
162 void AllWatchBrowserWindow::GoToAddress(void)
165 QString newAddress
= address
->text();
166 memBase
= newAddress
.toUInt(&ok
, 16);