SlideShare a Scribd company logo
© 2009 Wind River
Merging KGDB KDB and
Kernel Mode Setting
Jason Wessel – Wind River
Jesse Barnes - Intel
© 2009 Wind River
The Glossary
• KGDB – Kernel GDB remote interface
– KGDB core merged to mainline kernel in 2.6.26
– Generic gdb serial interface for single or multi processor
systems, where gdb provides a source view of the system
– Works only with a uart based console driver
• KDB – Kernel debugger
– Never merged to mainline kernel and not likely to merge as is
– Supports only i386 and x86_64
– Provides a simple debugger via the system console or a serial
port, with no high level source
• KMS – Kernel Mode Settting
– Merged to mainline kernel in 2.6.29
– Core graphics driver in the kernel provides seamless switch
from console to graphics modes (vs reinitializing the HW each
time)
© 2009 Wind River
The Goal – Let the MERGE BEGIN!
• A simple, reliable multi-architecture debug shell
• Works with graphics or serial
• Ability to use kgdb or kdb
• Join the KDB and KGDB communities together
• Provide an API for future command expansion
– Trace dumping
– Disassembly
– Subsystem inspection commands (vfs, network, etc)
© 2009 Wind River
An example problem
• Awe MAN! If only I had a few more lines in the trace...
© 2009 Wind River
The debug shell
© 2009 Wind River
Basic KGDB design
KGDB has 4 main pieces
• Debug Core – Generic debug API
– Handles exceptions
– Syncs/saves/restores CPUs
– API for SW/HW breakpoints
• Arch specific KGDB
– Interface to read/write registers
– Arch specific exceptions and watch dogs
– Single stepping interface
• GDB Stub
– Speaks the gdb serial protocol
• Polled I/O Driver (kgdboc / kgdboe / kgdbou / kgdb_8250)
– Uses the console UART driver to multiplex a single serial line
– Another host's gdb connects to this port
Debug
Core
GDB
Stub
Polled
I/O Driver
Arch
Specific
KGDB
© 2009 Wind River
Basic KDB design
KDB has lots of parts
129 files changed, 57952 insertions(+), 10 deletions(-)
Low Level Arch Specific exceptions
kdb_main
kdb_io
Polled Keyboard driver
Polled serial driver
Assembly
set_jmp() long_jmp()
Back tracer
Other modules kdump etc...
disassembler
Single Step
BOOM!
Crash!
Thunk! Splat!
© 2009 Wind River
Merging KDB & KGDB
• The polled keyboard driver hooks into kgdboc
• The kdb_main, kdb_io and cmd handlers hook straight to the debug core
• gdb can use “monitor ...cmd...” to issue kdb cmds
• KDB got all the architecture specific pieces removed
– KDB core = 27 files changed, 6521 insertions(+), 10 deletions(-)
– KGDB changes = 9 files changed, 154 insertions(+), 31 deletions(-)
Debug
Core
kdb_main and kdb_io
Polled
I/O Driver
KGDBOC
Arch
Specific
KGDB
GDB Stub
KDB Polled Keyboard driver
© 2009 Wind River
KMS (kernel mode setting) basics
• Mode setting refers to changing the graphics console display
characteristics, such as the display type/size, screen blanking and
graphics hw management
• Mode setting in userspace causes issues:
– suspend/resume
– interaction with kernel drivers
– Ability to change from X to console on crash (BOSD)
• KMS paves the way for flicker free console switching
• Adding in console debugger support becomes desirable to analyse a crash
or inspect the system
• The hard part lies in making KMS work without locks
– Take an exception
– Transition to console atomically
– Run kdb
– Restore graphics
– Resume system
© 2009 Wind River
kgdb + kdb + kms
• KMS bolts into the debugger via kgdboc entry/exit call backs
• Configuration of using KMS is dynamic through kgdboc
Debug
Core
kdb
kgdboc
Arch
Specific
KGDB
GDB Stub
KMS
Hooks
© 2009 Wind River
Demonstration time
• KGDB, KDB and KMS in < 60 seconds
– http://www.youtube.com/watch?v=PDds73yDCNo
© 2009 Wind River
But wait there's MORE!
How about kgdb + kdb + kms + usb serial
© 2009 Wind River
Moving beyond the prototype
• The first priority is to finish cleaning kdb core and post to LKML
– kernel/kgdb.c → kernel/debug/debug_core.c and
gdbstub.c
– kernel/debug/kdb/*
– Rename arch/*/kernel/kgdb.c →
arch/*/kernel/debug_arch.c
• For KMS, there are certainly problems with the locks
+++ b/drivers/gpu/drm/drm_crtc.c
+#ifdef CONFIG_KGDB
+ if (atomic_read(&kgdb_active) == -1)
+#endif
+ mutex_lock(&dev->mode_config.idr_mutex);
• KMS needs some generic debugger API work
– Only the Intel 915 works today with kdb
– Jesse suggested the possibility for a dedicated debug
console
© 2009 Wind River
Moving beyond the prototype
• The USB keyboard driver is UGLY!!!
– The low level uchi/ohci/ehci are modified to allow for
polloing and pulling off packets of the keyboard type only
• Anyone want to help with an “alternatives” implementation?
– The debugger needs to change some code paths after entry
– The debugger should stay out of the way otherwise
• Low Level exception support
– The debug core needs the first right of breakpoint handling
– Perhaps code “alternatives”?
• panic() should allow a debug hook before calling smp_send_stop()
© 2009 Wind River
Nested Exception Support
• Prototype hack for debugging part of the code used by the debugger
proves useful
– It was possible to debug the KMS code with kgdb so long as on
the second exception kgdb jumps directly into the debug core
– Without the “hack” the debug core prints a stack dump an
panics
• The kgdb_ll_trap() was introduced by kdb to allow the debug core to step
through an atomic_notifier_call_chain
• It is now a TODO item to consider nested exception debugging because
you can also debug parts of the debugger itself
© 2009 Wind River
Displaced Stepping?
• Problems without displaced stepping
– Missed breakpoint
• free all cpus and wait for a thread to get scheduled
which uses HW single stepping
– Deadlock on lock
• single stepping by freeing only one CPU, dead locks on
any lock held by a frozen CPU
• Displaced stepping is leaving a break point planted and executing the
original instruction out of line
– An experimental patch modifies kprobes to plant a probe to
single step a kernel thread
– The down side is you cannot debug some further small pieces of
the kernel
© 2009 Wind River
Mainline for kgdboe someday?
• Today's kgdboe has a major short coming, in that it is not robust
• Network drivers can be in a state where it is impossible to use them safely
from the exception context (preempted with locks held)
• Possible solutions:
– Perhaps a dedicated queue in the HW is the answer (e1000e)
– While it would require a dedicated ethernet interface, you could
use a self contained, exception safe network stack
– A redesigned poll interface
© 2009 Wind River
kgdbou (kgdb over usb)
• It is on the mile long todo list :-)
• First up is work around improved USB console support
– 2.6.31 - merged USB sysrq support
– 2.6.32 - USB EHCI debug port console (supports early_printk)
– Stable USB console support is a work in progress
– kgdbou present state is considered “too much of a hack”
• Kgdb integration can proceed after the console support
– On the demo machine there are if (kgdb_activate...) checks in
the hot path which would need to resolved by design
© 2009 Wind River
The kernel debugger and the future
• We want to unite the all the of the kernel debugger folks
• Send patches to kgdb-bugreport@lists.sourceforge.net
• The kgdb wiki is slated to launch in late September
http://kgdb.wiki.kernel.org/
Special Thanks
– Jesse Barnes - for his KMS code
– Martin Hicks - (KDB maintainer) for kdb cleanup patches
Kgdb kdb modesetting

More Related Content

What's hot (20)

PDF
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
PPT
Linux Crash Dump Capture and Analysis
Paul V. Novarese
 
PDF
Kernel Recipes 2015 - Kernel dump analysis
Anne Nicolas
 
PDF
Qemu Introduction
Chiawei Wang
 
PDF
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Anne Nicolas
 
PPTX
Tech Days 2015: Embedded Product Update
AdaCore
 
PDF
Low latency & mechanical sympathy issues and solutions
Jean-Philippe BEMPEL
 
PDF
LXC on Ganeti
kawamuray
 
PDF
Kernel Recipes 2015: Kernel packet capture technologies
Anne Nicolas
 
PDF
FreeBSD and Drivers
Kernel TLV
 
PPTX
RHEVM - Live Storage Migration
Raz Tamir
 
PDF
Kernel Recipes 2015: Speed up your kernel development cycle with QEMU
Anne Nicolas
 
PDF
Understand and optimize Linux I/O
Andrea Righi
 
PDF
Kernel Recipes 2015: Anatomy of an atomic KMS driver
Anne Nicolas
 
PDF
Xdp and ebpf_maps
lcplcp1
 
PDF
Kernel Recipes 2017 - Build farm again - Willy Tarreau
Anne Nicolas
 
PDF
Linux Cluster next generation
samsolutionsby
 
PDF
IRQs: the Hard, the Soft, the Threaded and the Preemptible
Alison Chaiken
 
PDF
Kernel Recipes 2015: Solving the Linux storage scalability bottlenecks
Anne Nicolas
 
PDF
NetBSD and Linux for Embedded Systems
Mahendra M
 
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
Linux Crash Dump Capture and Analysis
Paul V. Novarese
 
Kernel Recipes 2015 - Kernel dump analysis
Anne Nicolas
 
Qemu Introduction
Chiawei Wang
 
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Anne Nicolas
 
Tech Days 2015: Embedded Product Update
AdaCore
 
Low latency & mechanical sympathy issues and solutions
Jean-Philippe BEMPEL
 
LXC on Ganeti
kawamuray
 
Kernel Recipes 2015: Kernel packet capture technologies
Anne Nicolas
 
FreeBSD and Drivers
Kernel TLV
 
RHEVM - Live Storage Migration
Raz Tamir
 
Kernel Recipes 2015: Speed up your kernel development cycle with QEMU
Anne Nicolas
 
Understand and optimize Linux I/O
Andrea Righi
 
Kernel Recipes 2015: Anatomy of an atomic KMS driver
Anne Nicolas
 
Xdp and ebpf_maps
lcplcp1
 
Kernel Recipes 2017 - Build farm again - Willy Tarreau
Anne Nicolas
 
Linux Cluster next generation
samsolutionsby
 
IRQs: the Hard, the Soft, the Threaded and the Preemptible
Alison Chaiken
 
Kernel Recipes 2015: Solving the Linux storage scalability bottlenecks
Anne Nicolas
 
NetBSD and Linux for Embedded Systems
Mahendra M
 

Viewers also liked (20)

PDF
Linux Kernel Debugging Essentials workshop
Lubomir Rintel
 
PDF
Descripcion de nuestros servicios de Inteligencia Comercial
Lourdes Gómez
 
PDF
2012 M&A Deal Terms Study
MMMTechLaw
 
PPTX
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
Andrew Case
 
PPTX
Cybermania Mains
Divye Kapoor
 
PDF
Linux performance
Will Sterling
 
PDF
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanity
Anne Nicolas
 
PPTX
Cybermania Prelims
Divye Kapoor
 
PPTX
A particle filter based scheme for indoor tracking on an Android Smartphone
Divye Kapoor
 
PDF
Rootkit 102 - Kernel-Based Rootkit
Chia-Hao Tsai
 
ODP
Linux Internals - Kernel/Core
Shay Cohen
 
PDF
The TCP/IP stack in the FreeBSD kernel COSCUP 2014
Kevin Lo
 
PDF
LAS16-403 - GDB Linux Kernel Awareness
Peter Griffin
 
PDF
ELK: a log management framework
Giovanni Bechis
 
PDF
The Linux Kernel Implementation of Pipes and FIFOs
Divye Kapoor
 
PPT
Understanding Your Organisation
Eneni Oduwole
 
PPTX
Introduction to ELK
YuHsuan Chen
 
PDF
Rootkit on Linux X86 v2.6
fisher.w.y
 
PDF
Abby Covert – How to make sense of any mess
inUse
 
Linux Kernel Debugging Essentials workshop
Lubomir Rintel
 
Descripcion de nuestros servicios de Inteligencia Comercial
Lourdes Gómez
 
2012 M&A Deal Terms Study
MMMTechLaw
 
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
Andrew Case
 
Cybermania Mains
Divye Kapoor
 
Linux performance
Will Sterling
 
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanity
Anne Nicolas
 
Cybermania Prelims
Divye Kapoor
 
A particle filter based scheme for indoor tracking on an Android Smartphone
Divye Kapoor
 
Rootkit 102 - Kernel-Based Rootkit
Chia-Hao Tsai
 
Linux Internals - Kernel/Core
Shay Cohen
 
The TCP/IP stack in the FreeBSD kernel COSCUP 2014
Kevin Lo
 
LAS16-403 - GDB Linux Kernel Awareness
Peter Griffin
 
ELK: a log management framework
Giovanni Bechis
 
The Linux Kernel Implementation of Pipes and FIFOs
Divye Kapoor
 
Understanding Your Organisation
Eneni Oduwole
 
Introduction to ELK
YuHsuan Chen
 
Rootkit on Linux X86 v2.6
fisher.w.y
 
Abby Covert – How to make sense of any mess
inUse
 
Ad

Similar to Kgdb kdb modesetting (20)

PDF
Lecture 6 Kernel Debugging + Ports Development
Mohammed Farrag
 
PDF
Kernel development
Nuno Martins
 
PPT
Group 1 Presentation
marivic montiero
 
PDF
ELC-E Linux Awareness
Peter Griffin
 
PDF
Flourish11
Dru Lavigne
 
PDF
Crash Dump Analysis 101
John Howard
 
PDF
Jtag Tools For Linux
sheilamia
 
PDF
Scale9x sun
Dru Lavigne
 
PPTX
Arm architecture chapter2_steve_furber
asodariyabhavesh
 
PDF
Solaris Kernel Debugging V1.0
Jarod Wang
 
PDF
LAS16-403: GDB Linux Kernel Awareness
Linaro
 
PDF
今日から始めるPlan 9 from Bell Labs
Ryousei Takano
 
PDF
Debugging embedded devices using GDB
Chris Simmonds
 
PDF
Lect02
Vin Voro
 
PPTX
Computer Software | Lecture 4C
CMDLMS
 
PPTX
Computer Software - Lecture C
CMDLearning
 
ODP
coreboot@Budapest 10.2009 Meetup
Cristian Măgherușan-Stanciu
 
PDF
2013 Indiana LinuxFest - Getting Started With PC-BSD
Ken Moore
 
PPTX
Reversing with gdb
Mihir Shah
 
PDF
olf10
Dru Lavigne
 
Lecture 6 Kernel Debugging + Ports Development
Mohammed Farrag
 
Kernel development
Nuno Martins
 
Group 1 Presentation
marivic montiero
 
ELC-E Linux Awareness
Peter Griffin
 
Flourish11
Dru Lavigne
 
Crash Dump Analysis 101
John Howard
 
Jtag Tools For Linux
sheilamia
 
Scale9x sun
Dru Lavigne
 
Arm architecture chapter2_steve_furber
asodariyabhavesh
 
Solaris Kernel Debugging V1.0
Jarod Wang
 
LAS16-403: GDB Linux Kernel Awareness
Linaro
 
今日から始めるPlan 9 from Bell Labs
Ryousei Takano
 
Debugging embedded devices using GDB
Chris Simmonds
 
Lect02
Vin Voro
 
Computer Software | Lecture 4C
CMDLMS
 
Computer Software - Lecture C
CMDLearning
 
coreboot@Budapest 10.2009 Meetup
Cristian Măgherușan-Stanciu
 
2013 Indiana LinuxFest - Getting Started With PC-BSD
Ken Moore
 
Reversing with gdb
Mihir Shah
 
Ad

Recently uploaded (20)

PDF
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
PPTX
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
 
PPT
SF 9_Unit 1.ppt software engineering ppt
AmarrKannthh
 
PPTX
ASBC application presentation template (ENG)_v3 (1).pptx
HassanMohammed730118
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PPTX
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
PDF
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
PDF
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PDF
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
PDF
01-introduction to the ProcessDesign.pdf
StiveBrack
 
PDF
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
PDF
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
PPTX
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
PPTX
Precooling and Refrigerated storage.pptx
ThongamSunita
 
PDF
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
Computer network Computer network Computer network Computer network
Shrikant317689
 
SF 9_Unit 1.ppt software engineering ppt
AmarrKannthh
 
ASBC application presentation template (ENG)_v3 (1).pptx
HassanMohammed730118
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
Functions in Python Programming Language
BeulahS2
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
01-introduction to the ProcessDesign.pdf
StiveBrack
 
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
Tesia Dobrydnia - An Avid Hiker And Backpacker
Tesia Dobrydnia
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
Precooling and Refrigerated storage.pptx
ThongamSunita
 
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 

Kgdb kdb modesetting

  • 1. © 2009 Wind River Merging KGDB KDB and Kernel Mode Setting Jason Wessel – Wind River Jesse Barnes - Intel
  • 2. © 2009 Wind River The Glossary • KGDB – Kernel GDB remote interface – KGDB core merged to mainline kernel in 2.6.26 – Generic gdb serial interface for single or multi processor systems, where gdb provides a source view of the system – Works only with a uart based console driver • KDB – Kernel debugger – Never merged to mainline kernel and not likely to merge as is – Supports only i386 and x86_64 – Provides a simple debugger via the system console or a serial port, with no high level source • KMS – Kernel Mode Settting – Merged to mainline kernel in 2.6.29 – Core graphics driver in the kernel provides seamless switch from console to graphics modes (vs reinitializing the HW each time)
  • 3. © 2009 Wind River The Goal – Let the MERGE BEGIN! • A simple, reliable multi-architecture debug shell • Works with graphics or serial • Ability to use kgdb or kdb • Join the KDB and KGDB communities together • Provide an API for future command expansion – Trace dumping – Disassembly – Subsystem inspection commands (vfs, network, etc)
  • 4. © 2009 Wind River An example problem • Awe MAN! If only I had a few more lines in the trace...
  • 5. © 2009 Wind River The debug shell
  • 6. © 2009 Wind River Basic KGDB design KGDB has 4 main pieces • Debug Core – Generic debug API – Handles exceptions – Syncs/saves/restores CPUs – API for SW/HW breakpoints • Arch specific KGDB – Interface to read/write registers – Arch specific exceptions and watch dogs – Single stepping interface • GDB Stub – Speaks the gdb serial protocol • Polled I/O Driver (kgdboc / kgdboe / kgdbou / kgdb_8250) – Uses the console UART driver to multiplex a single serial line – Another host's gdb connects to this port Debug Core GDB Stub Polled I/O Driver Arch Specific KGDB
  • 7. © 2009 Wind River Basic KDB design KDB has lots of parts 129 files changed, 57952 insertions(+), 10 deletions(-) Low Level Arch Specific exceptions kdb_main kdb_io Polled Keyboard driver Polled serial driver Assembly set_jmp() long_jmp() Back tracer Other modules kdump etc... disassembler Single Step BOOM! Crash! Thunk! Splat!
  • 8. © 2009 Wind River Merging KDB & KGDB • The polled keyboard driver hooks into kgdboc • The kdb_main, kdb_io and cmd handlers hook straight to the debug core • gdb can use “monitor ...cmd...” to issue kdb cmds • KDB got all the architecture specific pieces removed – KDB core = 27 files changed, 6521 insertions(+), 10 deletions(-) – KGDB changes = 9 files changed, 154 insertions(+), 31 deletions(-) Debug Core kdb_main and kdb_io Polled I/O Driver KGDBOC Arch Specific KGDB GDB Stub KDB Polled Keyboard driver
  • 9. © 2009 Wind River KMS (kernel mode setting) basics • Mode setting refers to changing the graphics console display characteristics, such as the display type/size, screen blanking and graphics hw management • Mode setting in userspace causes issues: – suspend/resume – interaction with kernel drivers – Ability to change from X to console on crash (BOSD) • KMS paves the way for flicker free console switching • Adding in console debugger support becomes desirable to analyse a crash or inspect the system • The hard part lies in making KMS work without locks – Take an exception – Transition to console atomically – Run kdb – Restore graphics – Resume system
  • 10. © 2009 Wind River kgdb + kdb + kms • KMS bolts into the debugger via kgdboc entry/exit call backs • Configuration of using KMS is dynamic through kgdboc Debug Core kdb kgdboc Arch Specific KGDB GDB Stub KMS Hooks
  • 11. © 2009 Wind River Demonstration time • KGDB, KDB and KMS in < 60 seconds – http://www.youtube.com/watch?v=PDds73yDCNo
  • 12. © 2009 Wind River But wait there's MORE! How about kgdb + kdb + kms + usb serial
  • 13. © 2009 Wind River Moving beyond the prototype • The first priority is to finish cleaning kdb core and post to LKML – kernel/kgdb.c → kernel/debug/debug_core.c and gdbstub.c – kernel/debug/kdb/* – Rename arch/*/kernel/kgdb.c → arch/*/kernel/debug_arch.c • For KMS, there are certainly problems with the locks +++ b/drivers/gpu/drm/drm_crtc.c +#ifdef CONFIG_KGDB + if (atomic_read(&kgdb_active) == -1) +#endif + mutex_lock(&dev->mode_config.idr_mutex); • KMS needs some generic debugger API work – Only the Intel 915 works today with kdb – Jesse suggested the possibility for a dedicated debug console
  • 14. © 2009 Wind River Moving beyond the prototype • The USB keyboard driver is UGLY!!! – The low level uchi/ohci/ehci are modified to allow for polloing and pulling off packets of the keyboard type only • Anyone want to help with an “alternatives” implementation? – The debugger needs to change some code paths after entry – The debugger should stay out of the way otherwise • Low Level exception support – The debug core needs the first right of breakpoint handling – Perhaps code “alternatives”? • panic() should allow a debug hook before calling smp_send_stop()
  • 15. © 2009 Wind River Nested Exception Support • Prototype hack for debugging part of the code used by the debugger proves useful – It was possible to debug the KMS code with kgdb so long as on the second exception kgdb jumps directly into the debug core – Without the “hack” the debug core prints a stack dump an panics • The kgdb_ll_trap() was introduced by kdb to allow the debug core to step through an atomic_notifier_call_chain • It is now a TODO item to consider nested exception debugging because you can also debug parts of the debugger itself
  • 16. © 2009 Wind River Displaced Stepping? • Problems without displaced stepping – Missed breakpoint • free all cpus and wait for a thread to get scheduled which uses HW single stepping – Deadlock on lock • single stepping by freeing only one CPU, dead locks on any lock held by a frozen CPU • Displaced stepping is leaving a break point planted and executing the original instruction out of line – An experimental patch modifies kprobes to plant a probe to single step a kernel thread – The down side is you cannot debug some further small pieces of the kernel
  • 17. © 2009 Wind River Mainline for kgdboe someday? • Today's kgdboe has a major short coming, in that it is not robust • Network drivers can be in a state where it is impossible to use them safely from the exception context (preempted with locks held) • Possible solutions: – Perhaps a dedicated queue in the HW is the answer (e1000e) – While it would require a dedicated ethernet interface, you could use a self contained, exception safe network stack – A redesigned poll interface
  • 18. © 2009 Wind River kgdbou (kgdb over usb) • It is on the mile long todo list :-) • First up is work around improved USB console support – 2.6.31 - merged USB sysrq support – 2.6.32 - USB EHCI debug port console (supports early_printk) – Stable USB console support is a work in progress – kgdbou present state is considered “too much of a hack” • Kgdb integration can proceed after the console support – On the demo machine there are if (kgdb_activate...) checks in the hot path which would need to resolved by design
  • 19. © 2009 Wind River The kernel debugger and the future • We want to unite the all the of the kernel debugger folks • Send patches to [email protected] • The kgdb wiki is slated to launch in late September http://kgdb.wiki.kernel.org/ Special Thanks – Jesse Barnes - for his KMS code – Martin Hicks - (KDB maintainer) for kdb cleanup patches

Editor's Notes

  • #2: The title of your presentation should be short and direct. The subtitle of your presentation should consist of the presenter’s name and title.