@@ -33,7 +33,6 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget* parent)
33
33
34
34
// Start disassembly view at the entry point of the binary
35
35
this ->function = 0 ;
36
- this ->update_id = 0 ;
37
36
this ->ready = false ;
38
37
this ->desired_pos = nullptr ;
39
38
this ->highlight_token = nullptr ;
@@ -46,13 +45,6 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget* parent)
46
45
this ->blocks .clear ();
47
46
this ->saveGraph = false ;
48
47
49
- // Create timer to automatically refresh view when it needs to be updated
50
- this ->updateTimer = new QTimer ();
51
- this ->updateTimer ->setInterval (100 );
52
- this ->updateTimer ->setSingleShot (false );
53
- connect (this ->updateTimer , SIGNAL (timeout ()), this , SLOT (updateTimerEvent ()));
54
- this ->updateTimer ->start ();
55
-
56
48
this ->initFont ();
57
49
58
50
// Initialize scroll bars
@@ -214,35 +206,38 @@ void DisassemblerGraphView::paintNormal(QPainter & p, QRect & viewportRect, int
214
206
int y = block.y + (2 * this ->charWidth ) + (int (block.block .header_text .lines .size ()) * this ->charHeight );
215
207
for (Instr & instr : block.block .instrs )
216
208
{
217
- auto selected = instr.addr == this ->cur_instr ;
218
- auto traceCount = dbgfunctions->GetTraceRecordHitCount (instr.addr );
219
-
220
- if (selected && traceCount)
221
- {
222
- p.fillRect (QRect (block.x + this ->charWidth + 3 , y, block.width - (10 + 2 * this ->charWidth ),
223
- int (instr.text .lines .size ()) * this ->charHeight ), disassemblyTracedSelectionColor);
224
- }
225
- else if (selected)
226
- {
227
- p.fillRect (QRect (block.x + this ->charWidth + 3 , y, block.width - (10 + 2 * this ->charWidth ),
228
- int (instr.text .lines .size ()) * this ->charHeight ), disassemblySelectionColor);
229
- }
230
- else if (traceCount)
209
+ if (y > viewportRect.y () - int (instr.text .lines .size ()) * this ->charHeight && y < viewportRect.bottom ())
231
210
{
232
- // Color depending on how often a sequence of code is executed
233
- int exponent = 1 ;
234
- while (traceCount >>= 1 ) // log2(traceCount)
235
- exponent++;
236
- int colorDiff = (exponent * exponent) / 2 ;
237
-
238
- // If the user has a light trace background color, substract
239
- if (disassemblyTracedColor.blue () > 160 )
240
- colorDiff *= -1 ;
241
-
242
- p.fillRect (QRect (block.x + this ->charWidth + 3 , y, block.width - (10 + 2 * this ->charWidth ), int (instr.text .lines .size ()) * this ->charHeight ),
243
- QColor (disassemblyTracedColor.red (),
244
- disassemblyTracedColor.green (),
245
- std::max (0 , std::min (256 , disassemblyTracedColor.blue () + colorDiff))));
211
+ auto selected = instr.addr == this ->cur_instr ;
212
+ auto traceCount = dbgfunctions->GetTraceRecordHitCount (instr.addr );
213
+
214
+ if (selected && traceCount)
215
+ {
216
+ p.fillRect (QRect (block.x + this ->charWidth + 3 , y, block.width - (10 + 2 * this ->charWidth ),
217
+ int (instr.text .lines .size ()) * this ->charHeight ), disassemblyTracedSelectionColor);
218
+ }
219
+ else if (selected)
220
+ {
221
+ p.fillRect (QRect (block.x + this ->charWidth + 3 , y, block.width - (10 + 2 * this ->charWidth ),
222
+ int (instr.text .lines .size ()) * this ->charHeight ), disassemblySelectionColor);
223
+ }
224
+ else if (traceCount)
225
+ {
226
+ // Color depending on how often a sequence of code is executed
227
+ int exponent = 1 ;
228
+ while (traceCount >>= 1 ) // log2(traceCount)
229
+ exponent++;
230
+ int colorDiff = (exponent * exponent) / 2 ;
231
+
232
+ // If the user has a light trace background color, substract
233
+ if (disassemblyTracedColor.blue () > 160 )
234
+ colorDiff *= -1 ;
235
+
236
+ p.fillRect (QRect (block.x + this ->charWidth + 3 , y, block.width - (10 + 2 * this ->charWidth ), int (instr.text .lines .size ()) * this ->charHeight ),
237
+ QColor (disassemblyTracedColor.red (),
238
+ disassemblyTracedColor.green (),
239
+ std::max (0 , std::min (256 , disassemblyTracedColor.blue () + colorDiff))));
240
+ }
246
241
}
247
242
y += int (instr.text .lines .size ()) * this ->charHeight ;
248
243
}
@@ -253,43 +248,49 @@ void DisassemblerGraphView::paintNormal(QPainter & p, QRect & viewportRect, int
253
248
auto y = block.y + (2 * this ->charWidth );
254
249
for (auto & line : block.block .header_text .lines )
255
250
{
256
- RichTextPainter::paintRichText (&p, x, y, block.width , this ->charHeight , 0 , line, mFontMetrics );
251
+ if (y > viewportRect.y () - this ->charHeight && y < viewportRect.bottom ())
252
+ {
253
+ RichTextPainter::paintRichText (&p, x, y, block.width , this ->charHeight , 0 , line, mFontMetrics );
254
+ }
257
255
y += this ->charHeight ;
258
256
}
259
257
260
258
for (Instr & instr : block.block .instrs )
261
259
{
262
260
for (auto & line : instr.text .lines )
263
261
{
264
- int rectSize = qRound (this ->charWidth );
265
- if (rectSize % 2 )
266
- rectSize++;
262
+ if (y > viewportRect.y () - this ->charHeight && y < viewportRect.bottom ())
263
+ {
264
+ int rectSize = qRound (this ->charWidth );
265
+ if (rectSize % 2 )
266
+ rectSize++;
267
267
268
- // Assume charWidth <= charHeight
269
- QRectF bpRect (x - rectSize / 3.0 , y + (this ->charHeight - rectSize) / 2.0 , rectSize, rectSize);
268
+ // Assume charWidth <= charHeight
269
+ QRectF bpRect (x - rectSize / 3.0 , y + (this ->charHeight - rectSize) / 2.0 , rectSize, rectSize);
270
270
271
- bool isbp = DbgGetBpxTypeAt (instr.addr ) != bp_none;
272
- bool isbpdisabled = DbgIsBpDisabled (instr.addr );
273
- bool iscip = instr.addr == mCip ;
271
+ bool isbp = DbgGetBpxTypeAt (instr.addr ) != bp_none;
272
+ bool isbpdisabled = DbgIsBpDisabled (instr.addr );
273
+ bool iscip = instr.addr == mCip ;
274
274
275
- if (isbp || isbpdisabled)
276
- {
277
- if (iscip)
275
+ if (isbp || isbpdisabled)
278
276
{
279
- // Left half is cip
280
- bpRect.setWidth (bpRect.width () / 2 );
281
- p.fillRect (bpRect, mCipColor );
277
+ if (iscip)
278
+ {
279
+ // Left half is cip
280
+ bpRect.setWidth (bpRect.width () / 2 );
281
+ p.fillRect (bpRect, mCipColor );
282
+
283
+ // Right half is breakpoint
284
+ bpRect.translate (bpRect.width (), 0 );
285
+ }
282
286
283
- // Right half is breakpoint
284
- bpRect.translate (bpRect.width (), 0 );
287
+ p.fillRect (bpRect, isbp ? mBreakpointColor : mDisabledBreakpointColor );
285
288
}
289
+ else if (iscip)
290
+ p.fillRect (bpRect, mCipColor );
286
291
287
- p. fillRect (bpRect, isbp ? mBreakpointColor : mDisabledBreakpointColor );
292
+ RichTextPainter::paintRichText (&p, x + this -> charWidth , y, block. width - this -> charWidth , this -> charHeight , 0 , line, mFontMetrics );
288
293
}
289
- else if (iscip)
290
- p.fillRect (bpRect, mCipColor );
291
-
292
- RichTextPainter::paintRichText (&p, x + this ->charWidth , y, block.width - this ->charWidth , this ->charHeight , 0 , line, mFontMetrics );
293
294
y += this ->charHeight ;
294
295
}
295
296
}
@@ -1386,43 +1387,11 @@ void DisassemblerGraphView::renderFunction(Function & func)
1386
1387
this ->verticalScrollBar ()->setValue (0 );
1387
1388
}
1388
1389
1389
- this ->analysis .update_id = this ->update_id = func.update_id ;
1390
1390
this ->ready = true ;
1391
1391
this ->viewport ()->update (0 , 0 , areaSize.width (), areaSize.height ());
1392
1392
// puts("Finished");
1393
1393
}
1394
1394
1395
- void DisassemblerGraphView::updateTimerEvent ()
1396
- {
1397
- auto status = this ->analysis .status ;
1398
- if (status != this ->status )
1399
- {
1400
- this ->status = status;
1401
- this ->viewport ()->update ();
1402
- }
1403
-
1404
- if (this ->function == 0 )
1405
- return ;
1406
-
1407
- if (this ->ready )
1408
- {
1409
- // Check for updated code
1410
- if (this ->update_id != this ->analysis .update_id )
1411
- this ->renderFunction (this ->analysis .functions [this ->function ]);
1412
- return ;
1413
- }
1414
-
1415
- // View not up to date, check to see if active function is ready
1416
- if (this ->analysis .functions .count (this ->function ))
1417
- {
1418
- if (this ->analysis .functions [this ->function ].ready )
1419
- {
1420
- // Active function now ready, generate graph
1421
- this ->renderFunction (this ->analysis .functions [this ->function ]);
1422
- }
1423
- }
1424
- }
1425
-
1426
1395
void DisassemblerGraphView::show_cur_instr (bool force)
1427
1396
{
1428
1397
for (auto & blockIt : this ->blocks )
@@ -1527,14 +1496,12 @@ void DisassemblerGraphView::loadCurrentGraph()
1527
1496
{
1528
1497
bool showGraphRva = ConfigBool (" Gui" , " ShowGraphRva" );
1529
1498
Analysis anal;
1530
- anal.update_id = this ->update_id + 1 ;
1531
1499
anal.entry = currentGraph.entryPoint ;
1532
1500
anal.ready = true ;
1533
1501
{
1534
1502
Function func;
1535
1503
func.entry = currentGraph.entryPoint ;
1536
1504
func.ready = true ;
1537
- func.update_id = anal.update_id ;
1538
1505
{
1539
1506
for (const auto & nodeIt : currentGraph.nodes )
1540
1507
{
@@ -1629,6 +1596,7 @@ void DisassemblerGraphView::loadCurrentGraph()
1629
1596
}
1630
1597
this ->analysis = anal;
1631
1598
this ->function = this ->analysis .entry ;
1599
+ this ->renderFunction (this ->analysis .functions [this ->function ]);
1632
1600
}
1633
1601
1634
1602
void DisassemblerGraphView::loadGraphSlot (BridgeCFGraphList* graphList, duint addr)
0 commit comments