Debugger.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // System.Diagnostics.Debugger.cs
  3. //
  4. // Author:
  5. // John R. Hicks ([email protected])
  6. //
  7. // (C) 2001
  8. //
  9. //
  10. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System;
  32. using System.Runtime.CompilerServices;
  33. using System.Runtime.InteropServices;
  34. namespace System.Diagnostics
  35. {
  36. /// <summary>
  37. /// Enables communication with a debugger.
  38. /// </summary>
  39. [ComVisible (true)]
  40. [MonoTODO ("The Debugger class is not functional")]
  41. public sealed class Debugger
  42. {
  43. /// <summary>
  44. /// Represents the default category of a message with a constant.
  45. /// </summary>
  46. public static readonly string DefaultCategory = "";
  47. /// <summary>
  48. /// Returns a Boolean indicating whether a debugger is attached to a process.
  49. /// </summary>
  50. /// <value>
  51. /// true if debugger is attached; otherwise, false.
  52. /// </value>
  53. public static bool IsAttached
  54. {
  55. get
  56. {
  57. return IsAttached_internal ();
  58. }
  59. }
  60. [MethodImplAttribute (MethodImplOptions.InternalCall)]
  61. private extern static bool IsAttached_internal ();
  62. /// <summary>
  63. /// Causes a breakpoint to be signaled to an attached debugger.
  64. /// </summary>
  65. public static void Break()
  66. {
  67. // The JIT inserts a breakpoint on the caller.
  68. }
  69. /// <summary>
  70. /// Checks to see if logging is enabled by an attached debugger.
  71. /// </summary>
  72. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  73. public static extern bool IsLogging();
  74. /// <summary>
  75. /// Launches and attaches a debugger to the process.
  76. /// </summary>
  77. [MonoTODO ("Not implemented")]
  78. public static bool Launch()
  79. {
  80. throw new NotImplementedException();
  81. }
  82. /// <summary>
  83. /// Posts a message for the attached debugger.
  84. /// </summary>
  85. /// <param name="level">
  86. /// A description of the importance of this message
  87. /// </param>
  88. /// <param name="category">
  89. /// A string describing the category of this message.
  90. /// </param>
  91. /// <param name="message">
  92. /// A string representing the message to show.
  93. /// </param>
  94. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  95. public static extern void Log(int level, string category, string message);
  96. public static void NotifyOfCrossThreadDependency ()
  97. {
  98. }
  99. [ObsoleteAttribute("Call the static methods directly on this type", true)]
  100. public Debugger()
  101. {
  102. }
  103. #if MONODROID
  104. [MethodImplAttribute (MethodImplOptions.InternalCall)]
  105. private extern static void Mono_UnhandledException_internal (Exception ex);
  106. internal static void Mono_UnhandledException (Exception ex)
  107. {
  108. Mono_UnhandledException_internal (ex);
  109. }
  110. #endif
  111. }
  112. }