@@ -478,6 +478,7 @@ void TraceBrowser::setupRightClickContextMenu()
478
478
return (duint)0 ;
479
479
});
480
480
mBreakpointMenu ->build (mMenuBuilder );
481
+ mMenuBuilder ->addAction (makeShortcutAction (DIcon (" label.png" ), tr (" Label Current Address" ), SLOT (setLabelSlot ()), " ActionSetLabel" ), isDebugging);
481
482
mMenuBuilder ->addAction (makeShortcutAction (DIcon (" comment.png" ), tr (" &Comment" ), SLOT (setCommentSlot ()), " ActionSetComment" ), isDebugging);
482
483
mMenuBuilder ->addAction (makeShortcutAction (DIcon (" highlight.png" ), tr (" &Highlighting mode" ), SLOT (enableHighlightingModeSlot ()), " ActionHighlightingMode" ), isValid);
483
484
MenuBuilder* gotoMenu = new MenuBuilder (this , isValid);
@@ -854,7 +855,7 @@ void TraceBrowser::updateColors()
854
855
855
856
void TraceBrowser::openFileSlot ()
856
857
{
857
- BrowseDialog browse (this , tr (" Open run trace file" ), tr (" Open trace file" ), tr (" Run trace files (*.%1);;All files (*.*)" ).arg (ArchValue (" trace32" , " trace64" )), QApplication::applicationDirPath (), false );
858
+ BrowseDialog browse (this , tr (" Open run trace file" ), tr (" Open trace file" ), tr (" Run trace files (*.%1);;All files (*.*)" ).arg (ArchValue (" trace32" , " trace64" )), QApplication::applicationDirPath () + QDir::separator () + " db " , false );
858
859
if (browse.exec () != QDialog::Accepted)
859
860
return ;
860
861
emit openSlot (browse.path );
@@ -936,6 +937,8 @@ void TraceBrowser::parseFinishedSlot()
936
937
937
938
void TraceBrowser::gotoSlot ()
938
939
{
940
+ if (mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
941
+ return ;
939
942
GotoDialog gotoDlg (this , false , true ); // Problem: Cannot use when not debugging
940
943
if (gotoDlg.exec () == QDialog::Accepted)
941
944
{
@@ -1090,6 +1093,9 @@ void TraceBrowser::pushSelectionInto(bool copyBytes, QTextStream & stream, QText
1090
1093
1091
1094
void TraceBrowser::copySelectionSlot (bool copyBytes)
1092
1095
{
1096
+ if (mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
1097
+ return ;
1098
+
1093
1099
QString selectionString = " " ;
1094
1100
QString selectionHtmlString = " " ;
1095
1101
QTextStream stream (&selectionString);
@@ -1100,6 +1106,9 @@ void TraceBrowser::copySelectionSlot(bool copyBytes)
1100
1106
1101
1107
void TraceBrowser::copySelectionToFileSlot (bool copyBytes)
1102
1108
{
1109
+ if (mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
1110
+ return ;
1111
+
1103
1112
QString fileName = QFileDialog::getSaveFileName (this , tr (" Open File" ), " " , tr (" Text Files (*.txt)" ));
1104
1113
if (fileName != " " )
1105
1114
{
@@ -1138,6 +1147,9 @@ void TraceBrowser::copySelectionToFileNoBytesSlot()
1138
1147
1139
1148
void TraceBrowser::copyDisassemblySlot ()
1140
1149
{
1150
+ if (mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
1151
+ return ;
1152
+
1141
1153
QString clipboardHtml = QString (" <div style=\" font-family: %1; font-size: %2px\" >" ).arg (font ().family ()).arg (getRowHeight ());
1142
1154
QString clipboard = " " ;
1143
1155
for (auto i = getSelectionStart (); i <= getSelectionEnd (); i++)
@@ -1162,6 +1174,9 @@ void TraceBrowser::copyDisassemblySlot()
1162
1174
void TraceBrowser::copyRvaSlot ()
1163
1175
{
1164
1176
QString text;
1177
+ if (mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
1178
+ return ;
1179
+
1165
1180
for (unsigned long long i = getSelectionStart (); i <= getSelectionEnd (); i++)
1166
1181
{
1167
1182
duint cip = mTraceFile ->Registers (i).regcontext .cip ;
@@ -1184,6 +1199,9 @@ void TraceBrowser::copyRvaSlot()
1184
1199
void TraceBrowser::copyFileOffsetSlot ()
1185
1200
{
1186
1201
QString text;
1202
+ if (mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
1203
+ return ;
1204
+
1187
1205
for (unsigned long long i = getSelectionStart (); i <= getSelectionEnd (); i++)
1188
1206
{
1189
1207
duint cip = mTraceFile ->Registers (i).regcontext .cip ;
@@ -1205,7 +1223,7 @@ void TraceBrowser::copyFileOffsetSlot()
1205
1223
1206
1224
void TraceBrowser::setCommentSlot ()
1207
1225
{
1208
- if (!DbgIsDebugging ())
1226
+ if (!DbgIsDebugging () || mTraceFile == nullptr || mTraceFile -> Progress () < 100 )
1209
1227
return ;
1210
1228
duint wVA = mTraceFile ->Registers (getInitialSelection ()).regcontext .cip ;
1211
1229
LineEditDialog mLineEdit (this );
@@ -1240,6 +1258,39 @@ void TraceBrowser::setCommentSlot()
1240
1258
GuiUpdateAllViews ();
1241
1259
}
1242
1260
1261
+ void TraceBrowser::setLabelSlot ()
1262
+ {
1263
+ if (!DbgIsDebugging () || mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
1264
+ return ;
1265
+ duint wVA = mTraceFile ->Registers (getInitialSelection ()).regcontext .cip ;
1266
+ LineEditDialog mLineEdit (this );
1267
+ mLineEdit .setTextMaxLength (MAX_LABEL_SIZE - 2 );
1268
+ QString addr_text = ToPtrString (wVA);
1269
+ char label_text[MAX_COMMENT_SIZE] = " " ;
1270
+ if (DbgGetLabelAt ((duint)wVA, SEG_DEFAULT, label_text))
1271
+ mLineEdit .setText (QString (label_text));
1272
+ mLineEdit .setWindowTitle (tr (" Add label at " ) + addr_text);
1273
+ restart:
1274
+ if (mLineEdit .exec () != QDialog::Accepted)
1275
+ return ;
1276
+ QByteArray utf8data = mLineEdit .editText .toUtf8 ();
1277
+ if (!utf8data.isEmpty () && DbgIsValidExpression (utf8data.constData ()) && DbgValFromString (utf8data.constData ()) != wVA)
1278
+ {
1279
+ QMessageBox msg (QMessageBox::Warning, tr (" The label may be in use" ),
1280
+ tr (" The label \" %1\" may be an existing label or a valid expression. Using such label might have undesired effects. Do you still want to continue?" ).arg (mLineEdit .editText ),
1281
+ QMessageBox::Yes | QMessageBox::No, this );
1282
+ msg.setWindowIcon (DIcon (" compile-warning.png" ));
1283
+ msg.setParent (this , Qt::Dialog);
1284
+ msg.setWindowFlags (msg.windowFlags () & (~Qt::WindowContextHelpButtonHint));
1285
+ if (msg.exec () == QMessageBox::No)
1286
+ goto restart;
1287
+ }
1288
+ if (!DbgSetLabelAt (wVA, utf8data.constData ()))
1289
+ SimpleErrorBox (this , tr (" Error!" ), tr (" DbgSetLabelAt failed!" ));
1290
+
1291
+ GuiUpdateAllViews ();
1292
+ }
1293
+
1243
1294
void TraceBrowser::enableHighlightingModeSlot ()
1244
1295
{
1245
1296
if (mHighlightingMode )
@@ -1251,6 +1302,9 @@ void TraceBrowser::enableHighlightingModeSlot()
1251
1302
1252
1303
void TraceBrowser::followDisassemblySlot ()
1253
1304
{
1305
+ if (mTraceFile == nullptr || mTraceFile ->Progress () < 100 )
1306
+ return ;
1307
+
1254
1308
DbgCmdExec (QString (" dis " ).append (ToPtrString (mTraceFile ->Registers (getInitialSelection ()).regcontext .cip )).toUtf8 ().constData ());
1255
1309
}
1256
1310
0 commit comments