scripts/gdb: add data window feature
Subsystems (2)
RFC PATCH 1/1 scripts/gdb: add data window feature
Add data window feature to show current kernel status on separate consoles, including: 1) registers, 2) back trace and 3) watch data windows.
The data window would help kernel developer to understand current hardware/ kernel status, and on single-stepping, the modified fields in the data window would be highlighted.
--- Documentation/gdb-kernel-debugging.txt | 9 ++ scripts/gdb/linux/dw.py | 234 +++++++++++++++++++++++++++++++++ scripts/gdb/linux/lx-dw.py | 53 ++++++++ scripts/gdb/vmlinux-gdb.py | 1 + scripts/lx-dw.sh | 4 + 5 files changed, 301 insertions(+) create mode 100644 scripts/gdb/linux/dw.py create mode 100644 scripts/gdb/linux/lx-dw.py create mode 100755 scripts/lx-dw.sh
Documentation/gdb-kernel-debugging.txt +9 -0
@@ -139,6 +139,14 @@ Examples of using the Linux-provided gdb helpers start_comm = "swapper/2\000\000\000\000\000\000" } + o Enable the debugging data window feature in GDB, then run lx-dw.sh script + to create three xterm console on desktop to display the CPU registers, + back trace and variables. + (gdb) lx-dw + (gdb) lx-add p $lx_current().comm + (gdb) lx-add x/8x $rsp + (gdb) lx-add x/8i $rip + List of commands and functions ------------------------------
@@ -153,6 +161,7 @@ this is just a snapshot of the initial version: function lx_task_by_pid -- Find Linux task by PID and return the task_struct variable function lx_thread_info -- Calculate Linux thread_info from task variable lx-dmesg -- Print Linux kernel log buffer + lx-dw -- Enable GDB data window feature lx-lsmod -- List currently loaded modules lx-symbols -- (Re-)load symbols of Linux kernel and currently loaded modules
scripts/gdb/linux/dw.py new file +234 -0
234 lines not on this page · raw message
scripts/gdb/linux/lx-dw.py new file +53 -0
53 lines not on this page · raw message
scripts/gdb/vmlinux-gdb.py +1 -0
@@ -28,3 +28,4 @@ else: import linux.dmesg import linux.tasks import linux.cpus + import linux.dw
scripts/lx-dw.sh new file +4 -0
@@ -0,0 +1,4 @@ +xterm -fa 'Monospace' -fs 12 -e "python gdb/linux/lx-dw.py bt-dw" & +xterm -fa 'Monospace' -fs 12 -e "python gdb/linux/lx-dw.py reg-dw" & +xterm -fa 'Monospace' -fs 12 -e "python gdb/linux/lx-dw.py watch-dw" & +
Signature · 1 line
2.1.4
Quoted 7 lines · Houcheng Lin
Add data window feature to show current kernel status on separate consoles, including: 1) registers, 2) back trace and 3) watch data windows.
The data window would help kernel developer to understand current hardware/ kernel status, and on single-stepping, the modified fields in the data window would be highlighted.
I was trying to get an overview of this feature. Unfortunately, it does not work for me. I type in the commands you describe in the documentation, but nothing shows up. I suspect there are some hard-coded assumption about directory layouts etc. that aren't fulfilled here (out-of-tree build).
Anyway, let's try to understand what you would like to achieve. This seems to be some add-on tool for gdb debugging sessions to display target states continuously in separate terminals. Right? Is this comparable to gdb's tui mode?
More important, is this specific to the debugging infrastructure we have in scripts/gdb? Or could I install it (after some modifications, I guess) in my home directory and use it for any gdb session, not just with Linux kernels? Is there anything in it that particularly refers to Linux structures? In that case I would suggest to make it stand-alone first so that one could easily include it whenever needed, either explicitly or via ~/.gitinit.
Thanks for sharing in any case!
Jan
2015-07-22 5:04 GMT+08:00 Jan Kiszka <[email protected]>:
Quoted 9 lines · Houcheng Lin
Quoted 7 lines
Add data window feature to show current kernel status on separate consoles, including: 1) registers, 2) back trace and 3) watch data windows.
The data window would help kernel developer to understand current hardware/ kernel status, and on single-stepping, the modified fields in the data window would be highlighted.
Quoted 5 lines
I was trying to get an overview of this feature. Unfortunately, it does not work for me. I type in the commands you describe in the documentation, but nothing shows up. I suspect there are some hard-coded assumption about directory layouts etc. that aren't fulfilled here (out-of-tree build).
Sorry for not working. The steps might be run the "lx-dw" command first, then step the kernel in gdb; the kernel status would be dump to files in /tmp. Then you can run lx-dw.sh that creates 3 xterm window to display registers, back trace and watch variables.
Quoted 6 lines
Anyway, let's try to understand what you would like to achieve. This seems to be some add-on tool for gdb debugging sessions to display target states continuously in separate terminals. Right? Is this comparable to gdb's tui mode?
Yes, it is similar feature; dumps the content of register and kernel status into a separate window continuously and highlight the difference. It's snapshot is here:
https://www.dropbox.com/s/tl67sxm6474jd8i/dw-screenshot.png?dl=0
Quoted 7 lines
More important, is this specific to the debugging infrastructure we have in
scripts/gdb? Or could I install it (after some modifications, I guess) in my home directory and use it for any gdb session, not just with Linux kernels? Is there anything in it that particularly refers to Linux structures? In that case I would suggest to make it stand-alone first so that one could easily include it whenever needed, either explicitly or via ~/.gitinit.
This is not under the infrastructure of kernel gdb, however, this feature is needed and specific for kernel debugging. When trace an optimized kernel source, we usually need to trace it in assembly and throught the data window to update the current kernel status. It can be standalone, but I think it may helps a lot when developing kernel and good to be part of kernel gdb scripts.
best regards,
Houcheng Lin
Quoted 5 lines
Thanks for sharing in any case!
Jan
Signature · 2 lines
Best regards, Houcheng Lin