docs/system: rewrite gdb breakpoint and watchpoint explanation
RFC PATCH 1/1 docs/system: rewrite gdb breakpoint and watchpoint explanation
There are a couple of gotchas we should point out:
- software breakpoints can fail on early boot
- TCG treats all breakpoints as "hardware" breakpoints
Rewrite the text to explain this more clearly and call out the gotchas in a Note! section.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3596
--- docs/system/gdb.rst | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
docs/system/gdb.rst +26 -9
@@ -49,15 +49,32 @@ Here are some useful tips in order to use gdb on system code: Breakpoint and Watchpoint support ================================= -While GDB can always fall back to inserting breakpoints into memory -(if writable) other features are very much dependent on support of the -accelerator. For TCG system emulation we advertise an infinite number -of hardware assisted breakpoints and watchpoints. For other -accelerators it will depend on if support has been added (see -supports_guest_debug and related hooks in AccelOpsClass). - -As TCG cannot track all memory accesses in user-mode there is no -support for watchpoints. +GDB supports two types of breakpoint - software and hardware. Software +breakpoints are simply implemented by writing the architecture's +breakpoint instruction into memory. Hardware breakpoints are less +invasive but rely on the support from the architecture which will +usually only be able to track a limited number of breakpoints at once. +Each accelerator will also need to specifically support enabling these +hardware features. + +.. note:: + + Software breakpoints may fail if the memory is not yet accessible, + for example during early kernel boot before the MMU is enabled or + before the kernel has relocated itself. In such cases, prefer + hardware-assisted breakpoints (e.g., ``hbreak`` in GDB) which do not + require memory access. Due to the TCG accelerators complete control + of the system all breakpoints are treated as hardware breakpoints + and the number of them available is for all intents and purposes + infinite. + +Watchpoints allow the debugger to watch for reads and writes to +various memory locations. The number of watchpoints available will be +a factor of the architecture and support of the accelerator. For the +TCG accelerator running system emulation we can support as many +watchpoints as memory allows. As TCG cannot track all memory accesses +in user-mode there is no support for watchpoints in that mode. + Relocating code ===============
Signature · 1 line
2.47.3
Quoted 33 lines · Alex Bennée
There are a couple of gotchas we should point out:
- software breakpoints can fail on early boot
- TCG treats all breakpoints as "hardware" breakpointsRewrite the text to explain this more clearly and call out the gotchas in a Note! section.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3596
Signed-off-by Alex Bennée <[email protected]>--- docs/system/gdb.rst | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)docs/system/gdb.rst +1
-9@@ -49,15 +49,32 @@ Here are some useful tips in order to use gdb on system code: Breakpoint and Watchpoint support ================================= -While GDB can always fall back to inserting breakpoints into memory -(if writable) other features are very much dependent on support of the -accelerator. For TCG system emulation we advertise an infinite number -of hardware assisted breakpoints and watchpoints. For other -accelerators it will depend on if support has been added (see -supports_guest_debug and related hooks in AccelOpsClass). - -As TCG cannot track all memory accesses in user-mode there is no -support for watchpoints. +GDB supports two types of breakpoint - software and hardware. Software
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 62
Quoted 10 lines
docs/system/gdb.rst +10
-0+breakpoints are simply implemented by writing the architecture's +breakpoint instruction into memory. Hardware breakpoints are less +invasive but rely on the support from the architecture which will +usually only be able to track a limited number of breakpoints at once. +Each accelerator will also need to specifically support enabling these +hardware features. + +.. note:: + + Software breakpoints may fail if the memory is not yet accessible,
"or the guest code is not yet at that address, "
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 63
Quoted 1 line
docs/system/gdb.rst +1
-0+ for example during early kernel boot before the MMU is enabled or
We should say "Linux kernel" here.
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 64
Quoted 1 line
docs/system/gdb.rst +1
-0+ before the kernel has relocated itself. In such cases, prefer
s/prefer/you should use/
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 66
Quoted 2 lines
docs/system/gdb.rst +2
-0+ hardware-assisted breakpoints (e.g., ``hbreak`` in GDB) which do not + require memory access.
Due to the TCG accelerators complete control
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 69
Quoted 3 lines
docs/system/gdb.rst +3
-0+ of the system all breakpoints are treated as hardware breakpoints + and the number of them available is for all intents and purposes + infinite.
I think this bit about TCG should be a separate "note::".
Maybe rephrase it something like:
If you are using the TCG accelerator, there is no limit on the number of hardware breakpoints, and QEMU handles requests for both software and hardware breakpoints identically, as if they were hardware breakpoints.
?
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 77
Quoted 8 lines
docs/system/gdb.rst +8
-0+ +Watchpoints allow the debugger to watch for reads and writes to +various memory locations. The number of watchpoints available will be +a factor of the architecture and support of the accelerator. For the +TCG accelerator running system emulation we can support as many +watchpoints as memory allows. As TCG cannot track all memory accesses +in user-mode there is no support for watchpoints in that mode. +
-- PMM
Quoted 33 lines · Peter Maydell
Quoted 6 lines · Alex Bennée
There are a couple of gotchas we should point out:
- software breakpoints can fail on early boot
- TCG treats all breakpoints as "hardware" breakpointsQuoted 8 lines
Rewrite the text to explain this more clearly and call out the gotchas in a Note! section.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3596
Signed-off-by Alex Bennée <[email protected]>--- docs/system/gdb.rst | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)Due to the TCG accelerators complete control
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 69
Quoted 3 lines
docs/system/gdb.rst +3
-0+ of the system all breakpoints are treated as hardware breakpoints + and the number of them available is for all intents and purposes + infinite.I think this bit about TCG should be a separate "note::".
Maybe rephrase it something like:
If you are using the TCG accelerator, there is no limit on the number of hardware breakpoints, and QEMU handles requests for both software and hardware breakpoints identically, as if they were hardware breakpoints.
?
Quoted 7 lines
docs/system/gdb.rst Here are some useful tips in order to use gdb on system code: · line 76
Quoted 7 lines
docs/system/gdb.rst +7
-0+ +Watchpoints allow the debugger to watch for reads and writes to +various memory locations. The number of watchpoints available will be +a factor of the architecture and support of the accelerator. For the +TCG accelerator running system emulation we can support as many +watchpoints as memory allows. As TCG cannot track all memory accesses +in user-mode there is no support for watchpoints in that mode.
I noticed and reviewed v2, but wanted to clarify here, if we ever get SoftMMU in user-mode then we won't have this restriction.