Wrap debug to include thread information
355029
def thread_debug(self, *args, **kwargs):
        
        if 'module' not in kwargs:
            kwargs['module'] = "Monitor"
        if kwargs['module'] != 'Monitor' and self.do_DEBUG(module='Monitor'):
            self.debug[kwargs['module']] = True
        if not self.do_DEBUG(module=kwargs['module']):
            return
        thread_id = threading.current_thread().name
        key = "[" + thread_id + "] " + kwargs['module']
        if not self.debug.get(key):
            self.debug[key] = True
        kwargs['module'] = key
        self.DEBUG(*args, **kwargs)
1311317
def debug_object(obj: T) -> str:
    """"""
    pairs = []
    for k, v in vars(obj).items():
        pairs.append(u"{}={}".format(k, v))
    return u", ".join(pairs)
1058840
def print_debug(self, msg):
        """"""
        assert isinstance(msg, bytes)
        state = STATE_NAMES[self.state].encode()
        console_output(b'[dbg] ' + self.display_name.encode() + b'[' + state +
                       b']: ' + msg + b'\n')
857207
def enable_console_debug_logging():  # pragma no cover (Function useful only outside test environment)
    

    logger = logging.getLogger("github")
    logger.setLevel(logging.DEBUG)
    logger.addHandler(logging.StreamHandler())
1276222
def debug_file(self):
        """"""
        self.switch_to_plugin()
        current_editor = self.get_current_editor()
        if current_editor is not None:
            current_editor.sig_debug_start.emit()
        self.run_file(debug=True)
758599
def debugInfo(self):
        
        return ("enabled = {}, min = {}, max = {}, step = {}, specVal = {}"
                .format(self.enabled, self.minValue, self.maxValue, self.stepSize, self.specialValueText))
1278547
def _line_tracer(self, frame, exc_info=False):
        """"""
        # next logging statement commented for performance
        _logger.f_debug("user_line() with " 
                        "threadName=%s, frame=%s, frame.f_code=%s, self.mainpyfile=%s,"
                        "self.should_break_here()=%s, self.should_stop_here()=%s\n",
                         threading.currentThread().name,
                         hex(id(frame)),
                         frame.f_code,
                         self.mainpyfile,
                         self.should_break_here(frame),
                         self.should_stop_here(frame))

        # next lines allow to focus debugging on only one thread
        if self.debugged_thread_ident is None:
            self.debugged_thread_ident = threading.currentThread().ident
            self.debugged_thread_name = threading.currentThread().name
        else:
            if threading.currentThread().ident != self.debugged_thread_ident:
                return

        # Acquire Breakpoint Lock before sending break command to remote client
        self._active_breakpoint_lock.acquire()
        self.status = 'stopped'
        frames = self.dump_frames(frame)
        exception=None
        warning_messages = []
        if exc_info:
            exception = {
                'type': IKPdbRepr(exc_info[1]),
                'info': exc_info[1].args[0]
            }

        if self.stop_at_first_statement:
            warning_messages = ["IKP3db stopped so that you can setup some "
                                "breakpoints before 'Resuming' execution."]
            self.stop_at_first_statement = False

        remote_client.send('programBreak', 
                           frames=frames,
                           threads= self.get_threads(),
                           result={'executionStatus': 'stopped'},  #=self.status
                           warning_messages=warning_messages,
                           exception=exception)
                           
        # Enter a loop to process commands sent by client
        while True:
            command = self._command_q.get()

            if command['cmd'] == 'resume':
                self.setup_resume()
                break
            
            elif command['cmd'] == 'stepOver':
                self.setup_step_over(frame)
                break
            
            elif command['cmd'] == 'stepInto':
                self.setup_step_into(frame)
                break
            
            elif command['cmd'] == 'stepOut':
                self.setup_step_out(frame)
                break
            
            elif command['cmd'] == 'evaluate':
                value, result_type = self.evaluate(command['frame'], 
                                                   command['expression'], 
                                                   command['global'], 
                                                   disable_break=command['disableBreak'])
                remote_client.reply(command['obj'], {'value': value, 'type': result_type})

            elif command['cmd'] == 'getProperties':
                error_messages = []
                if command.get('id', False):
                    po_value = ctypes.cast(command['id'], ctypes.py_object).value
                    result={'properties': self.extract_object_properties(po_value) or []}
                    command_exec_status = 'ok'
                else:
                    result={'properties': self.extract_object_properties(None) or []}
                    command_exec_status = 'ok'
                    
                _logger.e_debug("    => %s", result)
                remote_client.reply(command['obj'], result, 
                                    command_exec_status=command_exec_status,
                                    error_messages=error_messages)

            elif command['cmd'] == 'setVariable':
                error_messages = []
                result = {}
                command_exec_status = 'ok'
                # TODO: Rework to use id now that we are in right thread context
                err_message = self.let_variable(command['frame'], 
                                                command['name'], 
                                                command['value'])
                if err_message:
                    command_exec_status = 'error'
                    msg = "setVariable(%s=%s) failed with error: %s" % (command['name'], 
                                                                        command['value'],
                                                                        err_message)
                    error_messages = [msg]
                    _logger.e_error(msg)
                remote_client.reply(command['obj'], 
                                    result,
                                    command_exec_status=command_exec_status,
                                    error_messages=error_messages)
                                    
            elif command['cmd'] == '_InternalQuit':
                _logger.x_critical("Exiting tracer upon reception of _Internal"
                                   "Quit  command")
                raise IKPdbQuit()                                    

            else:
                _logger.x_critical("Unknown command: %s received by _line_tracer()" % resume_command)
                raise IKPdbQuit()

        self.status = 'running'
        self._active_breakpoint_lock.release()
        return
