Ejemplo n.º 1
0
    def handle_logbuf(self, args):

        log_buf_len = get_value("log_buf_len")
        log_buf = get_value("log_buf")

        if log_buf_len and log_buf:
            if args.d:
                raise LogInvalidOption("Unstructured logs don't offer key/value pair support")
            print self.filter_unstructured_log(log_buf.string(), args)
Ejemplo n.º 2
0
    def handle_logbuf(self, args):

        log_buf_len = get_value("log_buf_len")
        log_buf = get_value("log_buf")

        if log_buf_len and log_buf:
            if (args.d):
                raise LogInvalidOption(
                    "Unstructured logs don't offer key/value pair support")
            print self.filter_unstructured_log(log_buf.string(), args)
Ejemplo n.º 3
0
    def __init__(self):
        self.high_memory = get_value('high_memory')
        print self.high_memory

        self.total_pages = arch.arch.base_to_page(arch.arch.virt_to_phys(self.high_memory.cast(unsigned_long)))
        self.min_page_count = self.total_pages

        num_physpages = get_value('num_physpages')
        if num_physpages:
            self.num_physpages = num_physpages.cast(unsigned_long)
            if num_physpages < self.total_pages:
                self.min_page_count = self.num_physpages
        else:
            self.num_physpages = None

        print "%u" % self.total_pages
Ejemplo n.º 4
0
    def get_log_msgs(self, dict_needed=False):
        first_idx = get_value('log_first_idx')
        clear_seq = get_value('clear_seq')
        first_seq = get_value('log_first_seq')
        next_seq = get_value('log_next_seq')
        logbuf = get_value("log_buf")

        if clear_seq < first_seq:
            clear_seq = first_seq

        seq = clear_seq
        idx = first_idx
        while seq < next_seq:
            msg = self.log_from_idx(logbuf, idx, dict_needed)
            seq += 1
            idx = msg['next']
            yield (msg)
Ejemplo n.º 5
0
    def __init__(self):
        self.high_memory = get_value('high_memory')
        print self.high_memory

        self.total_pages = arch.arch.base_to_page(
            arch.arch.virt_to_phys(self.high_memory.cast(unsigned_long)))
        self.min_page_count = self.total_pages

        num_physpages = get_value('num_physpages')
        if num_physpages:
            self.num_physpages = num_physpages.cast(unsigned_long)
            if num_physpages < self.total_pages:
                self.min_page_count = self.num_physpages
        else:
            self.num_physpages = None

        print "%u" % self.total_pages
Ejemplo n.º 6
0
    def get_log_msgs(self, dict_needed=False):
        first_idx = get_value("log_first_idx")
        clear_seq = get_value("clear_seq")
        first_seq = get_value("log_first_seq")
        next_seq = get_value("log_next_seq")
        logbuf = get_value("log_buf")

        if clear_seq < first_seq:
            clear_seq = first_seq

        seq = clear_seq
        idx = first_idx
        while seq < next_seq:
            msg = self.log_from_idx(logbuf, idx, dict_needed)
            seq += 1
            idx = msg["next"]
            yield (msg)
