Skip to content

Commit

Permalink
Debugger: Add initial UI for mem info type.
Browse files Browse the repository at this point in the history
Does not visualize yet, just implements the selection interface.
  • Loading branch information
unknownbrackets committed Feb 15, 2021
1 parent 616f5dd commit 6168506
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 58 deletions.
7 changes: 7 additions & 0 deletions Windows/Debugger/CtrlMemView.cpp
Expand Up @@ -797,3 +797,10 @@ void CtrlMemView::toggleOffsetScale(CommonToggles toggle)
updateStatusBarText();
redraw();
}

void CtrlMemView::setHighlightType(MemBlockFlags flags) {
if (highlightFlags_ != flags) {
highlightFlags_ = flags;
redraw();
}
}
7 changes: 6 additions & 1 deletion Windows/Debugger/CtrlMemView.h
Expand Up @@ -17,7 +17,8 @@
//
//To get a class instance to be able to access it, just use getFrom(HWND wnd).

#include "../../Core/Debugger/DebugInterface.h"
#include "Core/Debugger/DebugInterface.h"
#include "Core/Debugger/MemBlockInfo.h"

enum OffsetSpacing {
offsetSpace = 3, // the number of blank lines that should be left to make space for the offsets
Expand Down Expand Up @@ -63,6 +64,9 @@ class CtrlMemView
bool hasFocus;
static wchar_t szClassName[];
DebugInterface *debugger;

MemBlockFlags highlightFlags_ = MemBlockFlags::ALLOC;

void updateStatusBarText();
void search(bool continueSearch);
public:
Expand Down Expand Up @@ -99,4 +103,5 @@ class CtrlMemView
void drawOffsetScale(HDC hdc);
void toggleOffsetScale(CommonToggles toggle);
void toggleStringSearch(CommonToggles toggle);
void setHighlightType(MemBlockFlags flags);
};
103 changes: 49 additions & 54 deletions Windows/Debugger/Debugger_MemoryDlg.cpp
Expand Up @@ -4,11 +4,12 @@
#include <windowsx.h>
#include "..\resource.h"

#include "Common/System/Display.h"
#include "Common/Data/Encoding/Utf8.h"
#include "Common/System/Display.h"

#include "Core/Debugger/MemBlockInfo.h"
#include "Core/Debugger/SymbolMap.h"
#include "Core/MIPS/MIPSDebugInterface.h" // BAD
#include "Core/MIPS/MIPSDebugInterface.h"

