CefV8StackTrace.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. namespace Xilium.CefGlue
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Runtime.InteropServices;
  7. using Xilium.CefGlue.Interop;
  8. /// <summary>
  9. /// Class representing a V8 stack trace handle. V8 handles can only be accessed
  10. /// from the thread on which they are created. Valid threads for creating a V8
  11. /// handle include the render process main thread (TID_RENDERER) and WebWorker
  12. /// threads. A task runner for posting tasks on the associated thread can be
  13. /// retrieved via the CefV8Context::GetTaskRunner() method.
  14. /// </summary>
  15. public sealed unsafe partial class CefV8StackTrace
  16. {
  17. /// <summary>
  18. /// Returns the stack trace for the currently active context. |frame_limit| is
  19. /// the maximum number of frames that will be captured.
  20. /// </summary>
  21. public static CefV8StackTrace GetCurrent(int frameLimit)
  22. {
  23. return CefV8StackTrace.FromNative(
  24. cef_v8stack_trace_t.get_current(frameLimit)
  25. );
  26. }
  27. /// <summary>
  28. /// Returns true if the underlying handle is valid and it can be accessed on
  29. /// the current thread. Do not call any other methods if this method returns
  30. /// false.
  31. /// </summary>
  32. public bool IsValid
  33. {
  34. get { return cef_v8stack_trace_t.is_valid(_self) != 0; }
  35. }
  36. /// <summary>
  37. /// Returns the number of stack frames.
  38. /// </summary>
  39. public int FrameCount
  40. {
  41. get { return cef_v8stack_trace_t.get_frame_count(_self); }
  42. }
  43. /// <summary>
  44. /// Returns the stack frame at the specified 0-based index.
  45. /// </summary>
  46. public CefV8StackFrame GetFrame(int index)
  47. {
  48. return CefV8StackFrame.FromNative(
  49. cef_v8stack_trace_t.get_frame(_self, index)
  50. );
  51. }
  52. }
  53. }