summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/Debugger/CodeWindow.h
blob: 0cd6604261500d62706f52375b508ce38d593ee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <array>

#include <wx/aui/framemanager.h>
#include <wx/bitmap.h>
#include <wx/panel.h>

#include "Common/CommonTypes.h"
#include "Common/Event.h"
#include "DolphinWX/Globals.h"

class CCodeView;
class CFrame;
struct SConfig;
class CBreakPointWindow;
class CRegisterWindow;
class CWatchWindow;
class CMemoryWindow;
class CJitWindow;
class DSPDebuggerLLE;
class GFXDebuggerPanel;

class DolphinAuiToolBar;
class wxListBox;
class wxMenu;
class wxMenuBar;
class wxToolBar;

namespace Details
{
template <class T>
struct DebugPanelToID;

template <>
struct DebugPanelToID<CBreakPointWindow>
{
  static constexpr int ID = IDM_BREAKPOINT_WINDOW;
};
template <>
struct DebugPanelToID<CRegisterWindow>
{
  static constexpr int ID = IDM_REGISTER_WINDOW;
};
template <>
struct DebugPanelToID<CWatchWindow>
{
  static constexpr int ID = IDM_WATCH_WINDOW;
};
template <>
struct DebugPanelToID<CMemoryWindow>
{
  static constexpr int ID = IDM_MEMORY_WINDOW;
};
template <>
struct DebugPanelToID<CJitWindow>
{
  static constexpr int ID = IDM_JIT_WINDOW;
};
template <>
struct DebugPanelToID<DSPDebuggerLLE>
{
  static constexpr int ID = IDM_SOUND_WINDOW;
};
template <>
struct DebugPanelToID<GFXDebuggerPanel>
{
  static constexpr int ID = IDM_VIDEO_WINDOW;
};
}

class CCodeWindow : public wxPanel
{
public:
  CCodeWindow(const SConfig& _LocalCoreStartupParameter, CFrame* parent, wxWindowID id = wxID_ANY,
              const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
              long style = wxTAB_TRAVERSAL | wxBORDER_NONE, const wxString& name = _("Code"));
  ~CCodeWindow();

  void Load();
  void Save();

  // Parent interaction
  wxMenuBar* GetMenuBar();
  wxToolBar* GetToolBar();

  bool UseInterpreter();
  bool BootToPause();
  bool AutomaticStart();
  bool JITNoBlockCache();
  bool JITNoBlockLinking();
  bool JumpToAddress(u32 address);

  void Repopulate();
  void NotifyMapLoaded();
  void CreateMenu(const SConfig& _LocalCoreStartupParameter, wxMenuBar* pMenuBar);
  void CreateMenuOptions(wxMenu* pMenu);
  void CreateMenuSymbols(wxMenuBar* pMenuBar);
  void PopulateToolbar(wxToolBar* toolBar);
  void UpdateButtonStates();
  void OpenPages();

  // Menu bar
  // FIXME: This belongs in a separate class.
  void TogglePanel(int id, bool show);
  wxPanel* GetUntypedPanel(int id) const;
  bool HasUntypedPanel(int id) const { return GetUntypedPanel(id) != nullptr; }
  template <class T>
  T* GetPanel() const
  {
    return static_cast<T*>(GetUntypedPanel(Details::DebugPanelToID<T>::ID));
  }
  template <class T>
  bool HasPanel() const
  {
    return HasUntypedPanel(Details::DebugPanelToID<T>::ID);
  }
  template <class T>
  T* RequirePanel()
  {
    if (T* p = GetPanel<T>())
      return p;

    TogglePanel(Details::DebugPanelToID<T>::ID, true);
    return GetPanel<T>();
  }

  // Settings
  bool bAutomaticStart;
  bool bBootToPause;
  bool bShowOnStart[IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START];
  int iNbAffiliation[IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START];

private:
  void OnCPUMode(wxCommandEvent& event);

  void OnChangeFont(wxCommandEvent& event);

  void OnCodeStep(wxCommandEvent& event);
  void OnAddrBoxChange(wxCommandEvent& event);
  void OnSymbolsMenu(wxCommandEvent& event);
  void OnJitMenu(wxCommandEvent& event);
  void OnProfilerMenu(wxCommandEvent& event);

  void OnSymbolListChange(wxCommandEvent& event);
  void OnCallstackListChange(wxCommandEvent& event);
  void OnCallersListChange(wxCommandEvent& event);
  void OnCallsListChange(wxCommandEvent& event);
  void OnCodeViewChange(wxCommandEvent& event);
  void OnHostMessage(wxCommandEvent& event);

  // Debugger functions
  void SingleStep();
  void StepOver();
  void StepOut();
  void ToggleBreakpoint();

  void UpdateLists();
  void UpdateCallstack();

  void InitBitmaps();
  wxPanel* CreateSiblingPanel(int id);

  wxBitmap m_Bitmaps[Toolbar_Debug_Bitmap_Max];

  // Sibling debugger panels
  // FIXME: This obviously belongs in some manager class above this one.
  std::array<wxPanel*, IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START> m_sibling_panels;

  CFrame* Parent;
  CCodeView* codeview;
  wxListBox* callstack;
  wxListBox* symbols;
  wxListBox* callers;
  wxListBox* calls;
  Common::Event sync_event;

  wxAuiManager m_aui_manager;
  DolphinAuiToolBar* m_aui_toolbar;
};