src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java

Print this page




  47      * General debugging.
  48      */
  49     public static final int DBG_GEN = 0b0000001;
  50 
  51     /**
  52      * File manager debuging.
  53      */
  54     public static final int DBG_FMGR = 0b0000010;
  55 
  56     /**
  57      * Completion analysis debugging.
  58      */
  59     public static final int DBG_COMPA = 0b0000100;
  60 
  61     /**
  62      * Dependency debugging.
  63      */
  64     public static final int DBG_DEP = 0b0001000;
  65 
  66     /**





  67      * Event debugging.
  68      */
  69     public static final int DBG_EVNT = 0b0010000;
  70 
  71     private static Map<JShell, Integer> debugMap = null;
  72 
  73     /**
  74      * Sets which debug flags are enabled for a given JShell instance. The flags
  75      * are or'ed bits as defined in {@code DBG_*}.
  76      *
  77      * @param state the JShell instance
  78      * @param flags the or'ed debug bits
  79      */
  80     public static void setDebugFlags(JShell state, int flags) {
  81         if (debugMap == null) {
  82             debugMap = new HashMap<>();
  83         }
  84         debugMap.put(state, flags);
  85     }
  86 


 108      * @param state the current JShell instance
 109      * @param err the {@code PrintStream} to report on
 110      * @param flags {@code DBG_*} flag bits to check
 111      * @param format format string for the output
 112      * @param args args for the format string
 113      */
 114     public static void debug(JShell state, PrintStream err, int flags, String format, Object... args) {
 115         if (isDebugEnabled(state, flags)) {
 116             err.printf(format, args);
 117         }
 118     }
 119 
 120     /**
 121      * Displays a fatal exception as debug info.
 122      *
 123      * @param state the current JShell instance
 124      * @param err the {@code PrintStream} to report on
 125      * @param ex the fatal Exception
 126      * @param where additional context
 127      */
 128     public static void debug(JShell state, PrintStream err, Exception ex, String where) {
 129         if (isDebugEnabled(state, 0xFFFFFFFF)) {
 130             err.printf("Fatal error: %s: %s\n", where, ex.getMessage());
 131             ex.printStackTrace(err);
 132         }
 133     }
 134 }


  47      * General debugging.
  48      */
  49     public static final int DBG_GEN = 0b0000001;
  50 
  51     /**
  52      * File manager debuging.
  53      */
  54     public static final int DBG_FMGR = 0b0000010;
  55 
  56     /**
  57      * Completion analysis debugging.
  58      */
  59     public static final int DBG_COMPA = 0b0000100;
  60 
  61     /**
  62      * Dependency debugging.
  63      */
  64     public static final int DBG_DEP = 0b0001000;
  65 
  66     /**
  67      * Execution control channel debugging.
  68      */
  69     public static final int DBG_EC  = 0b0010000;
  70 
  71     /**
  72      * Event debugging.
  73      */
  74     public static final int DBG_EVNT = 0b0010000;
  75 
  76     private static Map<JShell, Integer> debugMap = null;
  77 
  78     /**
  79      * Sets which debug flags are enabled for a given JShell instance. The flags
  80      * are or'ed bits as defined in {@code DBG_*}.
  81      *
  82      * @param state the JShell instance
  83      * @param flags the or'ed debug bits
  84      */
  85     public static void setDebugFlags(JShell state, int flags) {
  86         if (debugMap == null) {
  87             debugMap = new HashMap<>();
  88         }
  89         debugMap.put(state, flags);
  90     }
  91 


 113      * @param state the current JShell instance
 114      * @param err the {@code PrintStream} to report on
 115      * @param flags {@code DBG_*} flag bits to check
 116      * @param format format string for the output
 117      * @param args args for the format string
 118      */
 119     public static void debug(JShell state, PrintStream err, int flags, String format, Object... args) {
 120         if (isDebugEnabled(state, flags)) {
 121             err.printf(format, args);
 122         }
 123     }
 124 
 125     /**
 126      * Displays a fatal exception as debug info.
 127      *
 128      * @param state the current JShell instance
 129      * @param err the {@code PrintStream} to report on
 130      * @param ex the fatal Exception
 131      * @param where additional context
 132      */
 133     public static void debug(JShell state, PrintStream err, Throwable ex, String where) {
 134         if (isDebugEnabled(state, 0xFFFFFFFF)) {
 135             err.printf("Fatal error: %s: %s\n", where, ex.getMessage());
 136             ex.printStackTrace(err);
 137         }
 138     }
 139 }