mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-23 17:19:39 +00:00
Debugger: Lua - Added (configurable) script timeout to prevent infinite loops from locking up the emulator
This commit is contained in:
parent
db1b689161
commit
80c80181ba
@ -36,29 +36,39 @@ void DebugHud::Draw(uint32_t* argbBuffer, OverscanDimensions overscan, uint32_t
|
||||
void DebugHud::DrawPixel(int x, int y, int color, int frameCount, int startFrame)
|
||||
{
|
||||
auto lock = _commandLock.AcquireSafe();
|
||||
_commands.push_back(unique_ptr<DrawPixelCommand>(new DrawPixelCommand(x, y, color, frameCount, startFrame)));
|
||||
if(_commands.size() < DebugHud::MaxCommandCount) {
|
||||
_commands.push_back(unique_ptr<DrawPixelCommand>(new DrawPixelCommand(x, y, color, frameCount, startFrame)));
|
||||
}
|
||||
}
|
||||
|
||||
void DebugHud::DrawLine(int x, int y, int x2, int y2, int color, int frameCount, int startFrame)
|
||||
{
|
||||
auto lock = _commandLock.AcquireSafe();
|
||||
_commands.push_back(unique_ptr<DrawLineCommand>(new DrawLineCommand(x, y, x2, y2, color, frameCount, startFrame)));
|
||||
if(_commands.size() < DebugHud::MaxCommandCount) {
|
||||
_commands.push_back(unique_ptr<DrawLineCommand>(new DrawLineCommand(x, y, x2, y2, color, frameCount, startFrame)));
|
||||
}
|
||||
}
|
||||
|
||||
void DebugHud::DrawRectangle(int x, int y, int width, int height, int color, bool fill, int frameCount, int startFrame)
|
||||
{
|
||||
auto lock = _commandLock.AcquireSafe();
|
||||
_commands.push_back(unique_ptr<DrawRectangleCommand>(new DrawRectangleCommand(x, y, width, height, color, fill, frameCount, startFrame)));
|
||||
if(_commands.size() < DebugHud::MaxCommandCount) {
|
||||
_commands.push_back(unique_ptr<DrawRectangleCommand>(new DrawRectangleCommand(x, y, width, height, color, fill, frameCount, startFrame)));
|
||||
}
|
||||
}
|
||||
|
||||
void DebugHud::DrawScreenBuffer(uint32_t* screenBuffer, int startFrame)
|
||||
{
|
||||
auto lock = _commandLock.AcquireSafe();
|
||||
_commands.push_back(unique_ptr<DrawScreenBufferCommand>(new DrawScreenBufferCommand(screenBuffer, startFrame)));
|
||||
if(_commands.size() < DebugHud::MaxCommandCount) {
|
||||
_commands.push_back(unique_ptr<DrawScreenBufferCommand>(new DrawScreenBufferCommand(screenBuffer, startFrame)));
|
||||
}
|
||||
}
|
||||
|
||||
void DebugHud::DrawString(int x, int y, string text, int color, int backColor, int frameCount, int startFrame)
|
||||
{
|
||||
auto lock = _commandLock.AcquireSafe();
|
||||
_commands.push_back(unique_ptr<DrawStringCommand>(new DrawStringCommand(x, y, text, color, backColor, frameCount, startFrame)));
|
||||
if(_commands.size() < DebugHud::MaxCommandCount) {
|
||||
_commands.push_back(unique_ptr<DrawStringCommand>(new DrawStringCommand(x, y, text, color, backColor, frameCount, startFrame)));
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ class DrawCommand;
|
||||
class DebugHud
|
||||
{
|
||||
private:
|
||||
static constexpr size_t MaxCommandCount = 500000;
|
||||
vector<unique_ptr<DrawCommand>> _commands;
|
||||
SimpleLock _commandLock;
|
||||
|
||||
|
@ -6,6 +6,9 @@
|
||||
#include "DebuggerTypes.h"
|
||||
#include "Debugger.h"
|
||||
|
||||
LuaScriptingContext* LuaScriptingContext::_context = nullptr;
|
||||
uint32_t LuaScriptingContext::_timeout = 1000;
|
||||
|
||||
LuaScriptingContext::LuaScriptingContext(Debugger* debugger) : ScriptingContext(debugger)
|
||||
{
|
||||
}
|
||||
@ -38,18 +41,34 @@ LuaScriptingContext::~LuaScriptingContext()
|
||||
}
|
||||
}
|
||||
|
||||
void LuaScriptingContext::SetScriptTimeout(uint32_t timeout)
|
||||
{
|
||||
_timeout = timeout;
|
||||
}
|
||||
|
||||
void LuaScriptingContext::ExecutionCountHook(lua_State *lua, lua_Debug *ar)
|
||||
{
|
||||
if(_context->_timer.GetElapsedMS() > _timeout) {
|
||||
luaL_error(lua, (std::string("Maximum execution time (") + std::to_string(_timeout) + " ms) exceeded.").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool LuaScriptingContext::LoadScript(string scriptName, string scriptContent, Debugger* debugger)
|
||||
{
|
||||
_scriptName = scriptName;
|
||||
|
||||
int iErr = 0;
|
||||
_lua = luaL_newstate();
|
||||
|
||||
_context = this;
|
||||
LuaApi::SetContext(this);
|
||||
|
||||
luaL_openlibs(_lua);
|
||||
luaL_requiref(_lua, "emu", LuaApi::GetLibrary, 1);
|
||||
Log("Loading script...");
|
||||
if((iErr = luaL_loadbufferx(_lua, scriptContent.c_str(), scriptContent.size(), ("@" + scriptName).c_str(), nullptr)) == 0) {
|
||||
_timer.Reset();
|
||||
lua_sethook(_lua, LuaScriptingContext::ExecutionCountHook, LUA_MASKCOUNT, 1000);
|
||||
if((iErr = lua_pcall(_lua, 0, LUA_MULTRET, 0)) == 0) {
|
||||
//Script loaded properly
|
||||
Log("Script loaded successfully.");
|
||||
@ -77,12 +96,19 @@ void LuaScriptingContext::UnregisterEventCallback(EventType type, int reference)
|
||||
|
||||
void LuaScriptingContext::InternalCallMemoryCallback(uint16_t addr, uint8_t &value, CallbackType type)
|
||||
{
|
||||
if(_callbacks[(int)type][addr].empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
_timer.Reset();
|
||||
_context = this;
|
||||
lua_sethook(_lua, LuaScriptingContext::ExecutionCountHook, LUA_MASKCOUNT, 1000);
|
||||
LuaApi::SetContext(this);
|
||||
for(int &ref : _callbacks[(int)type][addr]) {
|
||||
int top = lua_gettop(_lua);
|
||||
lua_rawgeti(_lua, LUA_REGISTRYINDEX, ref);
|
||||
lua_pushinteger(_lua, addr);
|
||||
lua_pushinteger(_lua, value);
|
||||
lua_pushinteger(_lua, value);
|
||||
if(lua_pcall(_lua, 2, LUA_MULTRET, 0) != 0) {
|
||||
Log(lua_tostring(_lua, -1));
|
||||
} else {
|
||||
@ -98,6 +124,13 @@ void LuaScriptingContext::InternalCallMemoryCallback(uint16_t addr, uint8_t &val
|
||||
|
||||
int LuaScriptingContext::InternalCallEventCallback(EventType type)
|
||||
{
|
||||
if(_eventCallbacks[(int)type].empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_timer.Reset();
|
||||
_context = this;
|
||||
lua_sethook(_lua, LuaScriptingContext::ExecutionCountHook, LUA_MASKCOUNT, 1000);
|
||||
LuaApi::SetContext(this);
|
||||
LuaCallHelper l(_lua);
|
||||
for(int &ref : _eventCallbacks[(int)type]) {
|
||||
|
@ -1,14 +1,21 @@
|
||||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "ScriptingContext.h"
|
||||
#include "../Utilities/Timer.h"
|
||||
|
||||
struct lua_State;
|
||||
struct lua_Debug;
|
||||
class Debugger;
|
||||
|
||||
class LuaScriptingContext : public ScriptingContext
|
||||
{
|
||||
private:
|
||||
static LuaScriptingContext* _context;
|
||||
static uint32_t _timeout;
|
||||
lua_State* _lua = nullptr;
|
||||
Timer _timer;
|
||||
|
||||
static void ExecutionCountHook(lua_State* lua, lua_Debug* ar);
|
||||
|
||||
protected:
|
||||
void InternalCallMemoryCallback(uint16_t addr, uint8_t &value, CallbackType type) override;
|
||||
@ -18,6 +25,8 @@ public:
|
||||
LuaScriptingContext(Debugger* debugger);
|
||||
virtual ~LuaScriptingContext();
|
||||
|
||||
static void SetScriptTimeout(uint32_t timeout);
|
||||
|
||||
bool LoadScript(string scriptName, string scriptContent, Debugger* debugger) override;
|
||||
|
||||
void UnregisterMemoryCallback(CallbackType type, int startAddr, int endAddr, int reference) override;
|
||||
|
@ -321,6 +321,7 @@ namespace Mesen.GUI.Config
|
||||
public FontStyle ScriptFontStyle = FontStyle.Regular;
|
||||
public float ScriptFontSize = BaseControl.DefaultFontSize;
|
||||
public int ScriptZoom = 100;
|
||||
public UInt32 ScriptTimeout = 1000;
|
||||
|
||||
public bool AssemblerCodeHighlighting = true;
|
||||
public XmlColor AssemblerOpcodeColor = Color.FromArgb(22, 37, 37);
|
||||
@ -369,6 +370,7 @@ namespace Mesen.GUI.Config
|
||||
static public void ApplyConfig()
|
||||
{
|
||||
InteropEmu.SetFlag(EmulationFlags.BreakOnCrash, ConfigManager.Config.DebugInfo.BreakOnCrash);
|
||||
InteropEmu.DebugSetScriptTimeout(ConfigManager.Config.DebugInfo.ScriptTimeout);
|
||||
}
|
||||
|
||||
public void AddRecentScript(string scriptFile)
|
||||
|
48
GUI.NET/Debugger/frmScript.Designer.cs
generated
48
GUI.NET/Debugger/frmScript.Designer.cs
generated
@ -62,6 +62,8 @@
|
||||
this.mnuBlankWindow = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuTutorialScript = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuAutoLoadLastScript = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuApiReference = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip();
|
||||
this.txtScriptContent = new FastColoredTextBoxNS.FastColoredTextBox();
|
||||
this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
@ -76,8 +78,8 @@
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.lblScriptActive = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuApiReference = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuSetScriptTimeout = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuMain.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtScriptContent)).BeginInit();
|
||||
this.contextMenu.SuspendLayout();
|
||||
@ -257,6 +259,8 @@
|
||||
this.scriptToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuRun,
|
||||
this.mnuStop,
|
||||
this.toolStripMenuItem7,
|
||||
this.mnuSetScriptTimeout,
|
||||
this.toolStripMenuItem3,
|
||||
this.mnuSaveBeforeRun,
|
||||
this.mnuAutoReload,
|
||||
@ -332,6 +336,22 @@
|
||||
this.mnuAutoLoadLastScript.Text = "Load the last script loaded";
|
||||
this.mnuAutoLoadLastScript.Click += new System.EventHandler(this.mnuAutoLoadLastScript_Click);
|
||||
//
|
||||
// mnuHelp
|
||||
//
|
||||
this.mnuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuApiReference});
|
||||
this.mnuHelp.Name = "mnuHelp";
|
||||
this.mnuHelp.Size = new System.Drawing.Size(44, 20);
|
||||
this.mnuHelp.Text = "Help";
|
||||
//
|
||||
// mnuApiReference
|
||||
//
|
||||
this.mnuApiReference.Image = global::Mesen.GUI.Properties.Resources.Exclamation;
|
||||
this.mnuApiReference.Name = "mnuApiReference";
|
||||
this.mnuApiReference.Size = new System.Drawing.Size(147, 22);
|
||||
this.mnuApiReference.Text = "API Reference";
|
||||
this.mnuApiReference.Click += new System.EventHandler(this.mnuApiReference_Click);
|
||||
//
|
||||
// tsToolbar
|
||||
//
|
||||
this.tsToolbar.Location = new System.Drawing.Point(0, 24);
|
||||
@ -368,7 +388,6 @@
|
||||
this.txtScriptContent.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.txtScriptContent.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
|
||||
this.txtScriptContent.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtScriptContent.Font = new System.Drawing.Font("Courier New", 9.75F);
|
||||
this.txtScriptContent.IsReplaceMode = false;
|
||||
this.txtScriptContent.Language = FastColoredTextBoxNS.Language.Lua;
|
||||
this.txtScriptContent.LeftBracket = '(';
|
||||
@ -496,21 +515,18 @@
|
||||
this.lblScriptActive.Text = "Script is running";
|
||||
this.lblScriptActive.Visible = false;
|
||||
//
|
||||
// mnuHelp
|
||||
// mnuSetScriptTimeout
|
||||
//
|
||||
this.mnuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuApiReference});
|
||||
this.mnuHelp.Name = "mnuHelp";
|
||||
this.mnuHelp.Size = new System.Drawing.Size(44, 20);
|
||||
this.mnuHelp.Text = "Help";
|
||||
this.mnuSetScriptTimeout.Image = global::Mesen.GUI.Properties.Resources.Speed;
|
||||
this.mnuSetScriptTimeout.Name = "mnuSetScriptTimeout";
|
||||
this.mnuSetScriptTimeout.Size = new System.Drawing.Size(258, 22);
|
||||
this.mnuSetScriptTimeout.Text = "Set Script Timeout...";
|
||||
this.mnuSetScriptTimeout.Click += new System.EventHandler(this.mnuSetScriptTimeout_Click);
|
||||
//
|
||||
// mnuApiReference
|
||||
// toolStripMenuItem7
|
||||
//
|
||||
this.mnuApiReference.Image = global::Mesen.GUI.Properties.Resources.Exclamation;
|
||||
this.mnuApiReference.Name = "mnuApiReference";
|
||||
this.mnuApiReference.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuApiReference.Text = "API Reference";
|
||||
this.mnuApiReference.Click += new System.EventHandler(this.mnuApiReference_Click);
|
||||
this.toolStripMenuItem7.Name = "toolStripMenuItem7";
|
||||
this.toolStripMenuItem7.Size = new System.Drawing.Size(255, 6);
|
||||
//
|
||||
// frmScript
|
||||
//
|
||||
@ -589,5 +605,7 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuBuiltInScripts;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuHelp;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuApiReference;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuSetScriptTimeout;
|
||||
}
|
||||
}
|
@ -31,6 +31,8 @@ namespace Mesen.GUI.Debugger
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DebugInfo.ApplyConfig();
|
||||
|
||||
List<string> builtInScripts = new List<string> { "DmcCapture.lua", "DrawMode.lua", "Example.lua", "GameBoyMode.lua", "Grid.lua", "LogParallax.lua", "ModifyScreen.lua", "NtscSafeArea.lua", "ReverseMode.lua", "SpriteBox.lua" };
|
||||
foreach(string script in builtInScripts) {
|
||||
ToolStripItem item = mnuBuiltInScripts.DropDownItems.Add(script);
|
||||
@ -470,6 +472,13 @@ namespace Mesen.GUI.Debugger
|
||||
Process.Start("https://www.mesen.ca/ApiReference.php");
|
||||
}
|
||||
|
||||
private void mnuSetScriptTimeout_Click(object sender, EventArgs e)
|
||||
{
|
||||
using(frmSetScriptTimeout frm = new frmSetScriptTimeout()) {
|
||||
frm.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
static readonly List<List<string>> _availableFunctions = new List<List<string>>() {
|
||||
new List<string> {"enum", "emu", "", "", "", "", "" },
|
||||
new List<string> {"func","emu.addEventCallback","emu.addEventCallback(function, type)","function - A Lua function.\ntype - *Enum* See eventCallbackType.","Returns an integer value that can be used to remove the callback by calling removeEventCallback.","Registers a callback function to be called whenever the specified event occurs.",},
|
||||
|
142
GUI.NET/Debugger/frmSetScriptTimeout.Designer.cs
generated
Normal file
142
GUI.NET/Debugger/frmSetScriptTimeout.Designer.cs
generated
Normal file
@ -0,0 +1,142 @@
|
||||
using Mesen.GUI.Controls;
|
||||
|
||||
namespace Mesen.GUI.Debugger
|
||||
{
|
||||
partial class frmSetScriptTimeout
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.nudTimeout = new Mesen.GUI.Controls.MesenNumericUpDown();
|
||||
this.lblTimeout = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.lblMs = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// baseConfigPanel
|
||||
//
|
||||
this.baseConfigPanel.Location = new System.Drawing.Point(0, 29);
|
||||
this.baseConfigPanel.Size = new System.Drawing.Size(186, 29);
|
||||
//
|
||||
// nudTimeout
|
||||
//
|
||||
this.nudTimeout.DecimalPlaces = 0;
|
||||
this.nudTimeout.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudTimeout.Location = new System.Drawing.Point(84, 3);
|
||||
this.nudTimeout.Maximum = new decimal(new int[] {
|
||||
99999,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudTimeout.MaximumSize = new System.Drawing.Size(10000, 20);
|
||||
this.nudTimeout.Minimum = new decimal(new int[] {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudTimeout.MinimumSize = new System.Drawing.Size(0, 21);
|
||||
this.nudTimeout.Name = "nudTimeout";
|
||||
this.tableLayoutPanel1.SetRowSpan(this.nudTimeout, 2);
|
||||
this.nudTimeout.Size = new System.Drawing.Size(57, 21);
|
||||
this.nudTimeout.TabIndex = 3;
|
||||
this.nudTimeout.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// lblTimeout
|
||||
//
|
||||
this.lblTimeout.AutoSize = true;
|
||||
this.lblTimeout.Location = new System.Drawing.Point(3, 5);
|
||||
this.lblTimeout.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
|
||||
this.lblTimeout.Name = "lblTimeout";
|
||||
this.tableLayoutPanel1.SetRowSpan(this.lblTimeout, 2);
|
||||
this.lblTimeout.Size = new System.Drawing.Size(75, 13);
|
||||
this.lblTimeout.TabIndex = 0;
|
||||
this.lblTimeout.Text = "Script Timeout";
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 4;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.lblMs, 2, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.lblTimeout, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.nudTimeout, 1, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 4;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(186, 58);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// lblMs
|
||||
//
|
||||
this.lblMs.AutoSize = true;
|
||||
this.lblMs.Location = new System.Drawing.Point(147, 5);
|
||||
this.lblMs.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
|
||||
this.lblMs.Name = "lblMs";
|
||||
this.tableLayoutPanel1.SetRowSpan(this.lblMs, 2);
|
||||
this.lblMs.Size = new System.Drawing.Size(20, 13);
|
||||
this.lblMs.TabIndex = 4;
|
||||
this.lblMs.Text = "ms";
|
||||
//
|
||||
// frmSetScriptTimeout
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(186, 58);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Name = "frmSetScriptTimeout";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Set Script Timeout";
|
||||
this.Controls.SetChildIndex(this.tableLayoutPanel1, 0);
|
||||
this.Controls.SetChildIndex(this.baseConfigPanel, 0);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private MesenNumericUpDown nudTimeout;
|
||||
private System.Windows.Forms.Label lblTimeout;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Label lblMs;
|
||||
}
|
||||
}
|
41
GUI.NET/Debugger/frmSetScriptTimeout.cs
Normal file
41
GUI.NET/Debugger/frmSetScriptTimeout.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Mesen.GUI.Config;
|
||||
using Mesen.GUI.Forms;
|
||||
|
||||
namespace Mesen.GUI.Debugger
|
||||
{
|
||||
public partial class frmSetScriptTimeout : BaseConfigForm
|
||||
{
|
||||
public frmSetScriptTimeout()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
nudTimeout.Value = ConfigManager.Config.DebugInfo.ScriptTimeout;
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
nudTimeout.Focus();
|
||||
}
|
||||
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
{
|
||||
base.OnFormClosed(e);
|
||||
if(this.DialogResult == DialogResult.OK) {
|
||||
UInt32 count = (UInt32)nudTimeout.Value;
|
||||
ConfigManager.Config.DebugInfo.ScriptTimeout = count;
|
||||
ConfigManager.ApplyChanges();
|
||||
DebugInfo.ApplyConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
GUI.NET/Debugger/frmSetScriptTimeout.resx
Normal file
123
GUI.NET/Debugger/frmSetScriptTimeout.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -650,6 +650,12 @@
|
||||
<Compile Include="Debugger\frmAssembler.Designer.cs">
|
||||
<DependentUpon>frmAssembler.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\frmSetScriptTimeout.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\frmSetScriptTimeout.Designer.cs">
|
||||
<DependentUpon>frmSetScriptTimeout.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\frmBreakOn.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -1330,6 +1336,9 @@
|
||||
<EmbeddedResource Include="Debugger\Controls\ctrlSourceViewer.resx">
|
||||
<DependentUpon>ctrlSourceViewer.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Debugger\frmSetScriptTimeout.resx">
|
||||
<DependentUpon>frmSetScriptTimeout.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Debugger\frmTextHooker.resx">
|
||||
<DependentUpon>frmTextHooker.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -248,6 +248,7 @@ namespace Mesen.GUI
|
||||
[DllImport(DLLPath)] public static extern void DebugSetMemoryValue(DebugMemoryType type, UInt32 address, byte value);
|
||||
[DllImport(DLLPath)] public static extern void DebugSetInputOverride(Int32 port, Int32 state);
|
||||
|
||||
[DllImport(DLLPath)] public static extern void DebugSetScriptTimeout(UInt32 timeout);
|
||||
[DllImport(DLLPath)] public static extern Int32 DebugLoadScript([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string content, Int32 scriptId = -1);
|
||||
[DllImport(DLLPath)] public static extern void DebugRemoveScript(Int32 scriptId);
|
||||
[DllImport(DLLPath, EntryPoint = "DebugGetScriptLog")] private static extern IntPtr DebugGetScriptLogWrapper(Int32 scriptId);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "../Core/Profiler.h"
|
||||
#include "../Core/Assembler.h"
|
||||
#include "../Core/TraceLogger.h"
|
||||
#include "../Core/LuaScriptingContext.h"
|
||||
|
||||
enum class ConsoleId;
|
||||
|
||||
@ -138,6 +139,7 @@ extern "C"
|
||||
DllExport int32_t __stdcall DebugLoadScript(char* name, char* content, int32_t scriptId) { return GetDebugger()->LoadScript(name, content, scriptId); }
|
||||
DllExport void __stdcall DebugRemoveScript(int32_t scriptId) { GetDebugger()->RemoveScript(scriptId); }
|
||||
DllExport const char* __stdcall DebugGetScriptLog(int32_t scriptId) { return GetDebugger()->GetScriptLog(scriptId); }
|
||||
DllExport void __stdcall DebugSetScriptTimeout(uint32_t timeout) { LuaScriptingContext::SetScriptTimeout(timeout); }
|
||||
|
||||
DllExport void __stdcall DebugGetDebugEvents(uint32_t* pictureBuffer, DebugEventInfo *infoArray, uint32_t &maxEventCount, bool returnPreviousFrameData) { GetDebugger()->GetDebugEvents(pictureBuffer, infoArray, maxEventCount, returnPreviousFrameData); }
|
||||
DllExport uint32_t __stdcall DebugGetDebugEventCount(bool returnPreviousFrameData) { return GetDebugger()->GetDebugEventCount(returnPreviousFrameData); }
|
||||
|
Loading…
Reference in New Issue
Block a user