Ejemplo n.º 7
0
def initialize_task_state():
    global TASK_RUNNING
    global TASK_INTERRUPTIBLE
    global TASK_UNINTERRUPTIBLE
    global TASK_ZOMBIE
    global TASK_STOPPED
    global TASK_SWAPPING
    global TASK_EXCLUSIVE
    global TASK_DEAD

    task_stat = get_value('task_state_array')
    if not task_stat:
        self.set_default_task_state()
        return

    count = task_stat.type.sizeof / charp.sizeof

    TASK_DEAD = 0
    TASK_TRACING_STOPPED = 0
    for i in range(0, count):
        state = task_stat[i].string()
        if '(running)' in state:
            TASK_RUNNING = 1 << i
        elif '(sleeping)' in state:
            TASK_INTERRUPTIBLE = 1 << i
        elif '(disk sleep)' in state:
            TASK_UNINTERRUPTIBLE = 1 << i
        elif '(stopped)' in state:
            TASK_STOPPED = 1 << i
        elif '(zombie)' in state:
            TASK_ZOMBIE = 1 << i
        elif '(dead)' in state:
            TASK_DEAD |= 1 << i
        elif '(swapping)' in state:
            TASK_SWAPPING = 1 << i
        elif '(tracing stop)' in state:
            TASK_TRACING_STOPPED |= 1 << i
        elif '(wakekill)' in state:
            TASK_WAKEKILL = 1 << i
        elif '(waking)' in state:
            TASK_WAKING = 1 << i

    version = crash.cache.this_kernel_version()

    # NONINTERACTIVE didn't make it into task_state_array
    if version >= '2.6.16' and version < '2.6.24':
        TASK_NONINTERACTIVE = 64
    if version >= '2.6.32':
        if bin(TASK_DEAD).count('1') == 1:
            bit = math.log(TASK_DEAD, 2)
            TASK_DEAD |= 1 << (bit + 1)
            TASK_WAKEKILL |= 1 << (bit + 2)
            TASK_WAKING |= 1 << (bit + 3)

    if TASK_RUNNING is None or TASK_INTERRUPTIBLE is None or \
       TASK_UNINTERRUPTIBLE is None or TASK_ZOMBIE is None or \
       TASK_STOPPED is None:
        raise TaskStateException("Couldn't initialize valid task states")
Ejemplo n.º 8
0
def initialize_task_state():
    global TASK_RUNNING
    global TASK_INTERRUPTIBLE
    global TASK_UNINTERRUPTIBLE
    global TASK_ZOMBIE
    global TASK_STOPPED
    global TASK_SWAPPING
    global TASK_EXCLUSIVE
    global TASK_DEAD
   
    task_stat = get_value('task_state_array')
    if not task_stat:
        self.set_default_task_state()
        return

    count = task_stat.type.sizeof / charp.sizeof

    TASK_DEAD = 0
    TASK_TRACING_STOPPED = 0
    for i in range(0, count):
        state = task_stat[i].string()
        if '(running)' in state:
            TASK_RUNNING = 1 << i
        elif '(sleeping)' in state:
            TASK_INTERRUPTIBLE = 1 << i
        elif '(disk sleep)' in state:
            TASK_UNINTERRUPTIBLE = 1 << i
        elif '(stopped)' in state:
            TASK_STOPPED = 1 << i
        elif '(zombie)' in state:
            TASK_ZOMBIE = 1 << i
        elif '(dead)' in state:
            TASK_DEAD |= 1 << i
        elif '(swapping)' in state:
            TASK_SWAPPING = 1 << i
        elif '(tracing stop)' in state:
            TASK_TRACING_STOPPED |= 1 << i
        elif '(wakekill)' in state:
            TASK_WAKEKILL = 1 << i
        elif '(waking)' in state:
            TASK_WAKING = 1 << i

    version = crash.cache.this_kernel_version()

    # NONINTERACTIVE didn't make it into task_state_array
    if version >= '2.6.16' and version < '2.6.24':
        TASK_NONINTERACTIVE = 64
    if version >= '2.6.32':
        if bin(TASK_DEAD).count('1') == 1:
            bit = math.log(TASK_DEAD, 2)
            TASK_DEAD |= 1 << (bit + 1)
            TASK_WAKEKILL |= 1 << (bit + 2)
            TASK_WAKING |= 1 << (bit + 3)

    if TASK_RUNNING is None or TASK_INTERRUPTIBLE is None or \
       TASK_UNINTERRUPTIBLE is None or TASK_ZOMBIE is None or \
       TASK_STOPPED is None:
        raise TaskStateException("Couldn't initialize valid task states")