434484
def debug_string(self):
        """"""

        if self._resources_initialized:
            status = "Resources requested: {}/{} CPUs, {}/{} GPUs".format(
                self._committed_resources.cpu, self._avail_resources.cpu,
                self._committed_resources.gpu, self._avail_resources.gpu)
            customs = ", ".join([
                "{}/{} {}".format(
                    self._committed_resources.get_res_total(name),
                    self._avail_resources.get_res_total(name), name)
                for name in self._avail_resources.custom_resources
            ])
            if customs:
                status += " ({})".format(customs)
            return status
        else:
            return "Resources requested: ?"
579331
function wrapDebug (rule, id, atok) {
  rule._test = rule.test
  return function (buf, offset) {
    atok.emit_debug( 'SubRule', id, arguments )
    return rule._test(buf, offset)
  }
}
1021121
def _debug_log(self, msg):
        """"""
        if not self.debug:
            return
        sys.stderr.write('{}\n'.format(msg))
87727
def debug_flag():
    """"""
    logging.basicConfig(format=consts.LOGGING_FORMAT)

    parser = argparse.ArgumentParser(description=debug_flag.__doc__)
    add_debug(parser)
    args, _extra_args = parser.parse_known_args()

    package, *_ = __package__.split('.')
    logging.getLogger(package).setLevel(args.debug)
560788
def writeWorkerDebug(debugStats, queueLength, path_suffix=""):
    """"""
    createDirectory(path_suffix)
    origin_prefix = "origin-" if scoop.IS_ORIGIN else ""
    statsFilename = os.path.join(
        getDebugDirectory(),
        path_suffix,
        "{1}worker-{0}-STATS".format(getDebugIdentifier(), origin_prefix)
    )
    lengthFilename = os.path.join(
        getDebugDirectory(),
        path_suffix,
        "{1}worker-{0}-QUEUE".format(getDebugIdentifier(), origin_prefix)
    )
    with open(statsFilename, 'wb') as f:
        pickle.dump(debugStats, f)
    with open(lengthFilename, 'wb') as f:
        pickle.dump(queueLength, f)
116063
def add_debug(parser):
    """"""
    parser.add_argument(
        '-d', '--debug', action='store_const', const=logging.DEBUG, default=logging.INFO, help='Set DEBUG output')
914644
def set_debug_mode(debug=True):
    
    global debug_mode
    global _setting_keep_wirevector_call_stack
    global _setting_slower_but_more_descriptive_tmps
    debug_mode = debug
    _setting_keep_wirevector_call_stack = debug
    _setting_slower_but_more_descriptive_tmps = debug
608623
private static function debugEnd()
    {
        // SWATDB_DEBUG is legacy, use SwatDB::setDebug() instead
        if (defined('SWATDB_DEBUG') || self::$debug) {
            self::$debug_wrapper_depth--;

            if (self::$debug_wrapper_depth === 0) {
                $count = 0;
                $depth = 0;

                foreach (self::$debug_info as $info) {
                    if ($info['depth'] < $depth) {
                        echo str_repeat(
                            '</blockquote>',
                            $depth - $info['depth']
                        );
                    } elseif ($info['depth'] > $depth) {
                        echo '<blockquote class="swat-db-debug">';
                    } elseif ($info['depth'] === 0) {
                        echo '<hr />';
                    }

                    echo "\n" . $info['message'] . "\n";

                    $locale = SwatI18NLocale::get();
                    printf(
                        "<p>Query #%s</p>\n",
                        $locale->formatNumber($info['count'])
                    );

                    if (count(self::$debug_info) > $count + 1) {
                        $time = self::$debug_info[$count + 1]['time'];
                    } else {
                        $time = microtime(true) * 1000;
                    }

                    $ms = $time - $info['time'];

                    printf(
                        "<p><strong>%s ms</strong></p>\n",
                        $locale->formatNumber($ms, 3)
                    );

                    if ($info['depth'] === 0 && count(self::$debug_info) > 1) {
                        $ms =
                            microtime(true) * 1000 -
                            self::$debug_info[0]['time'];

                        echo '<p><strong>';

                        printf(
                            Swat::_(
                                'Total time: %s ms (includes ' .
                                    'queries within the wrapper)'
                            ),
                            $locale->formatNumber($ms, 3)
                        );

                        echo '</strong></p>';
                    }

                    $count++;
                    $depth = $info['depth'];
                }

                if ($depth > 0) {
                    echo str_repeat('</blockquote>', $depth);
                }

                // reset debug info for the next query
                self::$debug_info = array();
            }
        }
    }
347361
def handle_debug_break(self, call_id, payload):
        """"""
        line = payload['line']
        config = self.launcher.config  # TODO: make an attribute of client
        path = os.path.relpath(payload['file'], config['root-dir'])

        self.editor.raw_message(feedback['notify_break'].format(line, path))
        self.debug_thread_id = payload["threadId"]
861842
def _debug(self, out, print_prefix=True):
        
        if self.debug:
            if print_prefix:
                pre = self.__class__.__name__
                if hasattr(self, 'debug_prefix'):
                    pre = getattr(self, 'debug_prefix')
                sys.stderr.write("%s: " % pre)
            sys.stderr.write(out)