summaryrefslogtreecommitdiffstats
path: root/qemu/scripts/qemugdb
diff options
context:
space:
mode:
authorRajithaY <rajithax.yerrumsetty@intel.com>2017-04-25 03:31:15 -0700
committerRajitha Yerrumchetty <rajithax.yerrumsetty@intel.com>2017-05-22 06:48:08 +0000
commitbb756eebdac6fd24e8919e2c43f7d2c8c4091f59 (patch)
treeca11e03542edf2d8f631efeca5e1626d211107e3 /qemu/scripts/qemugdb
parenta14b48d18a9ed03ec191cf16b162206998a895ce (diff)
Adding qemu as a submodule of KVMFORNFV
This Patch includes the changes to add qemu as a submodule to kvmfornfv repo and make use of the updated latest qemu for the execution of all testcase Change-Id: I1280af507a857675c7f81d30c95255635667bdd7 Signed-off-by:RajithaY<rajithax.yerrumsetty@intel.com>
Diffstat (limited to 'qemu/scripts/qemugdb')
-rw-r--r--qemu/scripts/qemugdb/__init__.py28
-rw-r--r--qemu/scripts/qemugdb/aio.py58
-rw-r--r--qemu/scripts/qemugdb/coroutine.py119
-rw-r--r--qemu/scripts/qemugdb/mtree.py82
4 files changed, 0 insertions, 287 deletions
diff --git a/qemu/scripts/qemugdb/__init__.py b/qemu/scripts/qemugdb/__init__.py
deleted file mode 100644
index 969f552b2..000000000
--- a/qemu/scripts/qemugdb/__init__.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-# GDB debugging support
-#
-# Copyright (c) 2015 Linaro Ltd
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see
-# <http://www.gnu.org/licenses/gpl-2.0.html>
-#
-
-# We don't need to do anything in our init file currently.
-
-"""
-Support routines for debugging QEMU under GDB
-"""
-
-__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/qemu/scripts/qemugdb/aio.py b/qemu/scripts/qemugdb/aio.py
deleted file mode 100644
index 2ba00c444..000000000
--- a/qemu/scripts/qemugdb/aio.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/python
-
-# GDB debugging support: aio/iohandler debug
-#
-# Copyright (c) 2015 Red Hat, Inc.
-#
-# Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
-#
-# This work is licensed under the terms of the GNU GPL, version 2 or
-# later. See the COPYING file in the top-level directory.
-#
-
-import gdb
-from qemugdb import coroutine
-
-def isnull(ptr):
- return ptr == gdb.Value(0).cast(ptr.type)
-
-def dump_aiocontext(context, verbose):
- '''Display a dump and backtrace for an aiocontext'''
- cur = context['aio_handlers']['lh_first']
- # Get pointers to functions we're going to process specially
- sym_fd_coroutine_enter = gdb.parse_and_eval('fd_coroutine_enter')
-
- while not isnull(cur):
- entry = cur.dereference()
- gdb.write('----\n%s\n' % entry)
- if verbose and cur['io_read'] == sym_fd_coroutine_enter:
- coptr = (cur['opaque'].cast(gdb.lookup_type('FDYieldUntilData').pointer()))['co']
- coptr = coptr.cast(gdb.lookup_type('CoroutineUContext').pointer())
- coroutine.bt_jmpbuf(coptr['env']['__jmpbuf'])
- cur = cur['node']['le_next'];
-
- gdb.write('----\n')
-
-class HandlersCommand(gdb.Command):
- '''Display aio handlers'''
- def __init__(self):
- gdb.Command.__init__(self, 'qemu handlers', gdb.COMMAND_DATA,
- gdb.COMPLETE_NONE)
-
- def invoke(self, arg, from_tty):
- verbose = False
- argv = gdb.string_to_argv(arg)
-
- if len(argv) > 0 and argv[0] == '--verbose':
- verbose = True
- argv.pop(0)
-
- if len(argv) > 1:
- gdb.write('usage: qemu handlers [--verbose] [handler]\n')
- return
-
- if len(argv) == 1:
- handlers_name = argv[0]
- else:
- handlers_name = 'qemu_aio_context'
- dump_aiocontext(gdb.parse_and_eval(handlers_name), verbose)
diff --git a/qemu/scripts/qemugdb/coroutine.py b/qemu/scripts/qemugdb/coroutine.py
deleted file mode 100644
index ab699794a..000000000
--- a/qemu/scripts/qemugdb/coroutine.py
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/python
-
-# GDB debugging support
-#
-# Copyright 2012 Red Hat, Inc. and/or its affiliates
-#
-# Authors:
-# Avi Kivity <avi@redhat.com>
-#
-# This work is licensed under the terms of the GNU GPL, version 2. See
-# the COPYING file in the top-level directory.
-#
-# Contributions after 2012-01-13 are licensed under the terms of the
-# GNU GPL, version 2 or (at your option) any later version.
-
-import gdb
-
-VOID_PTR = gdb.lookup_type('void').pointer()
-
-def get_fs_base():
- '''Fetch %fs base value using arch_prctl(ARCH_GET_FS). This is
- pthread_self().'''
- # %rsp - 120 is scratch space according to the SystemV ABI
- old = gdb.parse_and_eval('*(uint64_t*)($rsp - 120)')
- gdb.execute('call arch_prctl(0x1003, $rsp - 120)', False, True)
- fs_base = gdb.parse_and_eval('*(uint64_t*)($rsp - 120)')
- gdb.execute('set *(uint64_t*)($rsp - 120) = %s' % old, False, True)
- return fs_base
-
-def pthread_self():
- '''Fetch pthread_self() from the glibc start_thread function.'''
- f = gdb.newest_frame()
- while f.name() != 'start_thread':
- f = f.older()
- if f is None:
- return get_fs_base()
-
- try:
- return f.read_var("arg")
- except ValueError:
- return get_fs_base()
-
-def get_glibc_pointer_guard():
- '''Fetch glibc pointer guard value'''
- fs_base = pthread_self()
- return gdb.parse_and_eval('*(uint64_t*)((uint64_t)%s + 0x30)' % fs_base)
-
-def glibc_ptr_demangle(val, pointer_guard):
- '''Undo effect of glibc's PTR_MANGLE()'''
- return gdb.parse_and_eval('(((uint64_t)%s >> 0x11) | ((uint64_t)%s << (64 - 0x11))) ^ (uint64_t)%s' % (val, val, pointer_guard))
-
-def get_jmpbuf_regs(jmpbuf):
- JB_RBX = 0
- JB_RBP = 1
- JB_R12 = 2
- JB_R13 = 3
- JB_R14 = 4
- JB_R15 = 5
- JB_RSP = 6
- JB_PC = 7
-
- pointer_guard = get_glibc_pointer_guard()
- return {'rbx': jmpbuf[JB_RBX],
- 'rbp': glibc_ptr_demangle(jmpbuf[JB_RBP], pointer_guard),
- 'rsp': glibc_ptr_demangle(jmpbuf[JB_RSP], pointer_guard),
- 'r12': jmpbuf[JB_R12],
- 'r13': jmpbuf[JB_R13],
- 'r14': jmpbuf[JB_R14],
- 'r15': jmpbuf[JB_R15],
- 'rip': glibc_ptr_demangle(jmpbuf[JB_PC], pointer_guard) }
-
-def bt_jmpbuf(jmpbuf):
- '''Backtrace a jmpbuf'''
- regs = get_jmpbuf_regs(jmpbuf)
- old = dict()
-
- for i in regs:
- old[i] = gdb.parse_and_eval('(uint64_t)$%s' % i)
-
- for i in regs:
- gdb.execute('set $%s = %s' % (i, regs[i]))
-
- gdb.execute('bt')
-
- for i in regs:
- gdb.execute('set $%s = %s' % (i, old[i]))
-
-def coroutine_to_jmpbuf(co):
- coroutine_pointer = co.cast(gdb.lookup_type('CoroutineUContext').pointer())
- return coroutine_pointer['env']['__jmpbuf']
-
-
-class CoroutineCommand(gdb.Command):
- '''Display coroutine backtrace'''
- def __init__(self):
- gdb.Command.__init__(self, 'qemu coroutine', gdb.COMMAND_DATA,
- gdb.COMPLETE_NONE)
-
- def invoke(self, arg, from_tty):
- argv = gdb.string_to_argv(arg)
- if len(argv) != 1:
- gdb.write('usage: qemu coroutine <coroutine-pointer>\n')
- return
-
- bt_jmpbuf(coroutine_to_jmpbuf(gdb.parse_and_eval(argv[0])))
-
-class CoroutineSPFunction(gdb.Function):
- def __init__(self):
- gdb.Function.__init__(self, 'qemu_coroutine_sp')
-
- def invoke(self, addr):
- return get_jmpbuf_regs(coroutine_to_jmpbuf(addr))['rsp'].cast(VOID_PTR)
-
-class CoroutinePCFunction(gdb.Function):
- def __init__(self):
- gdb.Function.__init__(self, 'qemu_coroutine_pc')
-
- def invoke(self, addr):
- return get_jmpbuf_regs(coroutine_to_jmpbuf(addr))['rip'].cast(VOID_PTR)
diff --git a/qemu/scripts/qemugdb/mtree.py b/qemu/scripts/qemugdb/mtree.py
deleted file mode 100644
index cc8131c2e..000000000
--- a/qemu/scripts/qemugdb/mtree.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/python
-
-# GDB debugging support
-#
-# Copyright 2012 Red Hat, Inc. and/or its affiliates
-#
-# Authors:
-# Avi Kivity <avi@redhat.com>
-#
-# This work is licensed under the terms of the GNU GPL, version 2. See
-# the COPYING file in the top-level directory.
-#
-# Contributions after 2012-01-13 are licensed under the terms of the
-# GNU GPL, version 2 or (at your option) any later version.
-
-# 'qemu mtree' -- display the memory hierarchy
-
-import gdb
-
-def isnull(ptr):
- return ptr == gdb.Value(0).cast(ptr.type)
-
-def int128(p):
- return int(p['lo']) + (int(p['hi']) << 64)
-
-class MtreeCommand(gdb.Command):
- '''Display the memory tree hierarchy'''
- def __init__(self):
- gdb.Command.__init__(self, 'qemu mtree', gdb.COMMAND_DATA,
- gdb.COMPLETE_NONE)
- self.queue = []
- def invoke(self, arg, from_tty):
- self.seen = set()
- self.queue_root('address_space_memory')
- self.queue_root('address_space_io')
- self.process_queue()
- def queue_root(self, varname):
- ptr = gdb.parse_and_eval(varname)['root']
- self.queue.append(ptr)
- def process_queue(self):
- while self.queue:
- ptr = self.queue.pop(0)
- if int(ptr) in self.seen:
- continue
- self.print_item(ptr)
- def print_item(self, ptr, offset = gdb.Value(0), level = 0):
- self.seen.add(int(ptr))
- addr = ptr['addr']
- addr += offset
- size = int128(ptr['size'])
- alias = ptr['alias']
- klass = ''
- if not isnull(alias):
- klass = ' (alias)'
- elif not isnull(ptr['ops']):
- klass = ' (I/O)'
- elif bool(ptr['ram']):
- klass = ' (RAM)'
- gdb.write('%s%016x-%016x %s%s (@ %s)\n'
- % (' ' * level,
- int(addr),
- int(addr + (size - 1)),
- ptr['name'].string(),
- klass,
- ptr,
- ),
- gdb.STDOUT)
- if not isnull(alias):
- gdb.write('%s alias: %s@%016x (@ %s)\n' %
- (' ' * level,
- alias['name'].string(),
- ptr['alias_offset'],
- alias,
- ),
- gdb.STDOUT)
- self.queue.append(alias)
- subregion = ptr['subregions']['tqh_first']
- level += 1
- while not isnull(subregion):
- self.print_item(subregion, addr, level)
- subregion = subregion['subregions_link']['tqe_next']
-