Philippe Mathieu-Daudé | 806c200 | 2020-05-12 12:32:34 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
Avi Kivity | 4daa187 | 2012-03-18 16:48:44 +0200 | [diff] [blame] | 3 | # GDB debugging support |
| 4 | # |
| 5 | # Copyright 2012 Red Hat, Inc. and/or its affiliates |
| 6 | # |
| 7 | # Authors: |
| 8 | # Avi Kivity <avi@redhat.com> |
| 9 | # |
Paolo Bonzini | 328eb60 | 2019-03-11 13:13:53 +0100 | [diff] [blame] | 10 | # This work is licensed under the terms of the GNU GPL, version 2 or |
| 11 | # later. See the COPYING file in the top-level directory. |
Avi Kivity | 4daa187 | 2012-03-18 16:48:44 +0200 | [diff] [blame] | 12 | |
Peter Maydell | 30c38c9 | 2015-08-14 18:46:32 +0100 | [diff] [blame] | 13 | # Usage: |
| 14 | # At the (gdb) prompt, type "source scripts/qemu-gdb.py". |
| 15 | # "help qemu" should then list the supported QEMU debug support commands. |
Avi Kivity | 4daa187 | 2012-03-18 16:48:44 +0200 | [diff] [blame] | 16 | |
| 17 | import gdb |
| 18 | |
Peter Maydell | 93b1b36 | 2015-08-14 18:46:29 +0100 | [diff] [blame] | 19 | import os, sys |
Avi Kivity | 4daa187 | 2012-03-18 16:48:44 +0200 | [diff] [blame] | 20 | |
Peter Maydell | 93b1b36 | 2015-08-14 18:46:29 +0100 | [diff] [blame] | 21 | # Annoyingly, gdb doesn't put the directory of scripts onto the |
| 22 | # module search path. Do it manually. |
| 23 | |
| 24 | sys.path.append(os.path.dirname(__file__)) |
| 25 | |
Alex Bennée | c24999f | 2018-01-11 11:27:33 +0300 | [diff] [blame] | 26 | from qemugdb import aio, mtree, coroutine, tcg, timers |
Stefan Hajnoczi | 9eddd6a | 2015-03-26 22:42:34 +0000 | [diff] [blame] | 27 | |
Avi Kivity | 4daa187 | 2012-03-18 16:48:44 +0200 | [diff] [blame] | 28 | class QemuCommand(gdb.Command): |
| 29 | '''Prefix for QEMU debug support commands''' |
| 30 | def __init__(self): |
| 31 | gdb.Command.__init__(self, 'qemu', gdb.COMMAND_DATA, |
| 32 | gdb.COMPLETE_NONE, True) |
| 33 | |
Avi Kivity | 4daa187 | 2012-03-18 16:48:44 +0200 | [diff] [blame] | 34 | QemuCommand() |
Peter Maydell | 191590f | 2015-08-14 18:46:30 +0100 | [diff] [blame] | 35 | coroutine.CoroutineCommand() |
Peter Maydell | 93b1b36 | 2015-08-14 18:46:29 +0100 | [diff] [blame] | 36 | mtree.MtreeCommand() |
Dr. David Alan Gilbert | c900ef8 | 2015-10-27 13:09:45 +0000 | [diff] [blame] | 37 | aio.HandlersCommand() |
Alex Bennée | f1cd52d | 2018-01-11 11:27:11 +0300 | [diff] [blame] | 38 | tcg.TCGLockStatusCommand() |
Alex Bennée | c24999f | 2018-01-11 11:27:33 +0300 | [diff] [blame] | 39 | timers.TimersCommand() |
Peter Maydell | 5e3c72d | 2015-08-14 18:46:31 +0100 | [diff] [blame] | 40 | |
Paolo Bonzini | a201b0f | 2015-10-12 10:02:54 +0200 | [diff] [blame] | 41 | coroutine.CoroutineSPFunction() |
| 42 | coroutine.CoroutinePCFunction() |
Maxim Levitsky | b9a0de3 | 2020-12-17 17:54:36 +0200 | [diff] [blame] | 43 | coroutine.CoroutineBt() |
Paolo Bonzini | a201b0f | 2015-10-12 10:02:54 +0200 | [diff] [blame] | 44 | |
Peter Maydell | 5e3c72d | 2015-08-14 18:46:31 +0100 | [diff] [blame] | 45 | # Default to silently passing through SIGUSR1, because QEMU sends it |
| 46 | # to itself a lot. |
| 47 | gdb.execute('handle SIGUSR1 pass noprint nostop') |