[PATCH 0/4] target/m68k: implement m68k "any instruction" trace mode

Mark Cave-Ayland posted 4 patches 2 years, 11 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210519142917.16693-1-mark.cave-ayland@ilande.co.uk
Maintainers: Laurent Vivier <laurent@vivier.eu>
target/m68k/cpu.h       |  8 +++++++
target/m68k/translate.c | 51 ++++++++++++++++++++++++++++++++++-------
2 files changed, 51 insertions(+), 8 deletions(-)
[PATCH 0/4] target/m68k: implement m68k "any instruction" trace mode
Posted by Mark Cave-Ayland 2 years, 11 months ago
This patchset implements the m68k "any instruction" tracing mode which is used
by the NetBSD kernel debugger to implement single-stepping. It is based upon
reading through the M68000 PRM and looking at how the ARM target handles both
gdbstub and architectural single-step exceptions.

With this patchset it becomes possible to single-step the NetBSD kernel using
the in-built kernel debugger:

Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x6:        unlk    a6
db> s
Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x8:        rts
db> 
Stopped in pid 0.1 (system) at  netbsd:main+0x2c:       jsr     kernel_lock_init
        [addr:0x1a38f6 ]
db> 
Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init:        linkw   a6,#0
db> 
Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0x4:    clrb    kernel_l
ock     [addr:0x33f400 ]
db> 
Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0xa:    clrb    kernel_l
ock_dodebug     [addr:0x35b48c ]
db> 
Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0x10:   unlk    a6
db> 
Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0x12:   rts
db> c
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
[   1.0000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
[   1.0000000]     2018, 2019, 2020 The NetBSD Foundation, Inc.  All rights reserved.
[   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[   1.0000000]     The Regents of the University of California.  All rights reserved.

[   1.0000000] NetBSD 9.1 (GENERIC) #0: Sun Oct 18 19:24:30 UTC 2020
... etc ...


Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

[q800-macos-upstream patchset series: 2]

Mark Cave-Ayland (4):
  target/m68k: introduce is_singlestepping() function
  target/m68k: call gen_raise_exception() directly if single-stepping in
    gen_jmp_tb()
  target/m68k: introduce gen_singlestep_exception() function
  target/m68k: implement m68k "any instruction" trace mode

 target/m68k/cpu.h       |  8 +++++++
 target/m68k/translate.c | 51 ++++++++++++++++++++++++++++++++++-------
 2 files changed, 51 insertions(+), 8 deletions(-)

-- 
2.20.1


Re: [PATCH 0/4] target/m68k: implement m68k "any instruction" trace mode
Posted by Laurent Vivier 2 years, 11 months ago
Le 19/05/2021 à 16:29, Mark Cave-Ayland a écrit :
> This patchset implements the m68k "any instruction" tracing mode which is used
> by the NetBSD kernel debugger to implement single-stepping. It is based upon
> reading through the M68000 PRM and looking at how the ARM target handles both
> gdbstub and architectural single-step exceptions.
> 
> With this patchset it becomes possible to single-step the NetBSD kernel using
> the in-built kernel debugger:
> 
> Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x6:        unlk    a6
> db> s
> Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x8:        rts
> db> 
> Stopped in pid 0.1 (system) at  netbsd:main+0x2c:       jsr     kernel_lock_init
>         [addr:0x1a38f6 ]
> db> 
> Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init:        linkw   a6,#0
> db> 
> Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0x4:    clrb    kernel_l
> ock     [addr:0x33f400 ]
> db> 
> Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0xa:    clrb    kernel_l
> ock_dodebug     [addr:0x35b48c ]
> db> 
> Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0x10:   unlk    a6
> db> 
> Stopped in pid 0.1 (system) at  netbsd:kernel_lock_init+0x12:   rts
> db> c
> Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
> [   1.0000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
> [   1.0000000]     2018, 2019, 2020 The NetBSD Foundation, Inc.  All rights reserved.
> [   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
> [   1.0000000]     The Regents of the University of California.  All rights reserved.
> 
> [   1.0000000] NetBSD 9.1 (GENERIC) #0: Sun Oct 18 19:24:30 UTC 2020
> ... etc ...
> 
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> 
> [q800-macos-upstream patchset series: 2]
> 
> Mark Cave-Ayland (4):
>   target/m68k: introduce is_singlestepping() function
>   target/m68k: call gen_raise_exception() directly if single-stepping in
>     gen_jmp_tb()
>   target/m68k: introduce gen_singlestep_exception() function
>   target/m68k: implement m68k "any instruction" trace mode
> 
>  target/m68k/cpu.h       |  8 +++++++
>  target/m68k/translate.c | 51 ++++++++++++++++++++++++++++++++++-------
>  2 files changed, 51 insertions(+), 8 deletions(-)
> 

Applied to my m68k-for-6.1 tree.

Thanks,
Laurent