From 9af83bb79c1ae98ce27e68f985d12163dbb8e7b4 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Fri, 20 Sep 2013 20:30:08 +0000 Subject: [PATCH] * Debugger: newly created Bookmarks inherit existing symbolic name by default * Debugger, Tracer: right-clicking on an address or a symbolic name works even when there's selection --- trunk/src/drivers/win/debugger.cpp | 21 ++++++++++++++++++--- trunk/src/drivers/win/debuggersp.cpp | 11 +++++++++-- trunk/src/drivers/win/tracer.cpp | 19 +++++++++++++++++-- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/trunk/src/drivers/win/debugger.cpp b/trunk/src/drivers/win/debugger.cpp index 5cdbaf8d..e7c97822 100644 --- a/trunk/src/drivers/win/debugger.cpp +++ b/trunk/src/drivers/win/debugger.cpp @@ -1380,7 +1380,7 @@ void LoadGameDebuggerData(HWND hwndDlg = hDebug) int Debugger_CheckClickingOnAnAddressOrSymbolicName(unsigned int lineNumber, bool onlyCheckWhenNothingSelected) { // debug_str contains the text in the disassembly window - int sel_start, sel_end; + int sel_start = 0, sel_end = 0; SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); if (onlyCheckWhenNothingSelected) if (sel_end > sel_start) @@ -1511,8 +1511,14 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w } case WM_RBUTTONUP: { - // if nothing is selected, try bringing Symbolic Debug Naming dialog - int offset = Debugger_CheckClickingOnAnAddressOrSymbolicName(GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight, true); + // save current selection + int sel_start = 0, sel_end = 0; + SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + // simulate a click + CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); + CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONUP, wParam, lParam); + // try bringing Symbolic Debug Naming dialog + int offset = Debugger_CheckClickingOnAnAddressOrSymbolicName(GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight, false); if (offset != EOF) { if (DoSymbolicDebugNaming(offset, hDebug)) @@ -1524,7 +1530,16 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w CheckDlgButton(hDebug, IDC_DEBUGGER_ENABLE_SYMBOLIC, BST_CHECKED); } UpdateDebugger(false); + } else + { + // then restore old selection + SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); } + return 0; + } else + { + // then restore old selection + SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); } break; } diff --git a/trunk/src/drivers/win/debuggersp.cpp b/trunk/src/drivers/win/debuggersp.cpp index dd39ba10..c916c639 100644 --- a/trunk/src/drivers/win/debuggersp.cpp +++ b/trunk/src/drivers/win/debuggersp.cpp @@ -660,7 +660,14 @@ void AddDebuggerBookmark2(HWND hwnd, unsigned int addr) { int index = bookmarks_addr.size(); bookmarks_addr.push_back(addr); - bookmarks_name.push_back(""); + // try to find Symbolic name for this address + Name* node = findNode(getNamesPointerForAddress(addr), addr); + if (node && node->name) + bookmarks_name.push_back(node->name); + else + bookmarks_name.push_back(""); + + // add new item to ListBox char buffer[256]; sprintf(buffer, "%04X %s", bookmarks_addr[index], bookmarks_name[index].c_str()); SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_ADDSTRING, 0, (LPARAM)buffer); @@ -676,7 +683,7 @@ void AddDebuggerBookmark2(HWND hwnd, unsigned int addr) **/ void AddDebuggerBookmark(HWND hwnd) { - unsigned int n; + int n; char buffer[5] = {0}; GetDlgItemText(hwnd, IDC_DEBUGGER_BOOKMARK, buffer, 5); diff --git a/trunk/src/drivers/win/tracer.cpp b/trunk/src/drivers/win/tracer.cpp index 34d6a84a..1bcc4c2a 100644 --- a/trunk/src/drivers/win/tracer.cpp +++ b/trunk/src/drivers/win/tracer.cpp @@ -220,8 +220,14 @@ BOOL CALLBACK IDC_TRACER_LOG_WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA } case WM_RBUTTONUP: { - // if nothing is selected, try bringing Symbolic Debug Naming dialog - int offset = Tracer_CheckClickingOnAnAddressOrSymbolicName(tracesi.nPos + (GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight), true); + // save current selection + int sel_start, sel_end; + SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + // simulate a click + CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); + CallWindowProc(IDC_TRACER_LOG_oldWndProc, hwndDlg, WM_LBUTTONUP, wParam, lParam); + // try bringing Symbolic Debug Naming dialog + int offset = Tracer_CheckClickingOnAnAddressOrSymbolicName(tracesi.nPos + (GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight), false); if (offset != EOF) { if (DoSymbolicDebugNaming(offset, hTracer)) @@ -230,7 +236,16 @@ BOOL CALLBACK IDC_TRACER_LOG_WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA UpdateDebugger(false); if (hMemView) UpdateCaption(); + } else + { + // then restore old selection + SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); } + return 0; + } else + { + // then restore old selection + SendDlgItemMessage(hTracer, IDC_TRACER_LOG, EM_SETSEL, (WPARAM)sel_start, (LPARAM)sel_end); } break; }