private void DebugProc(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string msg = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message, length); Console.WriteLine( "{0} {1} {2} {3}: {4}", source, type, id, severity, msg); }
private static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string msg = Marshal.PtrToStringAnsi(message); Console.WriteLine("[GL] {0}; {1}; {2}; {3}; {4}", source, type, id, severity, msg); }
static void PCCallbackHandler(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { if (severity == DebugSeverity.DebugSeverityHigh || severity == DebugSeverity.DebugSeverityMedium) { string msg = Marshal.PtrToStringAnsi(message); Console.WriteLine("[GL] {0}; {1}; {2}; {3}; {4}", source, type, id, severity, msg); } }
private static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string debugMessage = Marshal.PtrToStringAnsi(message, length); Debug.WriteLine(String.Format("{0} {1} {2}", severity, type, debugMessage)); }
void DebugProc(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { //string s = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message); //System.Diagnostics.Debug.WriteLine("{0} {1} {2} {3} {4} {5}", source, type, id, severity, length, s); // s = null; }
private static void MessageHandler(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { var debugMessage = Marshal.PtrToStringAnsi(message, length); Debug.WriteLine(debugMessage); }
private void AddSymbol(ulong ip, ulong stackFrame, ulong stackPointer) { var symbol = DebugSource.GetFirstSymbol(ip); treeView1.Nodes.Add(new CallStackEntry(symbol, ip, stackFrame, stackPointer)); }
/// <summary> /// Changes the properties of an array of debug message ids. /// This might be source, type, severity or just enable/disable them. /// Enables or Disables an array of Debug Messages ids /// </summary> /// <param name="source">Source of ids.</param> /// <param name="type">Type of ids</param> /// <param name="severity">Severity of ids.</param> /// <param name="ids">array of ids to change.</param> /// <param name="Enabled">Enables or disables the ids.</param> public static void DebugMessageControlARB(DebugSource source, DebugType type, DebugSeverity severity, uint[] ids, bool Enabled) { Delegates.glDebugMessageControlARB(source, type, severity, ids.Length, ref ids[0], Enabled); }
public abstract void DebugMessageControl([Flow(FlowDirection.In)] DebugSource source, [Flow(FlowDirection.In)] DebugType type, [Flow(FlowDirection.In)] DebugSeverity severity, [Flow(FlowDirection.In)] uint count, [Count(Parameter = "count"), Flow(FlowDirection.In)] Span <uint> ids, [Flow(FlowDirection.In)] bool enabled);
private static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string debugMessage = Marshal.PtrToStringAnsi(message, length); Debug.WriteLine($"{severity} {type} {debugMessage}"); }
public abstract void PushDebugGroup([Flow(FlowDirection.In)] DebugSource source, [Flow(FlowDirection.In)] uint id, [Flow(FlowDirection.In)] uint length, [Flow(FlowDirection.In)] string message);
public abstract unsafe void DebugMessageControl([Flow(FlowDirection.In)] DebugSource source, [Flow(FlowDirection.In)] DebugType type, [Flow(FlowDirection.In)] DebugSeverity severity, [Flow(FlowDirection.In)] uint count, [Flow(FlowDirection.In)] uint *ids, [Flow(FlowDirection.In)] bool enabled);
public static void HandleDebugGLMessage(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { StringBuilder errorString = new StringBuilder(); switch (source) { case DebugSource.DebugSourceApi: { errorString.Append("[API]"); break; } case DebugSource.DebugSourceApplication: { errorString.Append("[APP]"); break; } case DebugSource.DebugSourceOther: { errorString.Append("[Other]"); break; } case DebugSource.DebugSourceShaderCompiler: { errorString.Append("[Shader]"); break; } case DebugSource.DebugSourceThirdParty: { errorString.Append("[3RD]"); break; } case DebugSource.DebugSourceWindowSystem: { errorString.Append("[Window]"); break; } } switch (type) { case DebugType.DebugTypeDeprecatedBehavior: { errorString.Append("[DEPRECATED]"); break; } case DebugType.DebugTypeError: { errorString.Append("[ERROR]"); break; } case DebugType.DebugTypeMarker: { errorString.Append("[MARKER]"); break; } case DebugType.DebugTypeOther: { errorString.Append("[OTHER]"); break; } case DebugType.DebugTypePerformance: { errorString.Append("[PERF]"); break; } case DebugType.DebugTypePopGroup: { errorString.Append("[POPGROUP]"); break; } case DebugType.DebugTypePortability: { errorString.Append("[PORTABILITY]"); break; } case DebugType.DebugTypePushGroup: { errorString.Append("[PUSHGROUP]"); break; } case DebugType.DebugTypeUndefinedBehavior: { errorString.Append("[BEHAVIOR]"); break; } } errorString.Append(Marshal.PtrToStringAnsi(message)); switch (severity) { case DebugSeverity.DebugSeverityHigh: { Logger.Error(errorString.ToString()); //if (type == DebugType.DebugTypeError) throw new InvalidOperationException("ARB_debug_output found an error."); break; } case DebugSeverity.DebugSeverityMedium: { Logger.Warning(errorString.ToString()); break; } case DebugSeverity.DebugSeverityLow: { errorString.Insert(0, "[Low]"); Logger.Info(errorString.ToString()); break; } case DebugSeverity.DebugSeverityNotification: { errorString.Insert(0, "[Notice]"); Logger.Info(errorString.ToString()); break; } default: { break; } } }
void DebugMessage(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { var msg = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message, length); Console.WriteLine(string.Format("{0} {1} {2}", severity, type, msg)); }
private static void _debugMessageCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { var contents = $"{source}: " + Marshal.PtrToStringAnsi(message, length); var category = "ogl.debug"; switch (type) { case DebugType.DebugTypePerformance: category += ".performance"; break; case DebugType.DebugTypeOther: category += ".other"; break; case DebugType.DebugTypeError: category += ".error"; break; case DebugType.DebugTypeDeprecatedBehavior: category += ".deprecated"; break; case DebugType.DebugTypeUndefinedBehavior: category += ".ub"; break; case DebugType.DebugTypePortability: category += ".portability"; break; case DebugType.DebugTypeMarker: case DebugType.DebugTypePushGroup: case DebugType.DebugTypePopGroup: // These are inserted by our own code so I imagine they're not necessary to log? return; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } switch (severity) { case DebugSeverity.DontCare: Logger.InfoS(category, contents); break; case DebugSeverity.DebugSeverityNotification: Logger.InfoS(category, contents); break; case DebugSeverity.DebugSeverityHigh: Logger.ErrorS(category, contents); break; case DebugSeverity.DebugSeverityMedium: Logger.ErrorS(category, contents); break; case DebugSeverity.DebugSeverityLow: Logger.WarningS(category, contents); break; default: throw new ArgumentOutOfRangeException(nameof(severity), severity, null); } }
static void Callback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userparam) { //if(serverity == GL_DEBUG_SEVERITY_HIGH) Console.WriteLine("[Open Info: {severity: " + severity + ", source: " + source + ", type: " + type + ", id: " + id + "}]:\n " + message); }
/// <summary> /// Retrives a number of messages from message log and return the messages in array. /// </summary> /// <param name="sources"></param> /// <param name="types"></param> /// <param name="ids"></param> /// <param name="severities"></param> /// <param name="count"></param> /// <returns></returns> public static string[] GetDebugMessageLog(DebugSource[] sources, DebugType[] types, uint[] ids, DebugSeverity[] severities, int count = -1) { if (count == -1) { count = GetIntegerv(GetParameters.DebugLoggedMessages); } else count = Math.Min(sources.Length, Math.Min(types.Length, Math.Min(ids.Length, severities.Length))); // , MessageLogs.Length)))); var maxmessagelength = GetIntegerv(GetParameters.MaxDebugMessageLength); var sb = new StringBuilder(count * maxmessagelength + 4); var lengths = new int[count]; var result = (int)Delegates.glGetDebugMessageLog((uint)count, sb.Capacity - 2, ref sources[0], ref types[0], ref ids[0], ref severities[0], ref lengths[0], sb); if (result > 0) { var messages = new string[Math.Min(result, lengths.Length)]; int lastpos = 0; for (int i = 0; i < messages.Length; i++) { messages[i] = sb.ToString(lastpos, lengths[i] - 1); lastpos = lengths[i]; } return messages; } else return new string[0]; }
void debugOutput(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string msg = Marshal.PtrToStringAnsi(message, length); Info.print("GL Debug Message: {0} \n\tSource:{1} \n\tType:{2} \n\tSeverity:{3} \n\tID:{4} ", msg, source, type, severity, id); }
/// <summary> /// Pushes a debug group onto debug push stack. /// Usefull to during debug track a small part of a program. /// example. /// //at start /// DebugMessageControl([disable all logging]) /// /// //inside problematic part of ap. /// PushDebugGroup("Enter Shader Compiler subpart of app1"); /// { /// DebugMessageControl([LogEverything!]) // changes the control of the ACTIVE debug group. /// ... /// } /// // will reset DebugMessageControl back to disable. /// PopDebugGroup() /// /// // other, uninteresting part of program. /// ... /// </summary> /// <param name="source"></param> /// <param name="id">User Specified id</param> /// <param name="message">Message to </param> public static void PushDebugGroup(DebugSource source, uint id, string message) { Delegates.glPushDebugGroup(source, id, message.Length, message); }
public abstract void DebugMessageInsert([Flow(FlowDirection.In)] DebugSource source, [Flow(FlowDirection.In)] DebugType type, [Flow(FlowDirection.In)] uint id, [Flow(FlowDirection.In)] DebugSeverity severity, [Flow(FlowDirection.In)] uint length, [Flow(FlowDirection.In)] string buf);
private static void openGLDebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { Trace.WriteLine(source == DebugSource.DebugSourceApplication ? $"openGL - {Marshal.PtrToStringAnsi(message, length)}" : $"openGL - {Marshal.PtrToStringAnsi(message, length)}\n\tid:{id} severity:{severity} type:{type} source:{source}\n"); }
/// <summary> /// Insert a new debug message in the debug message log array. /// </summary> /// <param name="source">Source of inserted message.</param> /// <param name="type">type of inserted message.</param> /// <param name="id">id of inserted message. Userid has own range of ids.</param> /// <param name="severity">Severity of inserted message.</param> /// <param name="Text">The text of inserted message.</param> public static void DebugMessageInsertARB(DebugSource source, DebugType type, uint id, DebugSeverity severity, string Text) { Delegates.glDebugMessageInsertARB(source, type, id, severity, Text.Length, Text); }
private static void Debug(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr param) { Console.WriteLine($"{severity} | {source}"); }
public void LoadWatches() { if (WatchFile == null || !File.Exists(WatchFile)) { return; } bool remap = false; foreach (var line in File.ReadAllLines(WatchFile)) { if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("#HASH: ")) { if (ImageFile != null && File.Exists(ImageFile)) { var hash = line.Substring(7).Trim(); remap = VMHash != hash; } continue; } if (line.StartsWith("#")) { continue; } var parts = line.Split('\t'); if (parts.Length < 2) { continue; } var address = ParseHexAddress(parts[0]); var size = parts.Length >= 2 ? Convert.ToUInt32(parts[1]) : 0; var symbol = parts.Length >= 3 ? parts[2] : null; if (symbol != null && remap) { if (symbol.StartsWith("0x") && symbol.Contains('+')) { continue; } address = DebugSource.GetFirstSymbolByName(symbol); if (address == 0) { continue; } } AddWatch(symbol, address, size); } }
private void GLDebugMessageCallbackProc(DebugSource source, DebugType type, uint id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string debug_string = Marshal.PtrToStringAnsi(message, length); Debug.WriteLine($"{source}, {type}, {severity}: {debug_string}"); }
private void DebugCallback(DebugSource src, DebugType typ, int id, DebugSeverity svr, int len, IntPtr msg, IntPtr usrprm) { Console.WriteLine(msg); }
private void GLDebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { Debug.Print($"{(type == DebugType.DebugTypeError ? "GL ERROR!" : "GL callback")} - source={source}, type={type}, severity={severity}, message={Marshal.PtrToStringAnsi(message)}"); }
private void OpenGLDebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string msg = Marshal.PtrToStringAnsi(message, length); Console.WriteLine(msg); }
public static void MessageCallBack(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { LogError("GL CALLBACK:{0} id:{1} type: 0x{2}0, severity = 0x{3}x, message = {4}", source, id, type, severity, message); }
static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { string sev; switch (severity) { case DebugSeverity.DebugSeverityHigh: sev = "\u001b[91m"; break; case DebugSeverity.DebugSeverityMedium: sev = "\u001b[93m"; break; case DebugSeverity.DebugSeverityLow: sev = "\u001b[92m"; break; case DebugSeverity.DebugSeverityNotification: sev = "\u001b[34m"; break; default: sev = "\u001b[92m"; break; } string src; switch (source) { case DebugSource.DebugSourceApi: src = "API"; break; case DebugSource.DebugSourceWindowSystem: src = "window system"; break; case DebugSource.DebugSourceShaderCompiler: src = "shader compiler"; break; case DebugSource.DebugSourceThirdParty: src = "third party"; break; case DebugSource.DebugSourceApplication: src = "app"; break; case DebugSource.DebugSourceOther: default: src = "other"; break; } string type_str; switch (type) { case DebugType.DebugTypeError: type_str = "error"; break; case DebugType.DebugTypeDeprecatedBehavior: type_str = "deprecated behavior"; break; case DebugType.DebugTypeUndefinedBehavior: type_str = "undefined behavior"; break; case DebugType.DebugTypePortability: type_str = "portability"; break; case DebugType.DebugTypeMarker: type_str = "marker"; break; case DebugType.DebugTypePushGroup: type_str = "push group"; break; case DebugType.DebugTypePopGroup: type_str = "pop group"; break; case DebugType.DebugTypePerformance: type_str = "performance"; break; case DebugType.DebugTypeOther: default: type_str = "other"; break; } string messageStr = Marshal.PtrToStringAnsi(message); System.Console.Error.WriteLine($"debug:{sev} type: {type_str}, source: {src}, message: \"{messageStr}\"\u001b[0m"); }
private void GlDebugCallback(DebugSource source, DebugType type, uint id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { var messageStr = Marshal.PtrToStringAnsi(message, length); Logging.Log($"{type}: {id} {messageStr}"); }
private void AddSymbol(ulong ip) { var symbol = DebugSource.GetFirstSymbol(ip); treeView1.Nodes.Add(new CallStackEntry(symbol, ip)); }
protected void OnDebugMessage( DebugSource source, DebugType type, int num1, DebugSeverity severity, int num2, IntPtr ptr1, IntPtr ptr2) { Debug.Log("OpenGL Debug Message: " + source + " " + type); }
/// <summary> /// Retrives a number of messages from message log. /// How many retrives is determined by Math.Min([all arrays]) and availible messages. /// </summary> /// <param name="sources"></param> /// <param name="types"></param> /// <param name="ids"></param> /// <param name="severities"></param> /// <param name="lengths"></param> /// <param name="messageLog">A single preallocated stringbuilder with enough capacity to contain all the messages?</param> /// <returns></returns> public static uint GetDebugMessageLogARB(DebugSource[] sources, DebugType[] types, uint[] ids, DebugSeverity[] severities, int[] lengths, StringBuilder messageLog) { var count = Math.Min(sources.Length, Math.Min(types.Length, Math.Min(ids.Length, Math.Min(severities.Length, lengths.Length)))); return Delegates.glGetDebugMessageLogARB((uint)count, messageLog.Capacity, ref sources[0], ref types[0], ref ids[0], ref severities[0], ref lengths[0], messageLog); }
private static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) { if (id is 131169 or 131185 or 131218 or 131204) { return; } string sourceShort = source switch { DebugSource.DebugSourceApi => "API", DebugSource.DebugSourceApplication => "APPLICATION", DebugSource.DebugSourceOther => "OTHER", DebugSource.DebugSourceShaderCompiler => "SHADER COMPILER", DebugSource.DebugSourceThirdParty => "THIRD PARTY", DebugSource.DebugSourceWindowSystem => "WINDOWS SYSTEM", _ => "NONE" }; string typeShort = type switch { DebugType.DebugTypeDeprecatedBehavior => "DEPRECATED BEHAVIOR", DebugType.DebugTypeError => "ERROR", DebugType.DebugTypeMarker => "MARKER", DebugType.DebugTypeOther => "OTHER", DebugType.DebugTypePerformance => "PERFORMANCE", DebugType.DebugTypePopGroup => "POP GROUP", DebugType.DebugTypePortability => "PORTABILITY", DebugType.DebugTypePushGroup => "PUSH GROUP", DebugType.DebugTypeUndefinedBehavior => "UNDEFINED BEHAVIOR", _ => "NONE" }; (string idResolved, int eventId) = id switch { 0x500 => ("GL_INVALID_ENUM", Events.GlInvalidEnum), 0x501 => ("GL_INVALID_ENUM", Events.GlInvalidEnum), 0x502 => ("GL_INVALID_OPERATION", Events.GlInvalidOperation), 0x503 => ("GL_STACK_OVERFLOW", Events.GlStackOverflow), 0x504 => ("GL_STACK_UNDERFLOW", Events.GlStackUnderflow), 0x505 => ("GL_OUT_OF_MEMORY", Events.GlOutOfMemory), 0x506 => ("GL_INVALID_FRAMEBUFFER_OPERATION", Events.GlInvalidFramebufferOperation), 0x507 => ("GL_CONTEXT_LOST", Events.GlContextLost), _ => ("-", 0) }; switch (severity) { case DebugSeverity.DebugSeverityNotification: case DebugSeverity.DontCare: logger.LogInformation( eventId, LoggingTemplate, sourceShort, typeShort, idResolved, Marshal.PtrToStringAnsi(message, length)); break; case DebugSeverity.DebugSeverityLow: logger.LogWarning( eventId, LoggingTemplate, sourceShort, typeShort, idResolved, Marshal.PtrToStringAnsi(message, length)); break; case DebugSeverity.DebugSeverityMedium: logger.LogError( eventId, LoggingTemplate, sourceShort, typeShort, idResolved, Marshal.PtrToStringAnsi(message, length)); break; case DebugSeverity.DebugSeverityHigh: logger.LogCritical( eventId, LoggingTemplate, sourceShort, typeShort, idResolved, Marshal.PtrToStringAnsi(message, length)); break; default: logger.LogInformation( eventId, LoggingTemplate, sourceShort, typeShort, idResolved, Marshal.PtrToStringAnsi(message, length)); break; } } } }
private static void ReceiveMessage(DebugSource debugSource, DebugType type, int id, DebugSeverity severity, int messageLength, IntPtr messagePtr, IntPtr customObj) { var msg = Marshal.PtrToStringAnsi(messagePtr, messageLength); Debug.WriteLine("Source {0}; Type {1}; id {2}; Severity {3}; msg: '{4}'", debugSource, type, id, severity, msg); }