Ejemplo n.º 9
0
    def handle_structured_log(self, args):
        log_first_idx = get_value("log_first_idx")
        log_next_idx = get_value("log_next_idx")
        log_buf = get_value("__log_buf")

        if log_first_idx == None or log_next_idx == None:
            raise LogTypeException("not structured log")

        for msg in self.get_log_msgs(args.d):
            timestamp = ""
            if not args.t:
                timestamp = "[%5lu.%06lu] " % (msg["timestamp"] / 1000000000, (msg["timestamp"] % 1000000000) / 1000)
            level = ""
            if args.m:
                level = "<%d>" % msg["level"]

            for line in msg["text"].split("\n"):
                print "%s%s%s" % (level, timestamp, line)

            for d in msg["dict"]:
                print "%15s%s" % ("", d.encode("string_escape"))
Ejemplo n.º 10
0
    def handle_structured_log(self, args):
        log_first_idx = get_value("log_first_idx")
        log_next_idx = get_value("log_next_idx")
        log_buf = get_value("__log_buf")

        if log_first_idx == None or log_next_idx == None:
            raise LogTypeException("not structured log")

        for msg in self.get_log_msgs(args.d):
            timestamp = ""
            if not args.t:
                timestamp = "[%5lu.%06lu] " % \
                            (msg['timestamp'] / 1000000000,
                            (msg['timestamp'] % 1000000000) / 1000)
            level = ""
            if args.m:
                level = "<%d>" % msg['level']

            for line in msg['text'].split('\n'):
                print "%s%s%s" % (level, timestamp, line)

            for d in msg['dict']:
                print "%15s%s" % ("", d.encode('string_escape'))
Ejemplo n.º 11
0
TASK_INTERRUPTIBLE = None
TASK_UNINTERRUPTIBLE = None
TASK_ZOMBIE = None
TASK_STOPPED = None
TASK_SWAPPING = None
TASK_EXCLUSIVE = None
TASK_DEAD = None

TASK_SWAPPING = None
TASK_TRACING_STOPPED = None
TASK_WAKEKILL = None
TASK_WAKING = None

PF_EXITING = 0x4

MM_FILEPAGES = get_value('MM_FILEPAGES', domain=gdb.SYMBOL_VAR_DOMAIN)
MM_ANONPAGES = get_value('MM_ANONPAGES', domain=gdb.SYMBOL_VAR_DOMAIN)

mm_struct_fields = gdb.lookup_type('struct mm_struct').keys()
task_struct_fields = task_type.keys()
init_mm = get_value('init_mm')

if 'eip' in thread_type.keys():
    ip_member = 'eip'
elif 'ip' in thread_type.keys():
    ip_member = 'ip'

if 'esp' in thread_type.keys():
    sp_member = 'eip'
elif 'sp' in thread_type.keys():
    sp_member = 'ip'
Ejemplo n.º 12
0
TASK_INTERRUPTIBLE = None
TASK_UNINTERRUPTIBLE = None
TASK_ZOMBIE = None
TASK_STOPPED = None
TASK_SWAPPING = None
TASK_EXCLUSIVE = None
TASK_DEAD = None

TASK_SWAPPING = None
TASK_TRACING_STOPPED = None
TASK_WAKEKILL = None
TASK_WAKING = None

PF_EXITING = 0x4

MM_FILEPAGES = get_value('MM_FILEPAGES', domain=gdb.SYMBOL_VAR_DOMAIN)
MM_ANONPAGES = get_value('MM_ANONPAGES', domain=gdb.SYMBOL_VAR_DOMAIN)

mm_struct_fields = gdb.lookup_type('struct mm_struct').keys()
task_struct_fields = task_type.keys()
init_mm = get_value('init_mm')

if 'eip' in thread_type.keys():
    ip_member = 'eip'
elif 'ip' in thread_type.keys():
    ip_member = 'ip'

if 'esp' in thread_type.keys():
    sp_member = 'eip'
elif 'sp' in thread_type.keys():
    sp_member = 'ip'