[PATCH v3 0/4] Fixes and improvements for scripts/qemugdb commands

Andrey Drobyshev posted 4 patches 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251204105019.455060-1-andrey.drobyshev@virtuozzo.com
scripts/qemugdb/coroutine.py | 257 +++++++++++++++++++++++++++++++++--
scripts/qemugdb/mtree.py     |   2 +-
scripts/qemugdb/timers.py    |  54 ++++++--
3 files changed, 289 insertions(+), 24 deletions(-)
[PATCH v3 0/4] Fixes and improvements for scripts/qemugdb commands
Posted by Andrey Drobyshev 2 months ago
v2 -> v3:

  * Use atexit.register() instead of gdb.events.exited.connect() for
    registering a cleanup callback.  That way it's called upon both
    normal and abnormal exit;
  * Wrap code in invoke() methods in try-finally block, so that
    restore_regs() is called unconditionally even we caught an exception;
  * Restore registers in cleanup;
  * Set dirty flag early on in patch_regs() to make sure registers get
    restored if we failed while patching.

v1 -> v2:

  * Use pty module instead of script(1) for producing colored output;
  * Patch coredump file in place instead of full copy;
  * Save and restore original pt_regs values in a separate file;
  * Wrap this logic in a separate class.

v2: https://lore.kernel.org/qemu-devel/20251202163119.363969-1-andrey.drobyshev@virtuozzo.com/
v1: https://lore.kernel.org/qemu-devel/20251125142105.448289-1-andrey.drobyshev@virtuozzo.com/

Andrey Drobyshev (4):
  scripts/qemugdb: mtree: Fix OverflowError in mtree with 128-bit
    addresses
  scripts/qemugdb: timers: Fix KeyError in 'qemu timers' command
  scripts/qemugdb: timers: Improve 'qemu timers' command readability
  scripts/qemugdb: coroutine: Add option for obtaining detailed trace in
    coredump

 scripts/qemugdb/coroutine.py | 257 +++++++++++++++++++++++++++++++++--
 scripts/qemugdb/mtree.py     |   2 +-
 scripts/qemugdb/timers.py    |  54 ++++++--
 3 files changed, 289 insertions(+), 24 deletions(-)

-- 
2.43.5
Re: [PATCH v3 0/4] Fixes and improvements for scripts/qemugdb commands
Posted by Stefan Hajnoczi 1 month ago
On Thu, Dec 04, 2025 at 12:50:15PM +0200, Andrey Drobyshev wrote:
> v2 -> v3:
> 
>   * Use atexit.register() instead of gdb.events.exited.connect() for
>     registering a cleanup callback.  That way it's called upon both
>     normal and abnormal exit;
>   * Wrap code in invoke() methods in try-finally block, so that
>     restore_regs() is called unconditionally even we caught an exception;
>   * Restore registers in cleanup;
>   * Set dirty flag early on in patch_regs() to make sure registers get
>     restored if we failed while patching.
> 
> v1 -> v2:
> 
>   * Use pty module instead of script(1) for producing colored output;
>   * Patch coredump file in place instead of full copy;
>   * Save and restore original pt_regs values in a separate file;
>   * Wrap this logic in a separate class.
> 
> v2: https://lore.kernel.org/qemu-devel/20251202163119.363969-1-andrey.drobyshev@virtuozzo.com/
> v1: https://lore.kernel.org/qemu-devel/20251125142105.448289-1-andrey.drobyshev@virtuozzo.com/
> 
> Andrey Drobyshev (4):
>   scripts/qemugdb: mtree: Fix OverflowError in mtree with 128-bit
>     addresses
>   scripts/qemugdb: timers: Fix KeyError in 'qemu timers' command
>   scripts/qemugdb: timers: Improve 'qemu timers' command readability
>   scripts/qemugdb: coroutine: Add option for obtaining detailed trace in
>     coredump
> 
>  scripts/qemugdb/coroutine.py | 257 +++++++++++++++++++++++++++++++++--
>  scripts/qemugdb/mtree.py     |   2 +-
>  scripts/qemugdb/timers.py    |  54 ++++++--
>  3 files changed, 289 insertions(+), 24 deletions(-)
> 
> -- 
> 2.43.5
> 

Thanks, applied to my block tree:
https://gitlab.com/stefanha/qemu/commits/block

Stefan
Re: [PATCH v3 0/4] Fixes and improvements for scripts/qemugdb commands
Posted by Andrey Drobyshev 1 month, 1 week ago
On 12/4/25 12:50 PM, Andrey Drobyshev wrote:
> v2 -> v3:
> 
>   * Use atexit.register() instead of gdb.events.exited.connect() for
>     registering a cleanup callback.  That way it's called upon both
>     normal and abnormal exit;
>   * Wrap code in invoke() methods in try-finally block, so that
>     restore_regs() is called unconditionally even we caught an exception;
>   * Restore registers in cleanup;
>   * Set dirty flag early on in patch_regs() to make sure registers get
>     restored if we failed while patching.
> 
> v1 -> v2:
> 
>   * Use pty module instead of script(1) for producing colored output;
>   * Patch coredump file in place instead of full copy;
>   * Save and restore original pt_regs values in a separate file;
>   * Wrap this logic in a separate class.
> 
> v2: https://lore.kernel.org/qemu-devel/20251202163119.363969-1-andrey.drobyshev@virtuozzo.com/
> v1: https://lore.kernel.org/qemu-devel/20251125142105.448289-1-andrey.drobyshev@virtuozzo.com/
> 
> Andrey Drobyshev (4):
>   scripts/qemugdb: mtree: Fix OverflowError in mtree with 128-bit
>     addresses
>   scripts/qemugdb: timers: Fix KeyError in 'qemu timers' command
>   scripts/qemugdb: timers: Improve 'qemu timers' command readability
>   scripts/qemugdb: coroutine: Add option for obtaining detailed trace in
>     coredump
> 
>  scripts/qemugdb/coroutine.py | 257 +++++++++++++++++++++++++++++++++--
>  scripts/qemugdb/mtree.py     |   2 +-
>  scripts/qemugdb/timers.py    |  54 ++++++--
>  3 files changed, 289 insertions(+), 24 deletions(-)
> 

Kind reminder.

AFAICT we've managed to cover all the issues with the last commit, so if
there're any others - please let me know.

Andrey