Debugger: Small performance fix
This commit is contained in:
parent
15bc6c85ac
commit
7bfe260c27
5 changed files with 23 additions and 9 deletions
|
@ -578,9 +578,17 @@ void Debugger::GenerateCodeOutput()
|
|||
|
||||
const char* Debugger::GetCode(uint32_t &length)
|
||||
{
|
||||
string previousCode = _disassemblerOutput;
|
||||
GenerateCodeOutput();
|
||||
length = (uint32_t)_disassemblerOutput.size();
|
||||
return _disassemblerOutput.c_str();
|
||||
if(previousCode.compare(_disassemblerOutput) == 0) {
|
||||
//Return null pointer if the code is identical to last call
|
||||
//This avois the UTF8->UTF16 conversion that the UI needs to do
|
||||
//before comparing the strings
|
||||
return nullptr;
|
||||
} else {
|
||||
return _disassemblerOutput.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Debugger::GetRelativeAddress(uint32_t addr, AddressType type)
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace Mesen.GUI.Debugger
|
|||
get { return _code; }
|
||||
set
|
||||
{
|
||||
if(value != _code) {
|
||||
if(value != null) {
|
||||
_codeChanged = true;
|
||||
_code = value;
|
||||
UpdateCode();
|
||||
|
|
2
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
2
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
|
@ -242,7 +242,6 @@ namespace Mesen.GUI.Debugger
|
|||
//
|
||||
// ctrlDebuggerCode
|
||||
//
|
||||
this.ctrlDebuggerCode.Code = null;
|
||||
this.ctrlDebuggerCode.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlDebuggerCode.Location = new System.Drawing.Point(3, 3);
|
||||
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
|
||||
|
@ -264,7 +263,6 @@ namespace Mesen.GUI.Debugger
|
|||
//
|
||||
// ctrlDebuggerCodeSplit
|
||||
//
|
||||
this.ctrlDebuggerCodeSplit.Code = null;
|
||||
this.ctrlDebuggerCodeSplit.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(495, 3);
|
||||
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
|
||||
|
|
|
@ -283,7 +283,6 @@ namespace Mesen.GUI.Debugger
|
|||
mnuGoToIrqHandler.Text = "IRQ Handler ($" + irqHandler.ToString("X4") + ")";
|
||||
}
|
||||
|
||||
string _previousCode = string.Empty;
|
||||
private void UpdateDebugger(bool updateActiveAddress = true)
|
||||
{
|
||||
if(!_debuggerInitialized) {
|
||||
|
@ -295,14 +294,18 @@ namespace Mesen.GUI.Debugger
|
|||
UpdateDebuggerFlags();
|
||||
UpdateVectorAddresses();
|
||||
|
||||
_previousCode = InteropEmu.DebugGetCode();
|
||||
ctrlDebuggerCode.Code = _previousCode;
|
||||
string newCode = InteropEmu.DebugGetCode();
|
||||
if(newCode != null) {
|
||||
ctrlDebuggerCode.Code = newCode;
|
||||
}
|
||||
|
||||
DebugState state = new DebugState();
|
||||
InteropEmu.DebugGetState(ref state);
|
||||
|
||||
if(UpdateSplitView()) {
|
||||
ctrlDebuggerCodeSplit.Code = _previousCode;
|
||||
if(newCode != null || ctrlDebuggerCodeSplit.Code == null) {
|
||||
ctrlDebuggerCodeSplit.Code = ctrlDebuggerCode.Code;
|
||||
}
|
||||
ctrlDebuggerCodeSplit.UpdateCode(true);
|
||||
} else {
|
||||
_lastCodeWindow = ctrlDebuggerCode;
|
||||
|
|
|
@ -215,7 +215,12 @@ namespace Mesen.GUI
|
|||
public static string DebugGetCode()
|
||||
{
|
||||
UInt32 length;
|
||||
return PtrToStringUtf8(InteropEmu.DebugGetCodeWrapper(out length), length);
|
||||
IntPtr ptrCodeString = InteropEmu.DebugGetCodeWrapper(out length);
|
||||
if(ptrCodeString == IntPtr.Zero) {
|
||||
return null;
|
||||
} else {
|
||||
return PtrToStringUtf8(ptrCodeString, length);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(DLLPath, EntryPoint="DebugAssembleCode")] private static extern UInt32 DebugAssembleCodeWrapper([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string code, UInt16 startAddress, IntPtr assembledCodeBuffer);
|
||||
|
|
Loading…
Add table
Reference in a new issue