diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters
index c1aa39021..25d3cde36 100644
--- a/Core/Core.vcxproj.filters
+++ b/Core/Core.vcxproj.filters
@@ -923,7 +923,8 @@
Debugger
-
+
+
diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp
index 77c4eed23..1f52f2f43 100644
--- a/Core/Debugger/DisassemblyManager.cpp
+++ b/Core/Debugger/DisassemblyManager.cpp
@@ -145,6 +145,23 @@ std::map::iterator findDisassemblyEntry(std::map DisassemblyManager::getBranchLines(u32 start, u32 size)
+{
+ std::vector result;
+
+ auto it = findDisassemblyEntry(entries,start,false);
+ if (it != entries.end())
+ {
+ do
+ {
+ it->second->getBranchLines(start,size,result);
+ it++;
+ } while (it != entries.end() && start+size > it->second->getLineAddress(0));
+ }
+
+ return result;
+}
+
DisassemblyLineInfo DisassemblyManager::getLine(u32 address, bool insertSymbols)
{
DisassemblyLineInfo result;
@@ -306,6 +323,13 @@ bool DisassemblyFunction::disassemble(u32 address, DisassemblyLineInfo& dest, bo
return it->second->disassemble(address,dest,insertSymbols);
}
+void DisassemblyFunction::getBranchLines(u32 start, u32 size, std::vector& dest)
+{
+ for (int i = 0; i < lines.size(); i++)
+ {
+ dest.push_back(lines[i]);
+ }
+}
#define NUM_LANES 16
diff --git a/Core/Debugger/DisassemblyManager.h b/Core/Debugger/DisassemblyManager.h
index 7b7f3a855..2ffe5b06d 100644
--- a/Core/Debugger/DisassemblyManager.h
+++ b/Core/Debugger/DisassemblyManager.h
@@ -55,6 +55,7 @@ public:
virtual u32 getLineAddress(int line) = 0;
virtual u32 getTotalSize() = 0;
virtual bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols) = 0;
+ virtual void getBranchLines(u32 start, u32 size, std::vector& dest) { };
};
class DisassemblyFunction: public DisassemblyEntry
@@ -67,6 +68,7 @@ public:
virtual u32 getLineAddress(int line);
virtual u32 getTotalSize() { return size; };
virtual bool disassemble(u32 address, DisassemblyLineInfo& dest, bool insertSymbols);
+ virtual void getBranchLines(u32 start, u32 size, std::vector& dest);
private:
u32 computeHash();
void generateBranchLines();
@@ -134,6 +136,7 @@ public:
void setCpu(DebugInterface* _cpu) { cpu = _cpu; };
DisassemblyLineInfo getLine(u32 address, bool insertSymbols);
void analyze(u32 address, u32 size);
+ std::vector getBranchLines(u32 start, u32 size);
u32 getStartAddress(u32 address);
u32 getNthPreviousAddress(u32 address, int n = 1);
diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp
index 6dac73e2d..e879dfc86 100644
--- a/Windows/Debugger/CtrlDisAsmView.cpp
+++ b/Windows/Debugger/CtrlDisAsmView.cpp
@@ -300,7 +300,7 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
scanFunctions();
if (address == curAddress)
- gotoAddr(curAddress+4);
+ gotoAddr(manager.getNthNextAddress(curAddress,1));
redraw();
} else {
@@ -310,10 +310,10 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
}
-void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line)
+void CtrlDisAsmView::drawBranchLine(HDC hdc, std::map& addressPositions, BranchLine& line)
{
HPEN pen;
- u32 windowEnd = windowStart+visibleRows*instructionSize;
+ u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows);
int topY;
int bottomY;
@@ -324,8 +324,7 @@ void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line)
{
topY = rect.bottom+1;
} else {
- int row = (line.first-windowStart)/instructionSize;
- topY = row*rowHeight + rowHeight/2;
+ topY = addressPositions[line.first] + rowHeight/2;
}
if (line.second < windowStart)
@@ -335,8 +334,7 @@ void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line)
{
bottomY = rect.bottom+1;
} else {
- int row = (line.second-windowStart)/instructionSize;
- bottomY = row*rowHeight + rowHeight/2;
+ bottomY = addressPositions[line.second] + rowHeight/2;
}
if ((topY < 0 && bottomY < 0) || (topY > rect.bottom && bottomY > rect.bottom))
@@ -429,6 +427,8 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOPDISABLE);
unsigned int address = windowStart;
+ std::map addressPositions;
+
for (int i = 0; i < visibleRows; i++)
{
DisassemblyLineInfo line = manager.getLine(address,displaySymbols);
@@ -436,6 +436,8 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
int rowY1 = rowHeight*i;
int rowY2 = rowHeight*(i+1);
+ addressPositions[address] = rowY1;
+
// draw background
COLORREF backgroundColor = whiteBackground ? 0xFFFFFF : debugger->getColor(address);
COLORREF textColor = 0x000000;
@@ -504,23 +506,12 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
address += line.totalSize;
}
-/* for (size_t i = 0; i < visibleFunctionAddresses.size(); i++)
+ std::vector branchLines = manager.getBranchLines(windowStart,address-windowStart);
+ for (size_t i = 0; i < branchLines.size(); i++)
{
- auto it = functions.find(visibleFunctionAddresses[i]);
- if (it == functions.end()) continue;
- DisassemblyFunc& func = it->second;
-
- for (size_t l = 0; l < func.lines.size(); l++)
- {
- drawBranchLine(hdc,func.lines[l]);
- }
+ drawBranchLine(hdc,addressPositions,branchLines[i]);
}
- for (size_t i = 0; i < strayLines.size(); i++)
- {
- drawBranchLine(hdc,strayLines[i]);
- }*/
-
SelectObject(hdc,oldFont);
SelectObject(hdc,oldPen);
SelectObject(hdc,oldBrush);
diff --git a/Windows/Debugger/CtrlDisAsmView.h b/Windows/Debugger/CtrlDisAsmView.h
index aa6760c4f..a486841be 100644
--- a/Windows/Debugger/CtrlDisAsmView.h
+++ b/Windows/Debugger/CtrlDisAsmView.h
@@ -36,10 +36,6 @@ class CtrlDisAsmView
HFONT boldfont;
RECT rect;
-// std::map functions;
- std::vector visibleFunctionAddresses;
- std::vector strayLines;
-
DisassemblyManager manager;
u32 curAddress;
u32 selectRangeStart;
@@ -81,7 +77,7 @@ class CtrlDisAsmView
void calculatePixelPositions();
bool getDisasmAddressText(u32 address, char* dest, bool abbreviateLabels);
void updateStatusBarText();
- void drawBranchLine(HDC hdc, BranchLine& line);
+ void drawBranchLine(HDC hdc, std::map& addressPositions, BranchLine& line);
void copyInstructions(u32 startAddr, u32 endAddr, bool withDisasm);
public:
CtrlDisAsmView(HWND _wnd);
@@ -103,12 +99,7 @@ public:
bool curAddressIsVisible();
void redraw();
void scanFunctions();
- void clearFunctions()
- {
- // functions.clear();
- visibleFunctionAddresses.clear();
- strayLines.clear();
- };
+ void clearFunctions() { };
void getOpcodeText(u32 address, char* dest);
int getRowHeight() { return rowHeight; };