Donation from Maigurs Stalidzans. Thanks!
[ikiwiki.git] / docs / developer / C_Development_Under_DragonFly_BSD-Volume_3_Developing_the_DragonFly_BSD_Kernel.mdwn
1 # C Development Under DragonFly BSD Volume 3: Developing the DragonFly BSD Kernel 
2
3
4 [[!toc  levels=2]]
5
6
7
8
9 ## Working on the kernel 
10
11
12
13
14 * Discuss how kernel development differs from userland development
15
16
17 * What subsystems do we provide
18
19
20 * Where are various files
21
22
23 * How to debug a kernel
24
25
26 * Overview, exercises and examples 
27
28
29
30
31
32
33
34 ### Section Notes 
35
36
37
38 ### Debugging threads in a kernel 
39
40
41
42 #### Notes from a thread which should be converted 
43
44
45
46
47
48     
49
50     :Richard Nyberg wrote:
51
52     :> I often use gdb's proc command to switch between different processes
53
54     :> when debugging kernel cores. Now I want to debug a kernel thread
55
56     :> and it doesn't seem to work. Does anyone know how to switch to a
57
58     :> kernel thread? Maybe proc could be tweaked to work for threads too.
59
60     :>
61
62     :Replying to myself...
63
64     : 
65
66     :I RTFS and it looked like proc should work with kernel threads.
67
68     :The problem seems to be that the threads td_pcb is invalid.
69
70     :
71
72     :Example:
73
74     
75
76     Matt wrote,
77
78     
79
80     Theoretically you can give the 'proc' command a thread address (not a
81
82     proc address, a thread address) and it should switch to it.
83
84     
85
86     But Joerg's recent upgrades of gdb seem to have broken some things
87
88     that had been working before.
89
90     
91
92     Pure kernel threads do not have PCBs in the conventional sense.  The
93
94     thread state is pushed onto the stack for the switch/restore instead.
95
96     Most of the pcb structure will be unused for a kernel thread.
97
98
99