#include "Debugger_MemoryDlg.h"
#include "CtrlMemView.h"
Expand Down Expand Up @@ -68,6 +69,18 @@ CMemoryDlg::CMemoryDlg(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu
searchBoxHdl = GetDlgItem(m_hDlg, IDC_SEARCH_BOX);
srcListHdl = GetDlgItem(m_hDlg, IDC_SEARCH_RESULTS);

layerDropdown_ = GetDlgItem(m_hDlg, IDC_REGIONS);
ComboBox_ResetContent(layerDropdown_);
ComboBox_AddString(layerDropdown_, L"Show allocations");
ComboBox_SetItemData(layerDropdown_, 0, MemBlockFlags::ALLOC);
ComboBox_AddString(layerDropdown_, L"Show sub allocations");
ComboBox_SetItemData(layerDropdown_, 1, MemBlockFlags::SUB_ALLOC);
ComboBox_AddString(layerDropdown_, L"Show writes");
ComboBox_SetItemData(layerDropdown_, 2, MemBlockFlags::WRITE);
ComboBox_AddString(layerDropdown_, L"Show textures");
ComboBox_SetItemData(layerDropdown_, 3, MemBlockFlags::TEXTURE);
ComboBox_SetCurSel(layerDropdown_, 0);

memView = CtrlMemView::getFrom(memViewHdl);
memView->setDebugger(_cpu);

Expand Down Expand Up @@ -118,66 +131,53 @@ void CMemoryDlg::searchBoxRedraw(std::vector<u32> results) {
void CMemoryDlg::NotifyMapLoaded()
{
if (m_hDlg)
{
g_symbolMap->FillSymbolListBox(symListHdl,ST_DATA);
int sel = ComboBox_GetCurSel(memViewHdl);
ComboBox_ResetContent(memViewHdl);
/*
for (int i = 0; i < cpu->getMemMap()->numRegions; i++)
{
// TODO: wchar_t
int n = ComboBox_AddString(lb,cpu->getMemMap()->regions[i].name);
ComboBox_SetItemData(lb,n,cpu->getMemMap()->regions[i].start);
}*/
ComboBox_SetCurSel(memViewHdl,sel>=0?sel:0);
}
g_symbolMap->FillSymbolListBox(symListHdl, ST_DATA);
Update();
}

BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message){
case WM_COMMAND:{
BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
wchar_t temp[256]{};
int n;

switch (message) {
case WM_COMMAND: {
HWND lb = GetDlgItem(m_hDlg, LOWORD(wParam));
switch (LOWORD(wParam)){
switch (LOWORD(wParam)) {
case IDC_REGIONS:
switch (HIWORD(wParam)) {
case LBN_DBLCLK:{
int n = ComboBox_GetCurSel(lb);
if (n != -1) {
unsigned int addr = (unsigned int)ComboBox_GetItemData(lb,n);
memView->gotoAddr(addr);
}
case CBN_SELENDOK:
n = ComboBox_GetCurSel(lb);
if (n != CB_ERR) {
MemBlockFlags flags = (MemBlockFlags)ComboBox_GetItemData(lb, n);
memView->setHighlightType(MemBlockFlags(flags));
}
break;
};
break;
}
break;
case IDC_SYMBOLS:
switch (HIWORD(wParam)) {
case LBN_DBLCLK:{
int n = ListBox_GetCurSel(lb);
if (n != -1) {
unsigned int addr = (unsigned int)ListBox_GetItemData(lb,n);
memView->gotoAddr(addr);
}
case LBN_DBLCLK:
n = ListBox_GetCurSel(lb);
if (n != -1) {
unsigned int addr = (unsigned int)ListBox_GetItemData(lb,n);
memView->gotoAddr(addr);
}
break;
}
break;
};
case IDC_SEARCH_RESULTS:
switch (HIWORD(wParam)) {
case LBN_DBLCLK: {
int n = ListBox_GetCurSel(lb);
if (n != -1) {
unsigned int addr = (unsigned int)ListBox_GetItemData(lb, n);
memView->gotoAddr(addr);
}
case LBN_DBLCLK:
n = ListBox_GetCurSel(lb);
if (n != -1) {
unsigned int addr = (unsigned int)ListBox_GetItemData(lb, n);
memView->gotoAddr(addr);
}
break;
}
break;
};
break;
case IDC_SHOWOFFSETS:
switch (HIWORD(wParam))
{
switch (HIWORD(wParam)) {
case BN_CLICKED:
if (SendDlgItemMessage(m_hDlg, IDC_SHOWOFFSETS, BM_GETCHECK, 0, 0))
memView->toggleOffsetScale(On);
Expand All @@ -187,25 +187,23 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
}
break;
case IDC_BUTTON_SEARCH:
switch (HIWORD(wParam))
{
switch (HIWORD(wParam)) {
case BN_CLICKED:
wchar_t temp[256];
GetWindowText(searchBoxHdl, temp, 255);
std::vector<u32> results = memView->searchString(ConvertWStringToUTF8(temp).c_str());
if (results.size() > 0){
searchBoxRedraw(results);
}
break;
}
break;
}
}
break;
case WM_DEB_MAPLOADED:
NotifyMapLoaded();
break;
case WM_DEB_GOTOADDRESSEDIT:{
wchar_t temp[256];
case WM_DEB_GOTOADDRESSEDIT: {
u32 addr;
GetWindowText(editWnd,temp,255);

Expand All @@ -223,10 +221,7 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;

case WM_INITDIALOG:
{
return TRUE;
}
break;
return TRUE;

case WM_SIZE:
Size();
Expand Down
1 change: 1 addition & 0 deletions Windows/Debugger/Debugger_MemoryDlg.h
Expand Up @@ -17,6 +17,7 @@ class CMemoryDlg : public Dialog
RECT winRect, srRect;
CtrlMemView *memView;
HWND memViewHdl, symListHdl, editWnd, searchBoxHdl, srcListHdl;
HWND layerDropdown_;
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam);

public:
Expand Down
6 changes: 3 additions & 3 deletions Windows/ppsspp.rc
Expand Up @@ -321,14 +321,14 @@ BEGIN
CONTROL "Normal",IDC_MODENORMAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,198,9,40,9
CONTROL "Symbols",IDC_MODESYMBOLS,"Button",BS_AUTORADIOBUTTON,241,9,43,8
GROUPBOX "Mode",IDC_STATIC,191,0,104,22
AUTOCHECKBOX "Show Offsets",IDC_SHOWOFFSETS,300,9,55,8
COMBOBOX IDC_REGIONS,87,5,88,139,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
AUTOCHECKBOX "Show Offsets",IDC_SHOWOFFSETS,300,9,55,8
COMBOBOX IDC_REGIONS,95,5,88,139,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP

LISTBOX IDC_SEARCH_RESULTS,557,14,140,272,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP

EDITTEXT IDC_SEARCH_BOX,397,6,100,13,ES_AUTOHSCROLL
PUSHBUTTON "Search",IDC_BUTTON_SEARCH,504,5,50,14
LTEXT "Search:",IDC_STATIC,369,6,27,8
LTEXT "Search:",IDC_STATIC,369,8,27,8
END

IDD_INPUTBOX DIALOGEX 0, 0, 163, 55
Expand Down

0 comments on commit 6168506

Please sign in to comment.