xref: /qemu/scripts/qemu-gdb.py (revision b9a0de37)
1806c200eSPhilippe Mathieu-Daudé#!/usr/bin/env python3
2806c200eSPhilippe Mathieu-Daudé#
34daa187dSAvi Kivity# GDB debugging support
44daa187dSAvi Kivity#
54daa187dSAvi Kivity# Copyright 2012 Red Hat, Inc. and/or its affiliates
64daa187dSAvi Kivity#
74daa187dSAvi Kivity# Authors:
84daa187dSAvi Kivity#  Avi Kivity <avi@redhat.com>
94daa187dSAvi Kivity#
10328eb60dSPaolo Bonzini# This work is licensed under the terms of the GNU GPL, version 2 or
11328eb60dSPaolo Bonzini# later.  See the COPYING file in the top-level directory.
124daa187dSAvi Kivity
1330c38c90SPeter Maydell# Usage:
1430c38c90SPeter Maydell# At the (gdb) prompt, type "source scripts/qemu-gdb.py".
1530c38c90SPeter Maydell# "help qemu" should then list the supported QEMU debug support commands.
164daa187dSAvi Kivity
174daa187dSAvi Kivityimport gdb
184daa187dSAvi Kivity
1993b1b365SPeter Maydellimport os, sys
204daa187dSAvi Kivity
2193b1b365SPeter Maydell# Annoyingly, gdb doesn't put the directory of scripts onto the
2293b1b365SPeter Maydell# module search path. Do it manually.
2393b1b365SPeter Maydell
2493b1b365SPeter Maydellsys.path.append(os.path.dirname(__file__))
2593b1b365SPeter Maydell
26c24999faSAlex Bennéefrom qemugdb import aio, mtree, coroutine, tcg, timers
279eddd6a4SStefan Hajnoczi
284daa187dSAvi Kivityclass QemuCommand(gdb.Command):
294daa187dSAvi Kivity    '''Prefix for QEMU debug support commands'''
304daa187dSAvi Kivity    def __init__(self):
314daa187dSAvi Kivity        gdb.Command.__init__(self, 'qemu', gdb.COMMAND_DATA,
324daa187dSAvi Kivity                             gdb.COMPLETE_NONE, True)
334daa187dSAvi Kivity
344daa187dSAvi KivityQemuCommand()
35191590f0SPeter Maydellcoroutine.CoroutineCommand()
3693b1b365SPeter Maydellmtree.MtreeCommand()
37c900ef86SDr. David Alan Gilbertaio.HandlersCommand()
38f1cd52d8SAlex Bennéetcg.TCGLockStatusCommand()
39c24999faSAlex Bennéetimers.TimersCommand()
405e3c72d4SPeter Maydell
41a201b0ffSPaolo Bonzinicoroutine.CoroutineSPFunction()
42a201b0ffSPaolo Bonzinicoroutine.CoroutinePCFunction()
43*b9a0de37SMaxim Levitskycoroutine.CoroutineBt()
44a201b0ffSPaolo Bonzini
455e3c72d4SPeter Maydell# Default to silently passing through SIGUSR1, because QEMU sends it
465e3c72d4SPeter Maydell# to itself a lot.
475e3c72d4SPeter Maydellgdb.execute('handle SIGUSR1 pass noprint nostop')
48