<commit_before>
import binascii

cdbLoaded = False
lldbLoaded = False
gdbLoaded = False

def warn(message):
    print "XXX: %s\n" % message.encode("latin1")


def showException(msg, exType, exValue, exTraceback):
    warn("**** CAUGHT EXCEPTION: %s ****" % msg)
    try:
        import traceback
        for line in traceback.format_exception(exType, exValue, exTraceback):
            warn("%s" % line)
    except:
        pass

try:
    #import cdb_bridge
    cdbLoaded = True

except:
    pass

try:
    #import lldb_bridge
    lldbLoaded = True

except:
    pass


try:
    import gdb
    gdbLoaded = True

    #######################################################################
    #
    # Sanitize environment
    #
    #######################################################################

    try:
        gdb.execute("set auto-load-scripts no")
    except:
        pass


    #######################################################################
    #
    # Infrastructure
    #
    #######################################################################

    def savePrint(output):
        try:
            print(output)
        except:
            out = ""
            for c in output:
                cc = ord(c)
                if cc > 127:
                    out += "\\\\%d" % cc
                elif cc < 0:
                    out += "\\\\%d" % (cc + 256)
                else:
                    out += c
            print(out)

    def registerCommand(name, func):

        class Command(gdb.Command):
            def __init__(self):
                super(Command, self).__init__(name, gdb.COMMAND_OBSCURE)
            def invoke(self, args, from_tty):
                savePrint(func(args))
<commit_msg>Debugger: allow automatic script loading<commit_after>
import binascii

cdbLoaded = False
lldbLoaded = False
gdbLoaded = False

def warn(message):
    print "XXX: %s\n" % message.encode("latin1")


def showException(msg, exType, exValue, exTraceback):
    warn("**** CAUGHT EXCEPTION: %s ****" % msg)
    try:
        import traceback
        for line in traceback.format_exception(exType, exValue, exTraceback):
            warn("%s" % line)
    except:
        pass

try:
    #import cdb_bridge
    cdbLoaded = True

except:
    pass

try:
    #import lldb_bridge
    lldbLoaded = True

except:
    pass


try:
    import gdb
    gdbLoaded = True

    #######################################################################
    #
    # Sanitize environment
    #
    #######################################################################

    #try:
    #    gdb.execute("set auto-load-scripts no")
    #except:
    #    pass


    #######################################################################
    #
    # Infrastructure
    #
    #######################################################################

    def savePrint(output):
        try:
            print(output)
        except:
            out = ""
            for c in output:
                cc = ord(c)
                if cc > 127:
                    out += "\\\\%d" % cc
                elif cc < 0:
                    out += "\\\\%d" % (cc + 256)
                else:
                    out += c
            print(out)

    def registerCommand(name, func):

        class Command(gdb.Command):
            def __init__(self):
                super(Command, self).__init__(name, gdb.COMMAND_OBSCURE)
            def invoke(self, args, from_tty):
                savePrint(func(args))

{'fraction_non_alphanumeric': 0.25221872316060695, 'fraction_numerical': 0.004580589750930432, 'mean_word_length': 1.9837745516652434, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4310984', 'n_tokens_mistral': 1000, 'n_tokens_neox': 926, 'n_words': 224}