1 diff -Nurp linux-2.6.22-590/arch/i386/Kconfig.debug linux-2.6.22-600/arch/i386/Kconfig.debug
2 --- linux-2.6.22-590/arch/i386/Kconfig.debug 2007-07-09 01:32:17.000000000 +0200
3 +++ linux-2.6.22-600/arch/i386/Kconfig.debug 2008-04-09 18:16:14.000000000 +0200
4 @@ -85,4 +85,82 @@ config DOUBLEFAULT
5 option saves about 4k and might cause you much additional grey
9 + bool "Built-in Kernel Debugger support"
10 + depends on DEBUG_KERNEL
14 + This option provides a built-in kernel debugger. The built-in
15 + kernel debugger contains commands which allow memory to be examined,
16 + instructions to be disassembled and breakpoints to be set. For details,
17 + see Documentation/kdb/kdb.mm and the manual pages kdb_bt, kdb_ss, etc.
18 + Kdb can also be used via the serial port. Set up the system to
19 + have a serial console (see Documentation/serial-console.txt).
20 + The key sequence <escape>KDB on the serial port will cause the
21 + kernel debugger to be entered with input from the serial port and
22 + output to the serial console. If unsure, say N.
25 + tristate "KDB modules"
28 + KDB can be extended by adding your own modules, in directory
29 + kdb/modules. This option selects the way that these modules should
30 + be compiled, as free standing modules (select M) or built into the
31 + kernel (select Y). If unsure say M.
34 + bool "KDB off by default"
37 + Normally kdb is activated by default, as long as CONFIG_KDB is set.
38 + If you want to ship a kernel with kdb support but only have kdb
39 + turned on when the user requests it then select this option. When
40 + compiled with CONFIG_KDB_OFF, kdb ignores all events unless you boot
41 + with kdb=on or you echo "1" > /proc/sys/kernel/kdb. This option also
42 + works in reverse, if kdb is normally activated, you can boot with
43 + kdb=off or echo "0" > /proc/sys/kernel/kdb to deactivate kdb. If
46 +config KDB_CONTINUE_CATASTROPHIC
47 + int "KDB continues after catastrophic errors"
51 + This integer controls the behaviour of kdb when the kernel gets a
52 + catastrophic error, i.e. for a panic, oops, NMI or other watchdog
53 + tripping. CONFIG_KDB_CONTINUE_CATASTROPHIC interacts with
54 + /proc/sys/kernel/kdb and CONFIG_LKCD_DUMP (if your kernel has the
56 + When KDB is active (/proc/sys/kernel/kdb == 1) and a catastrophic
57 + error occurs, nothing extra happens until you type 'go'.
58 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 0 (default). The first time
59 + you type 'go', kdb warns you. The second time you type 'go', KDB
60 + tries to continue - no guarantees that the kernel is still usable.
61 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 1. KDB tries to continue - no
62 + guarantees that the kernel is still usable.
63 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 2. If your kernel has the LKCD
64 + patch and LKCD is configured to take a dump then KDB forces a dump.
65 + Whether or not a dump is taken, KDB forces a reboot.
66 + When KDB is not active (/proc/sys/kernel/kdb == 0) and a catastrophic
67 + error occurs, the following steps are automatic, no human
68 + intervention is required.
69 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 0 (default) or 1. KDB attempts
70 + to continue - no guarantees that the kernel is still usable.
71 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 2. If your kernel has the LKCD
72 + patch and LKCD is configured to take a dump then KDB automatically
73 + forces a dump. Whether or not a dump is taken, KDB forces a
75 + If you are not sure, say 0. Read Documentation/kdb/dump.txt before
79 + bool "Support for USB Keyboard in KDB (OHCI only)"
80 + depends on KDB && USB_OHCI_HCD
82 + If you want to use kdb from a OHCI USB keyboard then say Y here. If you
83 + say N then kdb can only be used from a PC (AT) keyboard or a serial
87 diff -Nurp linux-2.6.22-590/arch/i386/kdb/ChangeLog linux-2.6.22-600/arch/i386/kdb/ChangeLog
88 --- linux-2.6.22-590/arch/i386/kdb/ChangeLog 1970-01-01 01:00:00.000000000 +0100
89 +++ linux-2.6.22-600/arch/i386/kdb/ChangeLog 2008-04-09 18:16:14.000000000 +0200
91 +2007-07-26 Keith Owens <kaos@sgi.com>
93 + * New x86 backtrace code.
94 + * kdb v4.4-2.6.22-i386-2.
96 +2007-07-09 Keith Owens <kaos@sgi.com>
98 + * kdb v4.4-2.6.22-i386-1.
100 +2007-07-02 Keith Owens <kaos@sgi.com>
102 + * kdb v4.4-2.6.22-rc7-i386-1.
104 +2007-06-20 Keith Owens <kaos@sgi.com>
106 + * kdb v4.4-2.6.22-rc5-i386-1.
108 +2007-06-08 Keith Owens <kaos@sgi.com>
110 + * kdb v4.4-2.6.22-rc4-i386-1.
112 +2007-05-28 Keith Owens <kaos@sgi.com>
114 + * kdb v4.4-2.6.22-rc3-i386-1.
116 +2007-05-22 Keith Owens <kaos@sgi.com>
118 + * Register KDBENTER_VECTOR early on the boot cpu.
119 + * kdb v4.4-2.6.22-rc2-i386-2.
121 +2007-05-22 Keith Owens <kaos@sgi.com>
123 + * kdb v4.4-2.6.22-rc2-i386-1.
125 +2007-05-22 Keith Owens <kaos@sgi.com>
127 + * kdb v4.4-2.6.22-rc1-i386-1.
129 +2007-05-17 Keith Owens <kaos@sgi.com>
131 + * Update dumpregs comments for rdmsr and wrmsr commands.
132 + Bernardo Innocenti.
133 + * kdb v4.4-2.6.21-i386-3.
135 +2007-05-15 Keith Owens <kaos@sgi.com>
137 + * Change kdba_late_init to kdba_arch_init so KDB_ENTER() can be used
139 + * kdb v4.4-2.6.21-i386-2.
141 +2007-04-29 Keith Owens <kaos@sgi.com>
143 + * kdb v4.4-2.6.21-i386-1.
145 +2007-04-16 Keith Owens <kaos@sgi.com>
147 + * kdb v4.4-2.6.21-rc7-i386-1.
149 +2007-04-10 Keith Owens <kaos@sgi.com>
151 + * kdb v4.4-2.6.21-rc6-i386-1.
153 +2007-04-02 Keith Owens <kaos@sgi.com>
155 + * kdb v4.4-2.6.21-rc5-i386-1.
157 +2007-03-19 Keith Owens <kaos@sgi.com>
159 + * kdb v4.4-2.6.21-rc4-i386-1.
161 +2007-03-14 Keith Owens <kaos@sgi.com>
163 + * kdb v4.4-2.6.21-rc3-i386-1.
165 +2007-03-14 Keith Owens <kaos@sgi.com>
167 + * kdb v4.4-2.6.21-rc2-i386-1.
169 +2007-03-01 Keith Owens <kaos@sgi.com>
171 + * kdb v4.4-2.6.21-rc1-i386-1.
173 +2007-03-01 Keith Owens <kaos@sgi.com>
175 + * Remove sparse warnings.
176 + * kdb v4.4-2.6.20-i386-3.
178 +2007-02-16 Keith Owens <kaos@sgi.com>
180 + * Initialise variable bits of struct disassemble_info each time.
181 + * kdb v4.4-2.6.20-i386-2.
183 +2007-02-06 Keith Owens <kaos@sgi.com>
185 + * kdb v4.4-2.6.20-i386-1.
187 +2007-02-01 Keith Owens <kaos@sgi.com>
189 + * kdb v4.4-2.6.20-rc7-i386-1.
191 +2007-01-08 Keith Owens <kaos@sgi.com>
193 + * kdb v4.4-2.6.20-rc4-i386-1.
195 +2007-01-02 Keith Owens <kaos@sgi.com>
197 + * kdb v4.4-2.6.20-rc3-i386-1.
199 +2006-12-20 Keith Owens <kaos@sgi.com>
201 + * kdb v4.4-2.6.20-rc1-i386-1.
203 +2006-11-30 Keith Owens <kaos@sgi.com>
205 + * kdb v4.4-2.6.19-i386-1.
207 +2006-11-27 Keith Owens <kaos@sgi.com>
209 + * Only use VT keyboard if the command line allows it and ACPI indicates
210 + that there is an i8042.
211 + * kdb v4.4-2.6.19-rc6-i386-2.
213 +2006-11-20 Keith Owens <kaos@sgi.com>
215 + * kdb v4.4-2.6.19-rc6-i386-1.
217 +2006-11-09 Keith Owens <kaos@sgi.com>
219 + * Change kdb() to fastcall.
220 + * Add unwind info to kdb_call(). Steve Lord.
221 + * Only use VT console if the command line allows it.
222 + * kdb v4.4-2.6.19-rc5-i386-2.
224 +2006-11-08 Keith Owens <kaos@sgi.com>
226 + * kdb v4.4-2.6.19-rc5-i386-1.
228 +2006-11-01 Keith Owens <kaos@sgi.com>
230 + * kdb v4.4-2.6.19-rc4-i386-1.
232 +2006-10-24 Keith Owens <kaos@sgi.com>
234 + * kdb v4.4-2.6.19-rc3-i386-1.
236 +2006-10-24 Keith Owens <kaos@sgi.com>
238 + * Remove redundant regs and envp parameters.
239 + * kdb v4.4-2.6.19-rc2-i386-2.
241 +2006-10-18 Keith Owens <kaos@sgi.com>
243 + * kdb v4.4-2.6.19-rc2-i386-1.
245 +2006-10-11 Keith Owens <kaos@sgi.com>
247 + * Move kdbm_x86.c from the i386 to the common KDB patch.
248 + * Make the KDBENTER_VECTOR an interrupt gate instead of a trap gate, it
249 + simplifies the code and disables interrupts on KDBENTER().
250 + * Exclude the KDBENTER_VECTOR from irq assignment.
251 + * kdb v4.4-2.6.19-rc1-i386-2.
253 +2006-10-09 Keith Owens <kaos@sgi.com>
255 + * kdb v4.4-2.6.19-rc1-i386-1.
257 +2006-10-06 Keith Owens <kaos@sgi.com>
259 + * Remove #include <linux/config.h>
260 + * kdb v4.4-2.6.18-i386-2.
262 +2006-09-20 Keith Owens <kaos@sgi.com>
264 + * kdb v4.4-2.6.18-i386-1.
266 +2006-09-15 Keith Owens <kaos@sgi.com>
268 + * kdb v4.4-2.6.18-rc7-i386-1.
270 +2006-08-30 Keith Owens <kaos@sgi.com>
272 + * Add warning for problems when following alternate stacks.
273 + * kdb v4.4-2.6.18-rc5-i386-3.
275 +2006-08-29 Keith Owens <kaos@sgi.com>
277 + * Rewrite all backtrace code.
278 + * kdb v4.4-2.6.18-rc5-i386-2.
280 +2006-08-28 Keith Owens <kaos@sgi.com>
282 + * kdb v4.4-2.6.18-rc5-i386-1.
284 +2006-08-08 Keith Owens <kaos@sgi.com>
286 + * kdb v4.4-2.6.18-rc4-i386-1.
288 +2006-08-04 Keith Owens <kaos@sgi.com>
290 + * kdb v4.4-2.6.18-rc3-i386-1.
292 +2006-07-18 Keith Owens <kaos@sgi.com>
294 + * kdb v4.4-2.6.18-rc2-i386-1.
296 +2006-07-12 Keith Owens <kaos@sgi.com>
298 + * Remove dead KDB_REASON codes.
300 + * kdb v4.4-2.6.18-rc1-i386-2.
302 +2006-07-07 Keith Owens <kaos@sgi.com>
304 + * kdb v4.4-2.6.18-rc1-i386-1.
306 +2006-07-04 Keith Owens <kaos@sgi.com>
308 + * Make KDB rendezvous on i386 a two stage approach.
309 + * Clean up generation of KDB interrupt code.
310 + * Move smp_kdb_stop() and smp_kdb_interrupt() to kdbasupport.c.
311 + * Move setting of interrupt traps to kdbasupport.c.
312 + * Remove KDB hooks from arch/i386/kernel smp.c, smpboot.c, i8259.c,
314 + * Add KDB_REASON_CPU_UP support.
315 + * Move per cpu setup to kdba_cpu_up().
316 + * Rework support for 4K stacks to make backtrace more accurate.
317 + * Add BTSP option to get the full backtrace, including kdb routines.
318 + * Delete kdba_enable_mce, architectures now do their own setup.
319 + * Delete kdba_enable_lbr, kdba_disable_lbr, kdba_print_lbr,
320 + page_fault_mca. Only ever implemented on x86, difficult to maintain
321 + and rarely used in the field.
322 + * Replace #ifdef KDB_HAVE_LONGJMP with #ifdef kdba_setjmp.
323 + * kdb v4.4-2.6.17-i386-2.
325 +2006-06-19 Keith Owens <kaos@sgi.com>
327 + * kdb v4.4-2.6.17-i386-1.
329 +2006-05-25 Keith Owens <kaos@sgi.com>
331 + * kdb v4.4-2.6.17-rc5-i386-1.
333 +2006-05-15 Keith Owens <kaos@sgi.com>
335 + * Refresh bfd related files from binutils 2.16.91.0.2.
336 + * kdb v4.4-2.6.17-rc4-i386-2.
338 +2006-05-12 Keith Owens <kaos@sgi.com>
340 + * kdb v4.4-2.6.17-rc4-i386-1.
342 +2006-04-28 Keith Owens <kaos@sgi.com>
344 + * kdb v4.4-2.6.17-rc3-i386-1.
346 +2006-04-22 Keith Owens <kaos@sgi.com>
348 + * kdb v4.4-2.6.17-rc2-i386-1.
350 +2006-04-11 Keith Owens <kaos@sgi.com>
352 + * kdb v4.4-2.6.17-rc1-i386-1.
354 +2006-03-30 Keith Owens <kaos@sgi.com>
356 + * Change CONFIG_LKCD to CONFIG_LKCD_DUMP.
357 + * kdb v4.4-2.6.16-i386-3.
359 +2006-03-24 Keith Owens <kaos@sgi.com>
361 + * Define a dummy kdba_wait_for_cpus().
362 + * kdb v4.4-2.6.16-i386-2.
364 +2006-03-21 Keith Owens <kaos@sgi.com>
366 + * kdb v4.4-2.6.16-i386-1.
368 +2006-03-14 Nathan Scott <nathans@sgi.com>
370 + * kdb v4.4-2.6.16-rc6-i386-1.
372 +2006-02-28 Nathan Scott <nathans@sgi.com>
374 + * kdb v4.4-2.6.16-rc5-i386-1.
376 +2006-02-20 Nathan Scott <nathans@sgi.com>
378 + * kdb v4.4-2.6.16-rc4-i386-1.
380 +2006-02-06 Keith Owens <kaos@sgi.com>
382 + * Change CONFIG_CRASH_DUMP to CONFIG_LKCD.
383 + * kdb v4.4-2.6.16-rc2-i386-2.
385 +2006-02-06 Keith Owens <kaos@sgi.com>
387 + * kdb v4.4-2.6.16-rc2-i386-1.
389 +2006-01-18 Keith Owens <kaos@sgi.com>
391 + * kdb v4.4-2.6.16-rc1-i386-1.
393 +2006-01-08 Keith Owens <kaos@sgi.com>
395 + * Add DIE_KDEBUG_ENTER and DIE_KDEBUG_LEAVE to notify_die.
396 + * kdb v4.4-2.6.15-i386-2.
398 +2006-01-04 Keith Owens <kaos@sgi.com>
400 + * Remove some inlines and the last vestige of CONFIG_NUMA_REPLICATE.
401 + * Read the keyboard acknowledgment after sending a character. SuSE
403 + * kdb v4.4-2.6.15-i386-1.
405 +2005-12-25 Keith Owens <kaos@sgi.com>
407 + * kdb v4.4-2.6.15-rc7-i386-1.
409 +2005-12-20 Keith Owens <kaos@sgi.com>
411 + * kdb v4.4-2.6.15-rc6-i386-1.
413 +2005-12-05 Keith Owens <kaos@sgi.com>
415 + * kdb v4.4-2.6.15-rc5-i386-1.
417 +2005-12-02 Keith Owens <kaos@sgi.com>
419 + * kdb v4.4-2.6.15-rc4-i386-1.
421 +2005-11-30 Keith Owens <kaos@sgi.com>
423 + * kdb v4.4-2.6.15-rc3-i386-1.
425 +2005-11-21 Keith Owens <kaos@sgi.com>
427 + * kdb v4.4-2.6.15-rc2-i386-1.
429 +2005-11-15 Keith Owens <kaos@sgi.com>
431 + * kdb v4.4-2.6.15-rc1-i386-1.
433 +2005-10-28 Keith Owens <kaos@sgi.com>
435 + * kdb v4.4-2.6.14-i386-1.
437 +2005-10-21 Keith Owens <kaos@sgi.com>
439 + * kdb v4.4-2.6.14-rc5-i386-1.
441 +2005-10-11 Keith Owens <kaos@sgi.com>
443 + * kdb v4.4-2.6.14-rc4-i386-1.
445 +2005-10-04 Keith Owens <kaos@sgi.com>
447 + * kdb v4.4-2.6.14-rc3-i386-1.
449 +2005-09-21 Keith Owens <kaos@sgi.com>
451 + * Support kdb_current_task in register display and modify commands.
452 + * kdb v4.4-2.6.14-rc2-i386-1.
454 +2005-09-20 Keith Owens <kaos@sgi.com>
456 + * Remove use of __STDC_VERSION__ in ansidecl.h.
457 + * kdb v4.4-2.6.14-rc1-i386-1.
459 +2005-08-29 Keith Owens <kaos@sgi.com>
461 + * kdb v4.4-2.6.13-i386-1.
463 +2005-08-24 Keith Owens <kaos@sgi.com>
465 + * kdb v4.4-2.6.13-rc7-i386-1.
467 +2005-08-08 Keith Owens <kaos@sgi.com>
469 + * kdb v4.4-2.6.13-rc6-i386-1.
471 +2005-08-02 Keith Owens <kaos@sgi.com>
473 + * kdb v4.4-2.6.13-rc5-i386-1.
475 +2005-07-30 Keith Owens <kaos@sgi.com>
477 + * kdb v4.4-2.6.13-rc4-i386-1.
479 +2005-07-22 Keith Owens <kaos@sgi.com>
481 + * Compile fix for kprobes.
482 + * kdb v4.4-2.6.13-rc3-i386-2.
484 +2005-07-19 Keith Owens <kaos@sgi.com>
486 + * Add support for USB keyboard (OHCI only). Aaron Young, SGI.
487 + * kdb v4.4-2.6.13-rc3-i386-1.
489 +2005-07-08 Keith Owens <kaos@sgi.com>
491 + * kdb v4.4-2.6.13-rc2-i386-1.
493 +2005-07-01 Keith Owens <kaos@sgi.com>
495 + * kdb v4.4-2.6.13-rc1-i386-1.
497 +2005-06-19 Keith Owens <kaos@sgi.com>
499 + * gcc 4 compile fix, remove extern kdb_hardbreaks. Steve Lord.
500 + * kdb v4.4-2.6.12-i386-2.
502 +2005-06-18 Keith Owens <kaos@sgi.com>
504 + * kdb v4.4-2.6.12-i386-1.
506 +2005-06-08 Keith Owens <kaos@sgi.com>
508 + * kdb v4.4-2.6.12-rc6-i386-1.
510 +2005-05-25 Keith Owens <kaos@sgi.com>
512 + * kdb v4.4-2.6.12-rc5-i386-1.
514 +2005-05-08 Keith Owens <kaos@sgi.com>
516 + * kdb v4.4-2.6.12-rc4-i386-1.
518 +2005-04-21 Keith Owens <kaos@sgi.com>
520 + * kdb v4.4-2.6.12-rc3-i386-1.
522 +2005-04-06 Keith Owens <kaos@sgi.com>
524 + * kdb v4.4-2.6.12-rc2-i386-1.
526 +2005-03-29 Keith Owens <kaos@sgi.com>
528 + * Replace __copy_to_user with __copy_to_user_inatomic.
529 + * kdb v4.4-2.6.12-rc1-i386-1.
531 +2005-03-08 Keith Owens <kaos@sgi.com>
533 + * Coexistence patches for lkcd.
534 + * kdb v4.4-2.6.11-i386-2.
536 +2005-03-03 Keith Owens <kaos@sgi.com>
538 + * kdb v4.4-2.6.11-i386-1.
540 +2005-02-14 Keith Owens <kaos@sgi.com>
542 + * kdb v4.4-2.6.11-rc4-i386-1.
544 +2005-02-08 Keith Owens <kaos@sgi.com>
546 + * kdb v4.4-2.6.11-rc3-bk4-i386-1.
548 +2005-02-03 Keith Owens <kaos@sgi.com>
550 + * kdb v4.4-2.6.11-rc3-i386-1.
552 +2005-01-27 Keith Owens <kaos@sgi.com>
554 + * kdb v4.4-2.6.11-rc2-i386-1.
556 +2005-01-12 Keith Owens <kaos@sgi.com>
558 + * kdb v4.4-2.6.11-rc1-i386-1.
560 +2004-12-25 Keith Owens <kaos@sgi.com>
562 + * kdb v4.4-2.6.10-i386-1.
564 +2004-12-07 Keith Owens <kaos@sgi.com>
566 + * kdb v4.4-2.6.10-rc3-i386-1.
568 +2004-11-23 Keith Owens <kaos@sgi.com>
570 + * Coexist with asmlinkage/fastcall changes.
571 + * kdb v4.4-2.6.10-rc2-i386-1.
573 +2004-10-29 Keith Owens <kaos@sgi.com>
575 + * Handle change defintions for hard and soft irq context.
576 + * Make stack switch in kdb backtrace look more like the oops output.
577 + * kdb v4.4-2.6.10-rc1-i386-1.
579 +2004-10-19 Keith Owens <kaos@sgi.com>
581 + * kdb v4.4-2.6.9-i386-1.
583 +2004-10-12 Keith Owens <kaos@sgi.com>
585 + * kdb v4.4-2.6.9-rc4-i386-1.
587 +2004-10-01 Keith Owens <kaos@sgi.com>
589 + * kdb v4.4-2.6.9-rc3-i386-1.
591 +2004-09-30 Keith Owens <kaos@sgi.com>
593 + * Add stackdepth command.
594 + * Handle backtrace with separate soft and hard irq stacks
596 + * Work around RESTORE_ALL macro, which can only be used once.
597 + * Export kdba_dumpregs. Bryan Cardillo, UPenn.
598 + * kdb v4.4-2.6.9-rc2-i386-2.
600 +2004-09-14 Keith Owens <kaos@sgi.com>
602 + * kdb v4.4-2.6.9-rc2-i386-1.
604 +2004-08-27 Keith Owens <kaos@sgi.com>
606 + * kdb v4.4-2.6.9-rc1-i386-1.
608 +2004-08-14 Keith Owens <kaos@sgi.com>
610 + * kdb v4.4-2.6.8-i386-1.
612 +2004-08-12 Keith Owens <kaos@sgi.com>
614 + * kdb v4.4-2.6.8-rc4-i386-1.
616 +2004-08-04 Keith Owens <kaos@sgi.com>
618 + * kdb v4.4-2.6.8-rc3-i386-1.
620 +2004-07-18 Keith Owens <kaos@sgi.com>
622 + * kdb v4.4-2.6.8-rc2-i386-1.
624 +2004-07-12 Keith Owens <kaos@sgi.com>
626 + * kdb v4.4-2.6.8-rc1-i386-1.
628 +2004-06-16 Keith Owens <kaos@sgi.com>
630 + * kdb v4.4-2.6.7-i386-1.
632 +2004-06-10 Keith Owens <kaos@sgi.com>
634 + * kdb v4.4-2.6.7-rc3-i386-1.
636 +2004-06-09 Keith Owens <kaos@sgi.com>
638 + * Namespace clean up. Mark code/variables as static when it is only
639 + used in one file, delete dead code/variables.
640 + * kdb v4.4-2.6.7-rc2-i386-3.
642 +2004-06-08 Keith Owens <kaos@sgi.com>
644 + * Whitespace clean up, no code changes.
645 + * kdb v4.4-2.6.7-rc2-i386-2.
647 +2004-06-07 Keith Owens <kaos@sgi.com>
649 + * Force KALLSYMS and KALLSYMS_ALL for CONFIG_KDB.
650 + * kdb v4.4-2.6.7-rc2-i386-1.
652 +2004-06-06 Keith Owens <kaos@sgi.com>
654 + * Correct Kconfig help text.
655 + * Coexist with CONFIG_REGPARM.
656 + * Add standard archkdb commands.
657 + * Move kdb_{get,put}userarea_size definitions to linux/kdb.h.
658 + * kdb v4.4-2.6.6-i386-2.
660 +2004-05-23 Keith Owens <kaos@sgi.com>
662 + * Move bfd.h and ansidecl.h from arch/$(ARCH)/kdb to include/asm-$(ARCH).
663 + * Update copyright notices.
664 + * kdb v4.4-2.6.6-i386-1.
666 +2004-05-10 Keith Owens <kaos@sgi.com>
668 + * kdb v4.3-2.6.6-i386-1.
670 +2004-05-06 Keith Owens <kaos@sgi.com>
672 + * kdb v4.3-2.6.6-rc3-i386-1.
674 +2004-05-06 Keith Owens <kaos@sgi.com>
676 + * kdb v4.3-2.6.6-rc2-i386-1.
678 +2004-04-30 Keith Owens <kaos@sgi.com>
680 + * kdb v4.3-2.6.6-rc1-i386-1.
682 +2004-04-05 Keith Owens <kaos@sgi.com>
684 + * kdb v4.3-2.6-5-i386-1.
686 +2004-02-29 Keith Owens <kaos@sgi.com>
688 + * kdb v4.3-2.6-4-rc1-i386-1.
690 +2004-02-18 Keith Owens <kaos@sgi.com>
692 + * kdb v4.3-2.6-3-i386-1.
694 +2004-02-17 Keith Owens <kaos@sgi.com>
696 + * Pick up changes from Jim Houston for 2.6.
697 + * Sync with kdb v4.3-2.4.25-rc1-i386-1.
698 + * Adjust for LDT changes in i386 mainline.
699 + * Convert longjmp buffers from static to dynamic allocation, for large
701 + * Do not use USB keyboard if it has not been probed.
702 + * Do not print section data, 2.6 kallsyms does not support sections :(.
703 + * kdb v4.3-2.6-3-rc3-i386-1.
705 +2003-08-29 Keith Owens <kaos@sgi.com>
707 + * kdb v4.3-2.4.22-i386-1.
709 +2003-08-05 Keith Owens <kaos@sgi.com>
711 + * Remove duplicate setting of trap for machine_check.
712 + * Only reset keyboard when CONFIG_VT_CONSOLE is defined.
714 +2003-07-27 Keith Owens <kaos@sgi.com>
716 + * kdb v4.3-2.4.22-pre8-i386-5.
718 +2003-07-20 Keith Owens <kaos@sgi.com>
720 + * Remove compile warning on x86 commands.
721 + * kdb v4.3-2.4.21-i386-5.
723 +2003-07-08 Keith Owens <kaos@sgi.com>
725 + * Add new x86 commands - rdv, gdt, idt, ldt, ldtp, ptex.
726 + Vamsi Krishna S., IBM.
727 + * kdb v4.3-2.4.21-i386-4.
729 +2003-07-01 Keith Owens <kaos@sgi.com>
731 + * Convert kdba_find_return() to two passes to reduce false positives.
732 + * Correct jmp disp8 offset calculation for out of line lock code.
733 + * Use NMI for kdb IPI in clustered APIC mode. Sachin Sant, IBM.
734 + * kdb v4.3-2.4.21-i386-3.
736 +2003-06-23 Keith Owens <kaos@sgi.com>
738 + * Sync with XFS 2.4.21 tree.
739 + * kdb v4.3-2.4.21-i386-2.
741 +2003-06-20 Keith Owens <kaos@sgi.com>
743 + * kdb v4.3-2.4.21-i386-1.
745 +2003-06-20 Keith Owens <kaos@sgi.com>
747 + * Add CONFIG_KDB_CONTINUE_CATASTROPHIC.
748 + * Correct KDB_ENTER() definition.
749 + * kdb v4.3-2.4.20-i386-1.
751 +2003-05-02 Keith Owens <kaos@sgi.com>
753 + * Add kdba_fp_value().
754 + * Limit backtrace size to catch loops.
755 + * Add read/write access to user pages. Vamsi Krishna S., IBM
756 + * Clean up USB keyboard support. Steven Dake.
757 + * kdb v4.2-2.4.20-i386-1.
759 +2003-04-04 Keith Owens <kaos@sgi.com>
761 + * Workarounds for scheduler bugs.
762 + * kdb v4.1-2.4.20-i386-1.
764 +2003-03-16 Keith Owens <kaos@sgi.com>
766 + * Each cpu saves its state as it enters kdb or before it enters code
767 + which cannot call kdb, converting kdb from a pull to a push model.
768 + * Clean up kdb interaction with CONFIG_SERIAL_CONSOLE.
769 + * Removal of special cases for i386 backtrace from common code
770 + simplifies the architecture code.
771 + * Add command to dump i386 struct pt_regs.
772 + * kdb v4.0-2.4.20-i386-1.
774 +2003-02-03 Keith Owens <kaos@sgi.com>
776 + * Register kdb commands early.
777 + * Handle KDB_ENTER() when kdb=off.
778 + * Optimize __kdba_getarea_size when width is a constant.
779 + * Decode oops via kallsyms if it is available.
780 + * Update copyright notices to 2003.
781 + * Handle call *disp32(%reg) in backtrace.
782 + * Correct keyboard freeze. Ashish Kalra.
783 + * Add command history and editing. Sonic Zhang.
784 + * kdb_toggleled is conditional on KDB_BLINK_LED. Bernhard Fischer.
785 + * Allow tab on serial line for symbol completion.
786 + * Ignore KDB_ENTER() when kdb is already running.
787 + * kdb v3.0-2.4.20-i386-1.
789 +2002-11-29 Keith Owens <kaos@sgi.com>
791 + * Upgrade to 2.4.20.
792 + * kdb v2.5-2.4.20-i386-1.
794 +2002-11-14 Keith Owens <kaos@sgi.com>
796 + * Upgrade to 2.4.20-rc1.
797 + * kdb v2.5-2.4.20-rc1-i386-1.
799 +2002-11-14 Keith Owens <kaos@sgi.com>
801 + * General clean up of handling for breakpoints and single stepping over
802 + software breakpoints.
803 + * Accept ff 1x as well as ff dx for call *(%reg) in backtrace.
804 + * kdb v2.5-2.4.19-i386-1.
806 +2002-11-01 Keith Owens <kaos@sgi.com>
808 + * Prevent SMP IRQ overwriting KDB_ENTER().
809 + * kdb v2.4-2.4.19-i386-2.
811 +2002-10-31 Keith Owens <kaos@sgi.com>
813 + * Avoid KDB_VECTOR conflict with DUMP_VECTOR.
814 + * Remove kdb_eframe_t.
815 + * Sanity check if we have pt_regs.
816 + * Remove kdba_getcurrentframe().
817 + * Reinstate missing nmi_watchdog/kdb hook.
818 + * kdb v2.4-2.4.19-i386-1.
820 +2002-10-17 Keith Owens <kaos@sgi.com>
822 + * Correct compile with CONFIG_VT_CONSOLE=n.
823 + * kdb v2.3-2.4.19-i386-5.
825 +2002-10-04 Keith Owens <kaos@sgi.com>
827 + * Add USB keyboard option.
828 + * Minimize differences between patches for 2.4 and 2.5 kernels.
829 + * kdb v2.3-2.4.19-i386-4.
831 +2002-08-10 Keith Owens <kaos@sgi.com>
833 + * Replace kdb_port with kdb_serial to support memory mapped I/O.
834 + Note: This needs kdb v2.3-2.4.19-common-2 or later.
835 + * kdb v2.3-2.4.19-i386-3.
837 +2002-08-09 Keith Owens <kaos@sgi.com>
839 + * Use -fno-optimize-sibling-calls for kdb if gcc supports it.
840 + * .text.lock does not consume an activation frame.
841 + * kdb v2.3-2.4.19-i386-2.
843 +2002-08-07 Keith Owens <kaos@sgi.com>
845 + * Upgrade to 2.4.19.
846 + * Remove individual SGI copyrights, the general SGI copyright applies.
847 + * New .text.lock name. Hugh Dickins.
848 + * Set KERNEL_CS in kdba_getcurrentframe. Hugh Dickins.
849 + * Clean up disassembly layout. Hugh Dickins, Keith Owens.
850 + * Replace hard coded stack size with THREAD_SIZE. Hugh Dickins.
851 + * Better stack layout on bt with no frame pointers. Hugh Dickins.
852 + * Make i386 IO breakpoints (bpha <address> IO) work again.
853 + Martin Wilck, Keith Owens.
854 + * Remove fixed KDB_MAX_COMMANDS size.
855 + * Add set_fs() around __copy_to_user on kernel addresses.
857 + * Position i386 for CONFIG_NUMA_REPLICATE.
858 + * kdb v2.3-2.4.19-i386-1.
860 +2002-07-09 Keith Owens <kaos@sgi.com>
862 + * Upgrade to 2.4.19-rc1.
864 +2002-06-14 Keith Owens <kaos@sgi.com>
866 + * Upgrade to 2.4.19-pre10.
867 + * kdb v2.1-2.4.19-pre10-i386-1.
869 +2002-04-09 Keith Owens <kaos@sgi.com>
871 + * Upgrade to 2.4.19-pre6.
872 + * kdb v2.1-2.4.19-pre6-i386-1.
874 +2002-02-26 Keith Owens <kaos@sgi.com>
876 + * Upgrade to 2.4.18.
877 + * kdb v2.1-2.4.18-i386-1.
879 +2002-01-18 Keith Owens <kaos@sgi.com>
881 + * Use new kdb_get/put functions.
882 + * Define kdba_{get,put}area_size functions for i386.
883 + * Remove over-engineered dblist callback functions.
884 + * Correctly handle failing call disp32 in backtrace.
885 + * Remove bp_instvalid flag, redundant code.
886 + * Remove dead code.
887 + * kdb v2.1-2.4.17-i386-1.
889 +2002-01-04 Keith Owens <kaos@sgi.com>
891 + * Sync xfs <-> kdb i386 code.
893 +2001-12-22 Keith Owens <kaos@sgi.com>
895 + * Split kdb for i386 as kdb v2.0-2.4.17-i386-1.
896 diff -Nurp linux-2.6.22-590/arch/i386/kdb/i386-dis.c linux-2.6.22-600/arch/i386/kdb/i386-dis.c
897 --- linux-2.6.22-590/arch/i386/kdb/i386-dis.c 1970-01-01 01:00:00.000000000 +0100
898 +++ linux-2.6.22-600/arch/i386/kdb/i386-dis.c 2008-04-09 18:16:14.000000000 +0200
900 +/* Print i386 instructions for GDB, the GNU debugger.
901 + Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
902 + 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
904 + This file is part of GDB.
906 + This program is free software; you can redistribute it and/or modify
907 + it under the terms of the GNU General Public License as published by
908 + the Free Software Foundation; either version 2 of the License, or
909 + (at your option) any later version.
911 + This program is distributed in the hope that it will be useful,
912 + but WITHOUT ANY WARRANTY; without even the implied warranty of
913 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
914 + GNU General Public License for more details.
916 + You should have received a copy of the GNU General Public License
917 + along with this program; if not, write to the Free Software
918 + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
920 +/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
921 + * Any trailing whitespace was removed and #ifdef/ifndef __KERNEL__ added as
923 + * Keith Owens <kaos@sgi.com> 15 May 2006
926 +/* 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
928 + modified by John Hassey (hassey@dg-rtp.dg.com)
929 + x86-64 support added by Jan Hubicka (jh@suse.cz)
930 + VIA PadLock support by Michal Ludvig (mludvig@suse.cz). */
932 +/* The main tables describing the instructions is essentially a copy
933 + of the "Opcode Map" chapter (Appendix A) of the Intel 80386
934 + Programmers Manual. Usually, there is a capital letter, followed
935 + by a small letter. The capital letter tell the addressing mode,
936 + and the small letter tells about the operand size. Refer to
937 + the Intel manual for details. */
940 +#include <linux/kernel.h>
941 +#include <linux/string.h>
942 +#include <linux/dis-asm.h>
943 +#include <linux/kdb.h>
944 +#define abort() BUG()
945 +#else /* __KERNEL__ */
946 +#include "dis-asm.h"
949 +#endif /* __KERNEL__ */
955 +#endif /* __KERNEL__ */
957 +#ifndef UNIXWARE_COMPAT
958 +/* Set non-zero for broken, compatible instructions. Set to zero for
959 + non-broken opcodes. */
960 +#define UNIXWARE_COMPAT 1
963 +static int fetch_data (struct disassemble_info *, bfd_byte *);
964 +static void ckprefix (void);
965 +static const char *prefix_name (int, int);
966 +static int print_insn (bfd_vma, disassemble_info *);
967 +static void dofloat (int);
968 +static void OP_ST (int, int);
969 +static void OP_STi (int, int);
970 +static int putop (const char *, int);
971 +static void oappend (const char *);
972 +static void append_seg (void);
973 +static void OP_indirE (int, int);
974 +static void print_operand_value (char *, int, bfd_vma);
975 +static void OP_E (int, int);
976 +static void OP_G (int, int);
977 +static bfd_vma get64 (void);
978 +static bfd_signed_vma get32 (void);
979 +static bfd_signed_vma get32s (void);
980 +static int get16 (void);
981 +static void set_op (bfd_vma, int);
982 +static void OP_REG (int, int);
983 +static void OP_IMREG (int, int);
984 +static void OP_I (int, int);
985 +static void OP_I64 (int, int);
986 +static void OP_sI (int, int);
987 +static void OP_J (int, int);
988 +static void OP_SEG (int, int);
989 +static void OP_DIR (int, int);
990 +static void OP_OFF (int, int);
991 +static void OP_OFF64 (int, int);
992 +static void ptr_reg (int, int);
993 +static void OP_ESreg (int, int);
994 +static void OP_DSreg (int, int);
995 +static void OP_C (int, int);
996 +static void OP_D (int, int);
997 +static void OP_T (int, int);
998 +static void OP_Rd (int, int);
999 +static void OP_MMX (int, int);
1000 +static void OP_XMM (int, int);
1001 +static void OP_EM (int, int);
1002 +static void OP_EX (int, int);
1003 +static void OP_MS (int, int);
1004 +static void OP_XS (int, int);
1005 +static void OP_M (int, int);
1006 +static void OP_VMX (int, int);
1007 +static void OP_0fae (int, int);
1008 +static void OP_0f07 (int, int);
1009 +static void NOP_Fixup (int, int);
1010 +static void OP_3DNowSuffix (int, int);
1011 +static void OP_SIMD_Suffix (int, int);
1012 +static void SIMD_Fixup (int, int);
1013 +static void PNI_Fixup (int, int);
1014 +static void SVME_Fixup (int, int);
1015 +static void INVLPG_Fixup (int, int);
1016 +static void BadOp (void);
1017 +static void SEG_Fixup (int, int);
1018 +static void VMX_Fixup (int, int);
1020 +struct dis_private {
1021 + /* Points to first byte not fetched. */
1022 + bfd_byte *max_fetched;
1023 + bfd_byte the_buffer[MAXLEN];
1024 + bfd_vma insn_start;
1025 + int orig_sizeflag;
1028 +#endif /* __KERNEL__ */
1031 +/* The opcode for the fwait instruction, which we treat as a prefix
1033 +#define FWAIT_OPCODE (0x9b)
1035 +/* Set to 1 for 64bit mode disassembly. */
1036 +static int mode_64bit;
1038 +/* Flags for the prefixes for the current instruction. See below. */
1039 +static int prefixes;
1041 +/* REX prefix the current instruction. See below. */
1043 +/* Bits of REX we've already used. */
1044 +static int rex_used;
1045 +#define REX_MODE64 8
1049 +/* Mark parts used in the REX prefix. When we are testing for
1050 + empty prefix (for 8bit register REX extension), just mask it
1051 + out. Otherwise test for REX bit is excuse for existence of REX
1052 + only in case value is nonzero. */
1053 +#define USED_REX(value) \
1056 + rex_used |= (rex & value) ? (value) | 0x40 : 0; \
1058 + rex_used |= 0x40; \
1061 +/* Flags for prefixes which we somehow handled when printing the
1062 + current instruction. */
1063 +static int used_prefixes;
1065 +/* Flags stored in PREFIXES. */
1066 +#define PREFIX_REPZ 1
1067 +#define PREFIX_REPNZ 2
1068 +#define PREFIX_LOCK 4
1069 +#define PREFIX_CS 8
1070 +#define PREFIX_SS 0x10
1071 +#define PREFIX_DS 0x20
1072 +#define PREFIX_ES 0x40
1073 +#define PREFIX_FS 0x80
1074 +#define PREFIX_GS 0x100
1075 +#define PREFIX_DATA 0x200
1076 +#define PREFIX_ADDR 0x400
1077 +#define PREFIX_FWAIT 0x800
1079 +/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
1080 + to ADDR (exclusive) are valid. Returns 1 for success, longjmps
1082 +#define FETCH_DATA(info, addr) \
1083 + ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \
1084 + ? 1 : fetch_data ((info), (addr)))
1087 +fetch_data (struct disassemble_info *info, bfd_byte *addr)
1090 + struct dis_private *priv = (struct dis_private *) info->private_data;
1091 + bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
1093 + status = (*info->read_memory_func) (start,
1094 + priv->max_fetched,
1095 + addr - priv->max_fetched,
1099 + /* If we did manage to read at least one byte, then
1100 + print_insn_i386 will do something sensible. Otherwise, print
1101 + an error. We do that here because this is where we know
1103 + if (priv->max_fetched == priv->the_buffer)
1104 + (*info->memory_error_func) (status, start, info);
1106 + longjmp (priv->bailout, 1);
1107 +#else /* __KERNEL__ */
1108 + /* XXX - what to do? */
1109 + kdb_printf("Hmm. longjmp.\n");
1110 +#endif /* __KERNEL__ */
1113 + priv->max_fetched = addr;
1119 +#define Eb OP_E, b_mode
1120 +#define Ev OP_E, v_mode
1121 +#define Ed OP_E, d_mode
1122 +#define Eq OP_E, q_mode
1123 +#define Edq OP_E, dq_mode
1124 +#define Edqw OP_E, dqw_mode
1125 +#define indirEv OP_indirE, branch_v_mode
1126 +#define indirEp OP_indirE, f_mode
1127 +#define Em OP_E, m_mode
1128 +#define Ew OP_E, w_mode
1129 +#define Ma OP_E, v_mode
1130 +#define M OP_M, 0 /* lea, lgdt, etc. */
1131 +#define Mp OP_M, f_mode /* 32 or 48 bit memory operand for LDS, LES etc */
1132 +#define Gb OP_G, b_mode
1133 +#define Gv OP_G, v_mode
1134 +#define Gd OP_G, d_mode
1135 +#define Gdq OP_G, dq_mode
1136 +#define Gm OP_G, m_mode
1137 +#define Gw OP_G, w_mode
1138 +#define Rd OP_Rd, d_mode
1139 +#define Rm OP_Rd, m_mode
1140 +#define Ib OP_I, b_mode
1141 +#define sIb OP_sI, b_mode /* sign extened byte */
1142 +#define Iv OP_I, v_mode
1143 +#define Iq OP_I, q_mode
1144 +#define Iv64 OP_I64, v_mode
1145 +#define Iw OP_I, w_mode
1146 +#define I1 OP_I, const_1_mode
1147 +#define Jb OP_J, b_mode
1148 +#define Jv OP_J, v_mode
1149 +#define Cm OP_C, m_mode
1150 +#define Dm OP_D, m_mode
1151 +#define Td OP_T, d_mode
1152 +#define Sv SEG_Fixup, v_mode
1154 +#define RMeAX OP_REG, eAX_reg
1155 +#define RMeBX OP_REG, eBX_reg
1156 +#define RMeCX OP_REG, eCX_reg
1157 +#define RMeDX OP_REG, eDX_reg
1158 +#define RMeSP OP_REG, eSP_reg
1159 +#define RMeBP OP_REG, eBP_reg
1160 +#define RMeSI OP_REG, eSI_reg
1161 +#define RMeDI OP_REG, eDI_reg
1162 +#define RMrAX OP_REG, rAX_reg
1163 +#define RMrBX OP_REG, rBX_reg
1164 +#define RMrCX OP_REG, rCX_reg
1165 +#define RMrDX OP_REG, rDX_reg
1166 +#define RMrSP OP_REG, rSP_reg
1167 +#define RMrBP OP_REG, rBP_reg
1168 +#define RMrSI OP_REG, rSI_reg
1169 +#define RMrDI OP_REG, rDI_reg
1170 +#define RMAL OP_REG, al_reg
1171 +#define RMAL OP_REG, al_reg
1172 +#define RMCL OP_REG, cl_reg
1173 +#define RMDL OP_REG, dl_reg
1174 +#define RMBL OP_REG, bl_reg
1175 +#define RMAH OP_REG, ah_reg
1176 +#define RMCH OP_REG, ch_reg
1177 +#define RMDH OP_REG, dh_reg
1178 +#define RMBH OP_REG, bh_reg
1179 +#define RMAX OP_REG, ax_reg
1180 +#define RMDX OP_REG, dx_reg
1182 +#define eAX OP_IMREG, eAX_reg
1183 +#define eBX OP_IMREG, eBX_reg
1184 +#define eCX OP_IMREG, eCX_reg
1185 +#define eDX OP_IMREG, eDX_reg
1186 +#define eSP OP_IMREG, eSP_reg
1187 +#define eBP OP_IMREG, eBP_reg
1188 +#define eSI OP_IMREG, eSI_reg
1189 +#define eDI OP_IMREG, eDI_reg
1190 +#define AL OP_IMREG, al_reg
1191 +#define AL OP_IMREG, al_reg
1192 +#define CL OP_IMREG, cl_reg
1193 +#define DL OP_IMREG, dl_reg
1194 +#define BL OP_IMREG, bl_reg
1195 +#define AH OP_IMREG, ah_reg
1196 +#define CH OP_IMREG, ch_reg
1197 +#define DH OP_IMREG, dh_reg
1198 +#define BH OP_IMREG, bh_reg
1199 +#define AX OP_IMREG, ax_reg
1200 +#define DX OP_IMREG, dx_reg
1201 +#define indirDX OP_IMREG, indir_dx_reg
1203 +#define Sw OP_SEG, w_mode
1204 +#define Ap OP_DIR, 0
1205 +#define Ob OP_OFF, b_mode
1206 +#define Ob64 OP_OFF64, b_mode
1207 +#define Ov OP_OFF, v_mode
1208 +#define Ov64 OP_OFF64, v_mode
1209 +#define Xb OP_DSreg, eSI_reg
1210 +#define Xv OP_DSreg, eSI_reg
1211 +#define Yb OP_ESreg, eDI_reg
1212 +#define Yv OP_ESreg, eDI_reg
1213 +#define DSBX OP_DSreg, eBX_reg
1215 +#define es OP_REG, es_reg
1216 +#define ss OP_REG, ss_reg
1217 +#define cs OP_REG, cs_reg
1218 +#define ds OP_REG, ds_reg
1219 +#define fs OP_REG, fs_reg
1220 +#define gs OP_REG, gs_reg
1222 +#define MX OP_MMX, 0
1223 +#define XM OP_XMM, 0
1224 +#define EM OP_EM, v_mode
1225 +#define EX OP_EX, v_mode
1226 +#define MS OP_MS, v_mode
1227 +#define XS OP_XS, v_mode
1228 +#define VM OP_VMX, q_mode
1229 +#define OPSUF OP_3DNowSuffix, 0
1230 +#define OPSIMD OP_SIMD_Suffix, 0
1232 +#define cond_jump_flag NULL, cond_jump_mode
1233 +#define loop_jcxz_flag NULL, loop_jcxz_mode
1235 +/* bits in sizeflag */
1236 +#define SUFFIX_ALWAYS 4
1240 +#define b_mode 1 /* byte operand */
1241 +#define v_mode 2 /* operand size depends on prefixes */
1242 +#define w_mode 3 /* word operand */
1243 +#define d_mode 4 /* double word operand */
1244 +#define q_mode 5 /* quad word operand */
1245 +#define t_mode 6 /* ten-byte operand */
1246 +#define x_mode 7 /* 16-byte XMM operand */
1247 +#define m_mode 8 /* d_mode in 32bit, q_mode in 64bit mode. */
1248 +#define cond_jump_mode 9
1249 +#define loop_jcxz_mode 10
1250 +#define dq_mode 11 /* operand size depends on REX prefixes. */
1251 +#define dqw_mode 12 /* registers like dq_mode, memory like w_mode. */
1252 +#define f_mode 13 /* 4- or 6-byte pointer operand */
1253 +#define const_1_mode 14
1254 +#define branch_v_mode 15 /* v_mode for branch. */
1263 +#define eAX_reg 108
1264 +#define eCX_reg 109
1265 +#define eDX_reg 110
1266 +#define eBX_reg 111
1267 +#define eSP_reg 112
1268 +#define eBP_reg 113
1269 +#define eSI_reg 114
1270 +#define eDI_reg 115
1290 +#define rAX_reg 132
1291 +#define rCX_reg 133
1292 +#define rDX_reg 134
1293 +#define rBX_reg 135
1294 +#define rSP_reg 136
1295 +#define rBP_reg 137
1296 +#define rSI_reg 138
1297 +#define rDI_reg 139
1299 +#define indir_dx_reg 150
1301 +#define FLOATCODE 1
1302 +#define USE_GROUPS 2
1303 +#define USE_PREFIX_USER_TABLE 3
1304 +#define X86_64_SPECIAL 4
1306 +#define FLOAT NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
1308 +#define GRP1b NULL, NULL, USE_GROUPS, NULL, 0, NULL, 0
1309 +#define GRP1S NULL, NULL, USE_GROUPS, NULL, 1, NULL, 0
1310 +#define GRP1Ss NULL, NULL, USE_GROUPS, NULL, 2, NULL, 0
1311 +#define GRP2b NULL, NULL, USE_GROUPS, NULL, 3, NULL, 0
1312 +#define GRP2S NULL, NULL, USE_GROUPS, NULL, 4, NULL, 0
1313 +#define GRP2b_one NULL, NULL, USE_GROUPS, NULL, 5, NULL, 0
1314 +#define GRP2S_one NULL, NULL, USE_GROUPS, NULL, 6, NULL, 0
1315 +#define GRP2b_cl NULL, NULL, USE_GROUPS, NULL, 7, NULL, 0
1316 +#define GRP2S_cl NULL, NULL, USE_GROUPS, NULL, 8, NULL, 0
1317 +#define GRP3b NULL, NULL, USE_GROUPS, NULL, 9, NULL, 0
1318 +#define GRP3S NULL, NULL, USE_GROUPS, NULL, 10, NULL, 0
1319 +#define GRP4 NULL, NULL, USE_GROUPS, NULL, 11, NULL, 0
1320 +#define GRP5 NULL, NULL, USE_GROUPS, NULL, 12, NULL, 0
1321 +#define GRP6 NULL, NULL, USE_GROUPS, NULL, 13, NULL, 0
1322 +#define GRP7 NULL, NULL, USE_GROUPS, NULL, 14, NULL, 0
1323 +#define GRP8 NULL, NULL, USE_GROUPS, NULL, 15, NULL, 0
1324 +#define GRP9 NULL, NULL, USE_GROUPS, NULL, 16, NULL, 0
1325 +#define GRP10 NULL, NULL, USE_GROUPS, NULL, 17, NULL, 0
1326 +#define GRP11 NULL, NULL, USE_GROUPS, NULL, 18, NULL, 0
1327 +#define GRP12 NULL, NULL, USE_GROUPS, NULL, 19, NULL, 0
1328 +#define GRP13 NULL, NULL, USE_GROUPS, NULL, 20, NULL, 0
1329 +#define GRP14 NULL, NULL, USE_GROUPS, NULL, 21, NULL, 0
1330 +#define GRPAMD NULL, NULL, USE_GROUPS, NULL, 22, NULL, 0
1331 +#define GRPPADLCK1 NULL, NULL, USE_GROUPS, NULL, 23, NULL, 0
1332 +#define GRPPADLCK2 NULL, NULL, USE_GROUPS, NULL, 24, NULL, 0
1334 +#define PREGRP0 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 0, NULL, 0
1335 +#define PREGRP1 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 1, NULL, 0
1336 +#define PREGRP2 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 2, NULL, 0
1337 +#define PREGRP3 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 3, NULL, 0
1338 +#define PREGRP4 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 4, NULL, 0
1339 +#define PREGRP5 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 5, NULL, 0
1340 +#define PREGRP6 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 6, NULL, 0
1341 +#define PREGRP7 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 7, NULL, 0
1342 +#define PREGRP8 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 8, NULL, 0
1343 +#define PREGRP9 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 9, NULL, 0
1344 +#define PREGRP10 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 10, NULL, 0
1345 +#define PREGRP11 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 11, NULL, 0
1346 +#define PREGRP12 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 12, NULL, 0
1347 +#define PREGRP13 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 13, NULL, 0
1348 +#define PREGRP14 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 14, NULL, 0
1349 +#define PREGRP15 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 15, NULL, 0
1350 +#define PREGRP16 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 16, NULL, 0
1351 +#define PREGRP17 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 17, NULL, 0
1352 +#define PREGRP18 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 18, NULL, 0
1353 +#define PREGRP19 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 19, NULL, 0
1354 +#define PREGRP20 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 20, NULL, 0
1355 +#define PREGRP21 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 21, NULL, 0
1356 +#define PREGRP22 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 22, NULL, 0
1357 +#define PREGRP23 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 23, NULL, 0
1358 +#define PREGRP24 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 24, NULL, 0
1359 +#define PREGRP25 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 25, NULL, 0
1360 +#define PREGRP26 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 26, NULL, 0
1361 +#define PREGRP27 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 27, NULL, 0
1362 +#define PREGRP28 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 28, NULL, 0
1363 +#define PREGRP29 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 29, NULL, 0
1364 +#define PREGRP30 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 30, NULL, 0
1365 +#define PREGRP31 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 31, NULL, 0
1366 +#define PREGRP32 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 32, NULL, 0
1368 +#define X86_64_0 NULL, NULL, X86_64_SPECIAL, NULL, 0, NULL, 0
1370 +typedef void (*op_rtn) (int bytemode, int sizeflag);
1382 +/* Upper case letters in the instruction names here are macros.
1383 + 'A' => print 'b' if no register operands or suffix_always is true
1384 + 'B' => print 'b' if suffix_always is true
1385 + 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
1387 + 'E' => print 'e' if 32-bit form of jcxz
1388 + 'F' => print 'w' or 'l' depending on address size prefix (loop insns)
1389 + 'H' => print ",pt" or ",pn" branch hint
1390 + 'I' => honor following macro letter even in Intel mode (implemented only
1391 + . for some of the macro letters)
1393 + 'L' => print 'l' if suffix_always is true
1394 + 'N' => print 'n' if instruction has no wait "prefix"
1395 + 'O' => print 'd', or 'o'
1396 + 'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
1397 + . or suffix_always is true. print 'q' if rex prefix is present.
1398 + 'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
1400 + 'R' => print 'w', 'l' or 'q' ("wd" or "dq" in intel mode)
1401 + 'S' => print 'w', 'l' or 'q' if suffix_always is true
1402 + 'T' => print 'q' in 64bit mode and behave as 'P' otherwise
1403 + 'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
1404 + 'W' => print 'b' or 'w' ("w" or "de" in intel mode)
1405 + 'X' => print 's', 'd' depending on data16 prefix (for XMM)
1406 + 'Y' => 'q' if instruction has an REX 64bit overwrite prefix
1408 + Many of the above letters print nothing in Intel mode. See "putop"
1411 + Braces '{' and '}', and vertical bars '|', indicate alternative
1412 + mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
1413 + modes. In cases where there are only two alternatives, the X86_64
1414 + instruction is reserved, and "(bad)" is printed.
1417 +static const struct dis386 dis386[] = {
1419 + { "addB", Eb, Gb, XX },
1420 + { "addS", Ev, Gv, XX },
1421 + { "addB", Gb, Eb, XX },
1422 + { "addS", Gv, Ev, XX },
1423 + { "addB", AL, Ib, XX },
1424 + { "addS", eAX, Iv, XX },
1425 + { "push{T|}", es, XX, XX },
1426 + { "pop{T|}", es, XX, XX },
1428 + { "orB", Eb, Gb, XX },
1429 + { "orS", Ev, Gv, XX },
1430 + { "orB", Gb, Eb, XX },
1431 + { "orS", Gv, Ev, XX },
1432 + { "orB", AL, Ib, XX },
1433 + { "orS", eAX, Iv, XX },
1434 + { "push{T|}", cs, XX, XX },
1435 + { "(bad)", XX, XX, XX }, /* 0x0f extended opcode escape */
1437 + { "adcB", Eb, Gb, XX },
1438 + { "adcS", Ev, Gv, XX },
1439 + { "adcB", Gb, Eb, XX },
1440 + { "adcS", Gv, Ev, XX },
1441 + { "adcB", AL, Ib, XX },
1442 + { "adcS", eAX, Iv, XX },
1443 + { "push{T|}", ss, XX, XX },
1444 + { "popT|}", ss, XX, XX },
1446 + { "sbbB", Eb, Gb, XX },
1447 + { "sbbS", Ev, Gv, XX },
1448 + { "sbbB", Gb, Eb, XX },
1449 + { "sbbS", Gv, Ev, XX },
1450 + { "sbbB", AL, Ib, XX },
1451 + { "sbbS", eAX, Iv, XX },
1452 + { "push{T|}", ds, XX, XX },
1453 + { "pop{T|}", ds, XX, XX },
1455 + { "andB", Eb, Gb, XX },
1456 + { "andS", Ev, Gv, XX },
1457 + { "andB", Gb, Eb, XX },
1458 + { "andS", Gv, Ev, XX },
1459 + { "andB", AL, Ib, XX },
1460 + { "andS", eAX, Iv, XX },
1461 + { "(bad)", XX, XX, XX }, /* SEG ES prefix */
1462 + { "daa{|}", XX, XX, XX },
1464 + { "subB", Eb, Gb, XX },
1465 + { "subS", Ev, Gv, XX },
1466 + { "subB", Gb, Eb, XX },
1467 + { "subS", Gv, Ev, XX },
1468 + { "subB", AL, Ib, XX },
1469 + { "subS", eAX, Iv, XX },
1470 + { "(bad)", XX, XX, XX }, /* SEG CS prefix */
1471 + { "das{|}", XX, XX, XX },
1473 + { "xorB", Eb, Gb, XX },
1474 + { "xorS", Ev, Gv, XX },
1475 + { "xorB", Gb, Eb, XX },
1476 + { "xorS", Gv, Ev, XX },
1477 + { "xorB", AL, Ib, XX },
1478 + { "xorS", eAX, Iv, XX },
1479 + { "(bad)", XX, XX, XX }, /* SEG SS prefix */
1480 + { "aaa{|}", XX, XX, XX },
1482 + { "cmpB", Eb, Gb, XX },
1483 + { "cmpS", Ev, Gv, XX },
1484 + { "cmpB", Gb, Eb, XX },
1485 + { "cmpS", Gv, Ev, XX },
1486 + { "cmpB", AL, Ib, XX },
1487 + { "cmpS", eAX, Iv, XX },
1488 + { "(bad)", XX, XX, XX }, /* SEG DS prefix */
1489 + { "aas{|}", XX, XX, XX },
1491 + { "inc{S|}", RMeAX, XX, XX },
1492 + { "inc{S|}", RMeCX, XX, XX },
1493 + { "inc{S|}", RMeDX, XX, XX },
1494 + { "inc{S|}", RMeBX, XX, XX },
1495 + { "inc{S|}", RMeSP, XX, XX },
1496 + { "inc{S|}", RMeBP, XX, XX },
1497 + { "inc{S|}", RMeSI, XX, XX },
1498 + { "inc{S|}", RMeDI, XX, XX },
1500 + { "dec{S|}", RMeAX, XX, XX },
1501 + { "dec{S|}", RMeCX, XX, XX },
1502 + { "dec{S|}", RMeDX, XX, XX },
1503 + { "dec{S|}", RMeBX, XX, XX },
1504 + { "dec{S|}", RMeSP, XX, XX },
1505 + { "dec{S|}", RMeBP, XX, XX },
1506 + { "dec{S|}", RMeSI, XX, XX },
1507 + { "dec{S|}", RMeDI, XX, XX },
1509 + { "pushS", RMrAX, XX, XX },
1510 + { "pushS", RMrCX, XX, XX },
1511 + { "pushS", RMrDX, XX, XX },
1512 + { "pushS", RMrBX, XX, XX },
1513 + { "pushS", RMrSP, XX, XX },
1514 + { "pushS", RMrBP, XX, XX },
1515 + { "pushS", RMrSI, XX, XX },
1516 + { "pushS", RMrDI, XX, XX },
1518 + { "popS", RMrAX, XX, XX },
1519 + { "popS", RMrCX, XX, XX },
1520 + { "popS", RMrDX, XX, XX },
1521 + { "popS", RMrBX, XX, XX },
1522 + { "popS", RMrSP, XX, XX },
1523 + { "popS", RMrBP, XX, XX },
1524 + { "popS", RMrSI, XX, XX },
1525 + { "popS", RMrDI, XX, XX },
1527 + { "pusha{P|}", XX, XX, XX },
1528 + { "popa{P|}", XX, XX, XX },
1529 + { "bound{S|}", Gv, Ma, XX },
1531 + { "(bad)", XX, XX, XX }, /* seg fs */
1532 + { "(bad)", XX, XX, XX }, /* seg gs */
1533 + { "(bad)", XX, XX, XX }, /* op size prefix */
1534 + { "(bad)", XX, XX, XX }, /* adr size prefix */
1536 + { "pushT", Iq, XX, XX },
1537 + { "imulS", Gv, Ev, Iv },
1538 + { "pushT", sIb, XX, XX },
1539 + { "imulS", Gv, Ev, sIb },
1540 + { "ins{b||b|}", Yb, indirDX, XX },
1541 + { "ins{R||R|}", Yv, indirDX, XX },
1542 + { "outs{b||b|}", indirDX, Xb, XX },
1543 + { "outs{R||R|}", indirDX, Xv, XX },
1545 + { "joH", Jb, XX, cond_jump_flag },
1546 + { "jnoH", Jb, XX, cond_jump_flag },
1547 + { "jbH", Jb, XX, cond_jump_flag },
1548 + { "jaeH", Jb, XX, cond_jump_flag },
1549 + { "jeH", Jb, XX, cond_jump_flag },
1550 + { "jneH", Jb, XX, cond_jump_flag },
1551 + { "jbeH", Jb, XX, cond_jump_flag },
1552 + { "jaH", Jb, XX, cond_jump_flag },
1554 + { "jsH", Jb, XX, cond_jump_flag },
1555 + { "jnsH", Jb, XX, cond_jump_flag },
1556 + { "jpH", Jb, XX, cond_jump_flag },
1557 + { "jnpH", Jb, XX, cond_jump_flag },
1558 + { "jlH", Jb, XX, cond_jump_flag },
1559 + { "jgeH", Jb, XX, cond_jump_flag },
1560 + { "jleH", Jb, XX, cond_jump_flag },
1561 + { "jgH", Jb, XX, cond_jump_flag },
1565 + { "(bad)", XX, XX, XX },
1567 + { "testB", Eb, Gb, XX },
1568 + { "testS", Ev, Gv, XX },
1569 + { "xchgB", Eb, Gb, XX },
1570 + { "xchgS", Ev, Gv, XX },
1572 + { "movB", Eb, Gb, XX },
1573 + { "movS", Ev, Gv, XX },
1574 + { "movB", Gb, Eb, XX },
1575 + { "movS", Gv, Ev, XX },
1576 + { "movQ", Sv, Sw, XX },
1577 + { "leaS", Gv, M, XX },
1578 + { "movQ", Sw, Sv, XX },
1579 + { "popU", Ev, XX, XX },
1581 + { "nop", NOP_Fixup, 0, XX, XX },
1582 + { "xchgS", RMeCX, eAX, XX },
1583 + { "xchgS", RMeDX, eAX, XX },
1584 + { "xchgS", RMeBX, eAX, XX },
1585 + { "xchgS", RMeSP, eAX, XX },
1586 + { "xchgS", RMeBP, eAX, XX },
1587 + { "xchgS", RMeSI, eAX, XX },
1588 + { "xchgS", RMeDI, eAX, XX },
1590 + { "cW{tR||tR|}", XX, XX, XX },
1591 + { "cR{tO||tO|}", XX, XX, XX },
1592 + { "Jcall{T|}", Ap, XX, XX },
1593 + { "(bad)", XX, XX, XX }, /* fwait */
1594 + { "pushfT", XX, XX, XX },
1595 + { "popfT", XX, XX, XX },
1596 + { "sahf{|}", XX, XX, XX },
1597 + { "lahf{|}", XX, XX, XX },
1599 + { "movB", AL, Ob64, XX },
1600 + { "movS", eAX, Ov64, XX },
1601 + { "movB", Ob64, AL, XX },
1602 + { "movS", Ov64, eAX, XX },
1603 + { "movs{b||b|}", Yb, Xb, XX },
1604 + { "movs{R||R|}", Yv, Xv, XX },
1605 + { "cmps{b||b|}", Xb, Yb, XX },
1606 + { "cmps{R||R|}", Xv, Yv, XX },
1608 + { "testB", AL, Ib, XX },
1609 + { "testS", eAX, Iv, XX },
1610 + { "stosB", Yb, AL, XX },
1611 + { "stosS", Yv, eAX, XX },
1612 + { "lodsB", AL, Xb, XX },
1613 + { "lodsS", eAX, Xv, XX },
1614 + { "scasB", AL, Yb, XX },
1615 + { "scasS", eAX, Yv, XX },
1617 + { "movB", RMAL, Ib, XX },
1618 + { "movB", RMCL, Ib, XX },
1619 + { "movB", RMDL, Ib, XX },
1620 + { "movB", RMBL, Ib, XX },
1621 + { "movB", RMAH, Ib, XX },
1622 + { "movB", RMCH, Ib, XX },
1623 + { "movB", RMDH, Ib, XX },
1624 + { "movB", RMBH, Ib, XX },
1626 + { "movS", RMeAX, Iv64, XX },
1627 + { "movS", RMeCX, Iv64, XX },
1628 + { "movS", RMeDX, Iv64, XX },
1629 + { "movS", RMeBX, Iv64, XX },
1630 + { "movS", RMeSP, Iv64, XX },
1631 + { "movS", RMeBP, Iv64, XX },
1632 + { "movS", RMeSI, Iv64, XX },
1633 + { "movS", RMeDI, Iv64, XX },
1637 + { "retT", Iw, XX, XX },
1638 + { "retT", XX, XX, XX },
1639 + { "les{S|}", Gv, Mp, XX },
1640 + { "ldsS", Gv, Mp, XX },
1641 + { "movA", Eb, Ib, XX },
1642 + { "movQ", Ev, Iv, XX },
1644 + { "enterT", Iw, Ib, XX },
1645 + { "leaveT", XX, XX, XX },
1646 + { "lretP", Iw, XX, XX },
1647 + { "lretP", XX, XX, XX },
1648 + { "int3", XX, XX, XX },
1649 + { "int", Ib, XX, XX },
1650 + { "into{|}", XX, XX, XX },
1651 + { "iretP", XX, XX, XX },
1657 + { "aam{|}", sIb, XX, XX },
1658 + { "aad{|}", sIb, XX, XX },
1659 + { "(bad)", XX, XX, XX },
1660 + { "xlat", DSBX, XX, XX },
1671 + { "loopneFH", Jb, XX, loop_jcxz_flag },
1672 + { "loopeFH", Jb, XX, loop_jcxz_flag },
1673 + { "loopFH", Jb, XX, loop_jcxz_flag },
1674 + { "jEcxzH", Jb, XX, loop_jcxz_flag },
1675 + { "inB", AL, Ib, XX },
1676 + { "inS", eAX, Ib, XX },
1677 + { "outB", Ib, AL, XX },
1678 + { "outS", Ib, eAX, XX },
1680 + { "callT", Jv, XX, XX },
1681 + { "jmpT", Jv, XX, XX },
1682 + { "Jjmp{T|}", Ap, XX, XX },
1683 + { "jmp", Jb, XX, XX },
1684 + { "inB", AL, indirDX, XX },
1685 + { "inS", eAX, indirDX, XX },
1686 + { "outB", indirDX, AL, XX },
1687 + { "outS", indirDX, eAX, XX },
1689 + { "(bad)", XX, XX, XX }, /* lock prefix */
1690 + { "icebp", XX, XX, XX },
1691 + { "(bad)", XX, XX, XX }, /* repne */
1692 + { "(bad)", XX, XX, XX }, /* repz */
1693 + { "hlt", XX, XX, XX },
1694 + { "cmc", XX, XX, XX },
1698 + { "clc", XX, XX, XX },
1699 + { "stc", XX, XX, XX },
1700 + { "cli", XX, XX, XX },
1701 + { "sti", XX, XX, XX },
1702 + { "cld", XX, XX, XX },
1703 + { "std", XX, XX, XX },
1708 +static const struct dis386 dis386_twobyte[] = {
1712 + { "larS", Gv, Ew, XX },
1713 + { "lslS", Gv, Ew, XX },
1714 + { "(bad)", XX, XX, XX },
1715 + { "syscall", XX, XX, XX },
1716 + { "clts", XX, XX, XX },
1717 + { "sysretP", XX, XX, XX },
1719 + { "invd", XX, XX, XX },
1720 + { "wbinvd", XX, XX, XX },
1721 + { "(bad)", XX, XX, XX },
1722 + { "ud2a", XX, XX, XX },
1723 + { "(bad)", XX, XX, XX },
1725 + { "femms", XX, XX, XX },
1726 + { "", MX, EM, OPSUF }, /* See OP_3DNowSuffix. */
1731 + { "movlpX", EX, XM, SIMD_Fixup, 'h' },
1732 + { "unpcklpX", XM, EX, XX },
1733 + { "unpckhpX", XM, EX, XX },
1735 + { "movhpX", EX, XM, SIMD_Fixup, 'l' },
1738 + { "(bad)", XX, XX, XX },
1739 + { "(bad)", XX, XX, XX },
1740 + { "(bad)", XX, XX, XX },
1741 + { "(bad)", XX, XX, XX },
1742 + { "(bad)", XX, XX, XX },
1743 + { "(bad)", XX, XX, XX },
1744 + { "(bad)", XX, XX, XX },
1746 + { "movL", Rm, Cm, XX },
1747 + { "movL", Rm, Dm, XX },
1748 + { "movL", Cm, Rm, XX },
1749 + { "movL", Dm, Rm, XX },
1750 + { "movL", Rd, Td, XX },
1751 + { "(bad)", XX, XX, XX },
1752 + { "movL", Td, Rd, XX },
1753 + { "(bad)", XX, XX, XX },
1755 + { "movapX", XM, EX, XX },
1756 + { "movapX", EX, XM, XX },
1758 + { "movntpX", Ev, XM, XX },
1761 + { "ucomisX", XM,EX, XX },
1762 + { "comisX", XM,EX, XX },
1764 + { "wrmsr", XX, XX, XX },
1765 + { "rdtsc", XX, XX, XX },
1766 + { "rdmsr", XX, XX, XX },
1767 + { "rdpmc", XX, XX, XX },
1768 + { "sysenter", XX, XX, XX },
1769 + { "sysexit", XX, XX, XX },
1770 + { "(bad)", XX, XX, XX },
1771 + { "(bad)", XX, XX, XX },
1773 + { "(bad)", XX, XX, XX },
1774 + { "(bad)", XX, XX, XX },
1775 + { "(bad)", XX, XX, XX },
1776 + { "(bad)", XX, XX, XX },
1777 + { "(bad)", XX, XX, XX },
1778 + { "(bad)", XX, XX, XX },
1779 + { "(bad)", XX, XX, XX },
1780 + { "(bad)", XX, XX, XX },
1782 + { "cmovo", Gv, Ev, XX },
1783 + { "cmovno", Gv, Ev, XX },
1784 + { "cmovb", Gv, Ev, XX },
1785 + { "cmovae", Gv, Ev, XX },
1786 + { "cmove", Gv, Ev, XX },
1787 + { "cmovne", Gv, Ev, XX },
1788 + { "cmovbe", Gv, Ev, XX },
1789 + { "cmova", Gv, Ev, XX },
1791 + { "cmovs", Gv, Ev, XX },
1792 + { "cmovns", Gv, Ev, XX },
1793 + { "cmovp", Gv, Ev, XX },
1794 + { "cmovnp", Gv, Ev, XX },
1795 + { "cmovl", Gv, Ev, XX },
1796 + { "cmovge", Gv, Ev, XX },
1797 + { "cmovle", Gv, Ev, XX },
1798 + { "cmovg", Gv, Ev, XX },
1800 + { "movmskpX", Gdq, XS, XX },
1804 + { "andpX", XM, EX, XX },
1805 + { "andnpX", XM, EX, XX },
1806 + { "orpX", XM, EX, XX },
1807 + { "xorpX", XM, EX, XX },
1818 + { "punpcklbw", MX, EM, XX },
1819 + { "punpcklwd", MX, EM, XX },
1820 + { "punpckldq", MX, EM, XX },
1821 + { "packsswb", MX, EM, XX },
1822 + { "pcmpgtb", MX, EM, XX },
1823 + { "pcmpgtw", MX, EM, XX },
1824 + { "pcmpgtd", MX, EM, XX },
1825 + { "packuswb", MX, EM, XX },
1827 + { "punpckhbw", MX, EM, XX },
1828 + { "punpckhwd", MX, EM, XX },
1829 + { "punpckhdq", MX, EM, XX },
1830 + { "packssdw", MX, EM, XX },
1833 + { "movd", MX, Edq, XX },
1840 + { "pcmpeqb", MX, EM, XX },
1841 + { "pcmpeqw", MX, EM, XX },
1842 + { "pcmpeqd", MX, EM, XX },
1843 + { "emms", XX, XX, XX },
1845 + { "vmread", Em, Gm, XX },
1846 + { "vmwrite", Gm, Em, XX },
1847 + { "(bad)", XX, XX, XX },
1848 + { "(bad)", XX, XX, XX },
1854 + { "joH", Jv, XX, cond_jump_flag },
1855 + { "jnoH", Jv, XX, cond_jump_flag },
1856 + { "jbH", Jv, XX, cond_jump_flag },
1857 + { "jaeH", Jv, XX, cond_jump_flag },
1858 + { "jeH", Jv, XX, cond_jump_flag },
1859 + { "jneH", Jv, XX, cond_jump_flag },
1860 + { "jbeH", Jv, XX, cond_jump_flag },
1861 + { "jaH", Jv, XX, cond_jump_flag },
1863 + { "jsH", Jv, XX, cond_jump_flag },
1864 + { "jnsH", Jv, XX, cond_jump_flag },
1865 + { "jpH", Jv, XX, cond_jump_flag },
1866 + { "jnpH", Jv, XX, cond_jump_flag },
1867 + { "jlH", Jv, XX, cond_jump_flag },
1868 + { "jgeH", Jv, XX, cond_jump_flag },
1869 + { "jleH", Jv, XX, cond_jump_flag },
1870 + { "jgH", Jv, XX, cond_jump_flag },
1872 + { "seto", Eb, XX, XX },
1873 + { "setno", Eb, XX, XX },
1874 + { "setb", Eb, XX, XX },
1875 + { "setae", Eb, XX, XX },
1876 + { "sete", Eb, XX, XX },
1877 + { "setne", Eb, XX, XX },
1878 + { "setbe", Eb, XX, XX },
1879 + { "seta", Eb, XX, XX },
1881 + { "sets", Eb, XX, XX },
1882 + { "setns", Eb, XX, XX },
1883 + { "setp", Eb, XX, XX },
1884 + { "setnp", Eb, XX, XX },
1885 + { "setl", Eb, XX, XX },
1886 + { "setge", Eb, XX, XX },
1887 + { "setle", Eb, XX, XX },
1888 + { "setg", Eb, XX, XX },
1890 + { "pushT", fs, XX, XX },
1891 + { "popT", fs, XX, XX },
1892 + { "cpuid", XX, XX, XX },
1893 + { "btS", Ev, Gv, XX },
1894 + { "shldS", Ev, Gv, Ib },
1895 + { "shldS", Ev, Gv, CL },
1899 + { "pushT", gs, XX, XX },
1900 + { "popT", gs, XX, XX },
1901 + { "rsm", XX, XX, XX },
1902 + { "btsS", Ev, Gv, XX },
1903 + { "shrdS", Ev, Gv, Ib },
1904 + { "shrdS", Ev, Gv, CL },
1906 + { "imulS", Gv, Ev, XX },
1908 + { "cmpxchgB", Eb, Gb, XX },
1909 + { "cmpxchgS", Ev, Gv, XX },
1910 + { "lssS", Gv, Mp, XX },
1911 + { "btrS", Ev, Gv, XX },
1912 + { "lfsS", Gv, Mp, XX },
1913 + { "lgsS", Gv, Mp, XX },
1914 + { "movz{bR|x|bR|x}", Gv, Eb, XX },
1915 + { "movz{wR|x|wR|x}", Gv, Ew, XX }, /* yes, there really is movzww ! */
1917 + { "(bad)", XX, XX, XX },
1918 + { "ud2b", XX, XX, XX },
1920 + { "btcS", Ev, Gv, XX },
1921 + { "bsfS", Gv, Ev, XX },
1922 + { "bsrS", Gv, Ev, XX },
1923 + { "movs{bR|x|bR|x}", Gv, Eb, XX },
1924 + { "movs{wR|x|wR|x}", Gv, Ew, XX }, /* yes, there really is movsww ! */
1926 + { "xaddB", Eb, Gb, XX },
1927 + { "xaddS", Ev, Gv, XX },
1929 + { "movntiS", Ev, Gv, XX },
1930 + { "pinsrw", MX, Edqw, Ib },
1931 + { "pextrw", Gdq, MS, Ib },
1932 + { "shufpX", XM, EX, Ib },
1935 + { "bswap", RMeAX, XX, XX },
1936 + { "bswap", RMeCX, XX, XX },
1937 + { "bswap", RMeDX, XX, XX },
1938 + { "bswap", RMeBX, XX, XX },
1939 + { "bswap", RMeSP, XX, XX },
1940 + { "bswap", RMeBP, XX, XX },
1941 + { "bswap", RMeSI, XX, XX },
1942 + { "bswap", RMeDI, XX, XX },
1945 + { "psrlw", MX, EM, XX },
1946 + { "psrld", MX, EM, XX },
1947 + { "psrlq", MX, EM, XX },
1948 + { "paddq", MX, EM, XX },
1949 + { "pmullw", MX, EM, XX },
1951 + { "pmovmskb", Gdq, MS, XX },
1953 + { "psubusb", MX, EM, XX },
1954 + { "psubusw", MX, EM, XX },
1955 + { "pminub", MX, EM, XX },
1956 + { "pand", MX, EM, XX },
1957 + { "paddusb", MX, EM, XX },
1958 + { "paddusw", MX, EM, XX },
1959 + { "pmaxub", MX, EM, XX },
1960 + { "pandn", MX, EM, XX },
1962 + { "pavgb", MX, EM, XX },
1963 + { "psraw", MX, EM, XX },
1964 + { "psrad", MX, EM, XX },
1965 + { "pavgw", MX, EM, XX },
1966 + { "pmulhuw", MX, EM, XX },
1967 + { "pmulhw", MX, EM, XX },
1971 + { "psubsb", MX, EM, XX },
1972 + { "psubsw", MX, EM, XX },
1973 + { "pminsw", MX, EM, XX },
1974 + { "por", MX, EM, XX },
1975 + { "paddsb", MX, EM, XX },
1976 + { "paddsw", MX, EM, XX },
1977 + { "pmaxsw", MX, EM, XX },
1978 + { "pxor", MX, EM, XX },
1981 + { "psllw", MX, EM, XX },
1982 + { "pslld", MX, EM, XX },
1983 + { "psllq", MX, EM, XX },
1984 + { "pmuludq", MX, EM, XX },
1985 + { "pmaddwd", MX, EM, XX },
1986 + { "psadbw", MX, EM, XX },
1989 + { "psubb", MX, EM, XX },
1990 + { "psubw", MX, EM, XX },
1991 + { "psubd", MX, EM, XX },
1992 + { "psubq", MX, EM, XX },
1993 + { "paddb", MX, EM, XX },
1994 + { "paddw", MX, EM, XX },
1995 + { "paddd", MX, EM, XX },
1996 + { "(bad)", XX, XX, XX }
1999 +static const unsigned char onebyte_has_modrm[256] = {
2000 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
2001 + /* ------------------------------- */
2002 + /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
2003 + /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
2004 + /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
2005 + /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
2006 + /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
2007 + /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
2008 + /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
2009 + /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
2010 + /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
2011 + /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
2012 + /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
2013 + /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
2014 + /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
2015 + /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
2016 + /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
2017 + /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
2018 + /* ------------------------------- */
2019 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
2022 +static const unsigned char twobyte_has_modrm[256] = {
2023 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
2024 + /* ------------------------------- */
2025 + /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
2026 + /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0, /* 1f */
2027 + /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
2028 + /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
2029 + /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
2030 + /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
2031 + /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
2032 + /* 70 */ 1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1, /* 7f */
2033 + /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
2034 + /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
2035 + /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
2036 + /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
2037 + /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
2038 + /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
2039 + /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
2040 + /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 /* ff */
2041 + /* ------------------------------- */
2042 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
2045 +static const unsigned char twobyte_uses_SSE_prefix[256] = {
2046 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
2047 + /* ------------------------------- */
2048 + /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
2049 + /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
2050 + /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0, /* 2f */
2051 + /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
2052 + /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
2053 + /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
2054 + /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
2055 + /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1, /* 7f */
2056 + /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
2057 + /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
2058 + /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
2059 + /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
2060 + /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
2061 + /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
2062 + /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
2063 + /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 /* ff */
2064 + /* ------------------------------- */
2065 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
2068 +static char obuf[100];
2069 +static char *obufp;
2070 +static char scratchbuf[100];
2071 +static unsigned char *start_codep;
2072 +static unsigned char *insn_codep;
2073 +static unsigned char *codep;
2074 +static disassemble_info *the_info;
2078 +static unsigned char need_modrm;
2080 +/* If we are accessing mod/rm/reg without need_modrm set, then the
2081 + values are stale. Hitting this abort likely indicates that you
2082 + need to update onebyte_has_modrm or twobyte_has_modrm. */
2083 +#define MODRM_CHECK if (!need_modrm) abort ()
2085 +static const char **names64;
2086 +static const char **names32;
2087 +static const char **names16;
2088 +static const char **names8;
2089 +static const char **names8rex;
2090 +static const char **names_seg;
2091 +static const char **index16;
2093 +static const char *intel_names64[] = {
2094 + "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
2095 + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
2097 +static const char *intel_names32[] = {
2098 + "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
2099 + "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
2101 +static const char *intel_names16[] = {
2102 + "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
2103 + "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
2105 +static const char *intel_names8[] = {
2106 + "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
2108 +static const char *intel_names8rex[] = {
2109 + "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
2110 + "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
2112 +static const char *intel_names_seg[] = {
2113 + "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
2115 +static const char *intel_index16[] = {
2116 + "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
2119 +static const char *att_names64[] = {
2120 + "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
2121 + "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
2123 +static const char *att_names32[] = {
2124 + "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
2125 + "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
2127 +static const char *att_names16[] = {
2128 + "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
2129 + "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
2131 +static const char *att_names8[] = {
2132 + "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
2134 +static const char *att_names8rex[] = {
2135 + "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
2136 + "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
2138 +static const char *att_names_seg[] = {
2139 + "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
2141 +static const char *att_index16[] = {
2142 + "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
2145 +static const struct dis386 grps[][8] = {
2148 + { "addA", Eb, Ib, XX },
2149 + { "orA", Eb, Ib, XX },
2150 + { "adcA", Eb, Ib, XX },
2151 + { "sbbA", Eb, Ib, XX },
2152 + { "andA", Eb, Ib, XX },
2153 + { "subA", Eb, Ib, XX },
2154 + { "xorA", Eb, Ib, XX },
2155 + { "cmpA", Eb, Ib, XX }
2159 + { "addQ", Ev, Iv, XX },
2160 + { "orQ", Ev, Iv, XX },
2161 + { "adcQ", Ev, Iv, XX },
2162 + { "sbbQ", Ev, Iv, XX },
2163 + { "andQ", Ev, Iv, XX },
2164 + { "subQ", Ev, Iv, XX },
2165 + { "xorQ", Ev, Iv, XX },
2166 + { "cmpQ", Ev, Iv, XX }
2170 + { "addQ", Ev, sIb, XX },
2171 + { "orQ", Ev, sIb, XX },
2172 + { "adcQ", Ev, sIb, XX },
2173 + { "sbbQ", Ev, sIb, XX },
2174 + { "andQ", Ev, sIb, XX },
2175 + { "subQ", Ev, sIb, XX },
2176 + { "xorQ", Ev, sIb, XX },
2177 + { "cmpQ", Ev, sIb, XX }
2181 + { "rolA", Eb, Ib, XX },
2182 + { "rorA", Eb, Ib, XX },
2183 + { "rclA", Eb, Ib, XX },
2184 + { "rcrA", Eb, Ib, XX },
2185 + { "shlA", Eb, Ib, XX },
2186 + { "shrA", Eb, Ib, XX },
2187 + { "(bad)", XX, XX, XX },
2188 + { "sarA", Eb, Ib, XX },
2192 + { "rolQ", Ev, Ib, XX },
2193 + { "rorQ", Ev, Ib, XX },
2194 + { "rclQ", Ev, Ib, XX },
2195 + { "rcrQ", Ev, Ib, XX },
2196 + { "shlQ", Ev, Ib, XX },
2197 + { "shrQ", Ev, Ib, XX },
2198 + { "(bad)", XX, XX, XX },
2199 + { "sarQ", Ev, Ib, XX },
2203 + { "rolA", Eb, I1, XX },
2204 + { "rorA", Eb, I1, XX },
2205 + { "rclA", Eb, I1, XX },
2206 + { "rcrA", Eb, I1, XX },
2207 + { "shlA", Eb, I1, XX },
2208 + { "shrA", Eb, I1, XX },
2209 + { "(bad)", XX, XX, XX },
2210 + { "sarA", Eb, I1, XX },
2214 + { "rolQ", Ev, I1, XX },
2215 + { "rorQ", Ev, I1, XX },
2216 + { "rclQ", Ev, I1, XX },
2217 + { "rcrQ", Ev, I1, XX },
2218 + { "shlQ", Ev, I1, XX },
2219 + { "shrQ", Ev, I1, XX },
2220 + { "(bad)", XX, XX, XX},
2221 + { "sarQ", Ev, I1, XX },
2225 + { "rolA", Eb, CL, XX },
2226 + { "rorA", Eb, CL, XX },
2227 + { "rclA", Eb, CL, XX },
2228 + { "rcrA", Eb, CL, XX },
2229 + { "shlA", Eb, CL, XX },
2230 + { "shrA", Eb, CL, XX },
2231 + { "(bad)", XX, XX, XX },
2232 + { "sarA", Eb, CL, XX },
2236 + { "rolQ", Ev, CL, XX },
2237 + { "rorQ", Ev, CL, XX },
2238 + { "rclQ", Ev, CL, XX },
2239 + { "rcrQ", Ev, CL, XX },
2240 + { "shlQ", Ev, CL, XX },
2241 + { "shrQ", Ev, CL, XX },
2242 + { "(bad)", XX, XX, XX },
2243 + { "sarQ", Ev, CL, XX }
2247 + { "testA", Eb, Ib, XX },
2248 + { "(bad)", Eb, XX, XX },
2249 + { "notA", Eb, XX, XX },
2250 + { "negA", Eb, XX, XX },
2251 + { "mulA", Eb, XX, XX }, /* Don't print the implicit %al register, */
2252 + { "imulA", Eb, XX, XX }, /* to distinguish these opcodes from other */
2253 + { "divA", Eb, XX, XX }, /* mul/imul opcodes. Do the same for div */
2254 + { "idivA", Eb, XX, XX } /* and idiv for consistency. */
2258 + { "testQ", Ev, Iv, XX },
2259 + { "(bad)", XX, XX, XX },
2260 + { "notQ", Ev, XX, XX },
2261 + { "negQ", Ev, XX, XX },
2262 + { "mulQ", Ev, XX, XX }, /* Don't print the implicit register. */
2263 + { "imulQ", Ev, XX, XX },
2264 + { "divQ", Ev, XX, XX },
2265 + { "idivQ", Ev, XX, XX },
2269 + { "incA", Eb, XX, XX },
2270 + { "decA", Eb, XX, XX },
2271 + { "(bad)", XX, XX, XX },
2272 + { "(bad)", XX, XX, XX },
2273 + { "(bad)", XX, XX, XX },
2274 + { "(bad)", XX, XX, XX },
2275 + { "(bad)", XX, XX, XX },
2276 + { "(bad)", XX, XX, XX },
2280 + { "incQ", Ev, XX, XX },
2281 + { "decQ", Ev, XX, XX },
2282 + { "callT", indirEv, XX, XX },
2283 + { "JcallT", indirEp, XX, XX },
2284 + { "jmpT", indirEv, XX, XX },
2285 + { "JjmpT", indirEp, XX, XX },
2286 + { "pushU", Ev, XX, XX },
2287 + { "(bad)", XX, XX, XX },
2291 + { "sldtQ", Ev, XX, XX },
2292 + { "strQ", Ev, XX, XX },
2293 + { "lldt", Ew, XX, XX },
2294 + { "ltr", Ew, XX, XX },
2295 + { "verr", Ew, XX, XX },
2296 + { "verw", Ew, XX, XX },
2297 + { "(bad)", XX, XX, XX },
2298 + { "(bad)", XX, XX, XX }
2302 + { "sgdtIQ", VMX_Fixup, 0, XX, XX },
2303 + { "sidtIQ", PNI_Fixup, 0, XX, XX },
2304 + { "lgdt{Q|Q||}", M, XX, XX },
2305 + { "lidt{Q|Q||}", SVME_Fixup, 0, XX, XX },
2306 + { "smswQ", Ev, XX, XX },
2307 + { "(bad)", XX, XX, XX },
2308 + { "lmsw", Ew, XX, XX },
2309 + { "invlpg", INVLPG_Fixup, w_mode, XX, XX },
2313 + { "(bad)", XX, XX, XX },
2314 + { "(bad)", XX, XX, XX },
2315 + { "(bad)", XX, XX, XX },
2316 + { "(bad)", XX, XX, XX },
2317 + { "btQ", Ev, Ib, XX },
2318 + { "btsQ", Ev, Ib, XX },
2319 + { "btrQ", Ev, Ib, XX },
2320 + { "btcQ", Ev, Ib, XX },
2324 + { "(bad)", XX, XX, XX },
2325 + { "cmpxchg8b", Eq, XX, XX },
2326 + { "(bad)", XX, XX, XX },
2327 + { "(bad)", XX, XX, XX },
2328 + { "(bad)", XX, XX, XX },
2329 + { "(bad)", XX, XX, XX },
2330 + { "", VM, XX, XX }, /* See OP_VMX. */
2331 + { "vmptrst", Eq, XX, XX },
2335 + { "(bad)", XX, XX, XX },
2336 + { "(bad)", XX, XX, XX },
2337 + { "psrlw", MS, Ib, XX },
2338 + { "(bad)", XX, XX, XX },
2339 + { "psraw", MS, Ib, XX },
2340 + { "(bad)", XX, XX, XX },
2341 + { "psllw", MS, Ib, XX },
2342 + { "(bad)", XX, XX, XX },
2346 + { "(bad)", XX, XX, XX },
2347 + { "(bad)", XX, XX, XX },
2348 + { "psrld", MS, Ib, XX },
2349 + { "(bad)", XX, XX, XX },
2350 + { "psrad", MS, Ib, XX },
2351 + { "(bad)", XX, XX, XX },
2352 + { "pslld", MS, Ib, XX },
2353 + { "(bad)", XX, XX, XX },
2357 + { "(bad)", XX, XX, XX },
2358 + { "(bad)", XX, XX, XX },
2359 + { "psrlq", MS, Ib, XX },
2360 + { "psrldq", MS, Ib, XX },
2361 + { "(bad)", XX, XX, XX },
2362 + { "(bad)", XX, XX, XX },
2363 + { "psllq", MS, Ib, XX },
2364 + { "pslldq", MS, Ib, XX },
2368 + { "fxsave", Ev, XX, XX },
2369 + { "fxrstor", Ev, XX, XX },
2370 + { "ldmxcsr", Ev, XX, XX },
2371 + { "stmxcsr", Ev, XX, XX },
2372 + { "(bad)", XX, XX, XX },
2373 + { "lfence", OP_0fae, 0, XX, XX },
2374 + { "mfence", OP_0fae, 0, XX, XX },
2375 + { "clflush", OP_0fae, 0, XX, XX },
2379 + { "prefetchnta", Ev, XX, XX },
2380 + { "prefetcht0", Ev, XX, XX },
2381 + { "prefetcht1", Ev, XX, XX },
2382 + { "prefetcht2", Ev, XX, XX },
2383 + { "(bad)", XX, XX, XX },
2384 + { "(bad)", XX, XX, XX },
2385 + { "(bad)", XX, XX, XX },
2386 + { "(bad)", XX, XX, XX },
2390 + { "prefetch", Eb, XX, XX },
2391 + { "prefetchw", Eb, XX, XX },
2392 + { "(bad)", XX, XX, XX },
2393 + { "(bad)", XX, XX, XX },
2394 + { "(bad)", XX, XX, XX },
2395 + { "(bad)", XX, XX, XX },
2396 + { "(bad)", XX, XX, XX },
2397 + { "(bad)", XX, XX, XX },
2401 + { "xstore-rng", OP_0f07, 0, XX, XX },
2402 + { "xcrypt-ecb", OP_0f07, 0, XX, XX },
2403 + { "xcrypt-cbc", OP_0f07, 0, XX, XX },
2404 + { "xcrypt-ctr", OP_0f07, 0, XX, XX },
2405 + { "xcrypt-cfb", OP_0f07, 0, XX, XX },
2406 + { "xcrypt-ofb", OP_0f07, 0, XX, XX },
2407 + { "(bad)", OP_0f07, 0, XX, XX },
2408 + { "(bad)", OP_0f07, 0, XX, XX },
2412 + { "montmul", OP_0f07, 0, XX, XX },
2413 + { "xsha1", OP_0f07, 0, XX, XX },
2414 + { "xsha256", OP_0f07, 0, XX, XX },
2415 + { "(bad)", OP_0f07, 0, XX, XX },
2416 + { "(bad)", OP_0f07, 0, XX, XX },
2417 + { "(bad)", OP_0f07, 0, XX, XX },
2418 + { "(bad)", OP_0f07, 0, XX, XX },
2419 + { "(bad)", OP_0f07, 0, XX, XX },
2423 +static const struct dis386 prefix_user_table[][4] = {
2426 + { "addps", XM, EX, XX },
2427 + { "addss", XM, EX, XX },
2428 + { "addpd", XM, EX, XX },
2429 + { "addsd", XM, EX, XX },
2433 + { "", XM, EX, OPSIMD }, /* See OP_SIMD_SUFFIX. */
2434 + { "", XM, EX, OPSIMD },
2435 + { "", XM, EX, OPSIMD },
2436 + { "", XM, EX, OPSIMD },
2440 + { "cvtpi2ps", XM, EM, XX },
2441 + { "cvtsi2ssY", XM, Ev, XX },
2442 + { "cvtpi2pd", XM, EM, XX },
2443 + { "cvtsi2sdY", XM, Ev, XX },
2447 + { "cvtps2pi", MX, EX, XX },
2448 + { "cvtss2siY", Gv, EX, XX },
2449 + { "cvtpd2pi", MX, EX, XX },
2450 + { "cvtsd2siY", Gv, EX, XX },
2454 + { "cvttps2pi", MX, EX, XX },
2455 + { "cvttss2siY", Gv, EX, XX },
2456 + { "cvttpd2pi", MX, EX, XX },
2457 + { "cvttsd2siY", Gv, EX, XX },
2461 + { "divps", XM, EX, XX },
2462 + { "divss", XM, EX, XX },
2463 + { "divpd", XM, EX, XX },
2464 + { "divsd", XM, EX, XX },
2468 + { "maxps", XM, EX, XX },
2469 + { "maxss", XM, EX, XX },
2470 + { "maxpd", XM, EX, XX },
2471 + { "maxsd", XM, EX, XX },
2475 + { "minps", XM, EX, XX },
2476 + { "minss", XM, EX, XX },
2477 + { "minpd", XM, EX, XX },
2478 + { "minsd", XM, EX, XX },
2482 + { "movups", XM, EX, XX },
2483 + { "movss", XM, EX, XX },
2484 + { "movupd", XM, EX, XX },
2485 + { "movsd", XM, EX, XX },
2489 + { "movups", EX, XM, XX },
2490 + { "movss", EX, XM, XX },
2491 + { "movupd", EX, XM, XX },
2492 + { "movsd", EX, XM, XX },
2496 + { "mulps", XM, EX, XX },
2497 + { "mulss", XM, EX, XX },
2498 + { "mulpd", XM, EX, XX },
2499 + { "mulsd", XM, EX, XX },
2503 + { "rcpps", XM, EX, XX },
2504 + { "rcpss", XM, EX, XX },
2505 + { "(bad)", XM, EX, XX },
2506 + { "(bad)", XM, EX, XX },
2510 + { "rsqrtps", XM, EX, XX },
2511 + { "rsqrtss", XM, EX, XX },
2512 + { "(bad)", XM, EX, XX },
2513 + { "(bad)", XM, EX, XX },
2517 + { "sqrtps", XM, EX, XX },
2518 + { "sqrtss", XM, EX, XX },
2519 + { "sqrtpd", XM, EX, XX },
2520 + { "sqrtsd", XM, EX, XX },
2524 + { "subps", XM, EX, XX },
2525 + { "subss", XM, EX, XX },
2526 + { "subpd", XM, EX, XX },
2527 + { "subsd", XM, EX, XX },
2531 + { "(bad)", XM, EX, XX },
2532 + { "cvtdq2pd", XM, EX, XX },
2533 + { "cvttpd2dq", XM, EX, XX },
2534 + { "cvtpd2dq", XM, EX, XX },
2538 + { "cvtdq2ps", XM, EX, XX },
2539 + { "cvttps2dq",XM, EX, XX },
2540 + { "cvtps2dq",XM, EX, XX },
2541 + { "(bad)", XM, EX, XX },
2545 + { "cvtps2pd", XM, EX, XX },
2546 + { "cvtss2sd", XM, EX, XX },
2547 + { "cvtpd2ps", XM, EX, XX },
2548 + { "cvtsd2ss", XM, EX, XX },
2552 + { "maskmovq", MX, MS, XX },
2553 + { "(bad)", XM, EX, XX },
2554 + { "maskmovdqu", XM, EX, XX },
2555 + { "(bad)", XM, EX, XX },
2559 + { "movq", MX, EM, XX },
2560 + { "movdqu", XM, EX, XX },
2561 + { "movdqa", XM, EX, XX },
2562 + { "(bad)", XM, EX, XX },
2566 + { "movq", EM, MX, XX },
2567 + { "movdqu", EX, XM, XX },
2568 + { "movdqa", EX, XM, XX },
2569 + { "(bad)", EX, XM, XX },
2573 + { "(bad)", EX, XM, XX },
2574 + { "movq2dq", XM, MS, XX },
2575 + { "movq", EX, XM, XX },
2576 + { "movdq2q", MX, XS, XX },
2580 + { "pshufw", MX, EM, Ib },
2581 + { "pshufhw", XM, EX, Ib },
2582 + { "pshufd", XM, EX, Ib },
2583 + { "pshuflw", XM, EX, Ib },
2587 + { "movd", Edq, MX, XX },
2588 + { "movq", XM, EX, XX },
2589 + { "movd", Edq, XM, XX },
2590 + { "(bad)", Ed, XM, XX },
2594 + { "(bad)", MX, EX, XX },
2595 + { "(bad)", XM, EX, XX },
2596 + { "punpckhqdq", XM, EX, XX },
2597 + { "(bad)", XM, EX, XX },
2601 + { "movntq", EM, MX, XX },
2602 + { "(bad)", EM, XM, XX },
2603 + { "movntdq", EM, XM, XX },
2604 + { "(bad)", EM, XM, XX },
2608 + { "(bad)", MX, EX, XX },
2609 + { "(bad)", XM, EX, XX },
2610 + { "punpcklqdq", XM, EX, XX },
2611 + { "(bad)", XM, EX, XX },
2615 + { "(bad)", MX, EX, XX },
2616 + { "(bad)", XM, EX, XX },
2617 + { "addsubpd", XM, EX, XX },
2618 + { "addsubps", XM, EX, XX },
2622 + { "(bad)", MX, EX, XX },
2623 + { "(bad)", XM, EX, XX },
2624 + { "haddpd", XM, EX, XX },
2625 + { "haddps", XM, EX, XX },
2629 + { "(bad)", MX, EX, XX },
2630 + { "(bad)", XM, EX, XX },
2631 + { "hsubpd", XM, EX, XX },
2632 + { "hsubps", XM, EX, XX },
2636 + { "movlpX", XM, EX, SIMD_Fixup, 'h' }, /* really only 2 operands */
2637 + { "movsldup", XM, EX, XX },
2638 + { "movlpd", XM, EX, XX },
2639 + { "movddup", XM, EX, XX },
2643 + { "movhpX", XM, EX, SIMD_Fixup, 'l' },
2644 + { "movshdup", XM, EX, XX },
2645 + { "movhpd", XM, EX, XX },
2646 + { "(bad)", XM, EX, XX },
2650 + { "(bad)", XM, EX, XX },
2651 + { "(bad)", XM, EX, XX },
2652 + { "(bad)", XM, EX, XX },
2653 + { "lddqu", XM, M, XX },
2657 +static const struct dis386 x86_64_table[][2] = {
2659 + { "arpl", Ew, Gw, XX },
2660 + { "movs{||lq|xd}", Gv, Ed, XX },
2665 +#define INTERNAL_DISASSEMBLER_ERROR "<internal disassembler error>"
2666 +#else /* __KERNEL__ */
2667 +#define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
2668 +#endif /* __KERNEL__ */
2676 + used_prefixes = 0;
2680 + FETCH_DATA (the_info, codep + 1);
2684 + /* REX prefixes family. */
2707 + prefixes |= PREFIX_REPZ;
2710 + prefixes |= PREFIX_REPNZ;
2713 + prefixes |= PREFIX_LOCK;
2716 + prefixes |= PREFIX_CS;
2719 + prefixes |= PREFIX_SS;
2722 + prefixes |= PREFIX_DS;
2725 + prefixes |= PREFIX_ES;
2728 + prefixes |= PREFIX_FS;
2731 + prefixes |= PREFIX_GS;
2734 + prefixes |= PREFIX_DATA;
2737 + prefixes |= PREFIX_ADDR;
2739 + case FWAIT_OPCODE:
2740 + /* fwait is really an instruction. If there are prefixes
2741 + before the fwait, they belong to the fwait, *not* to the
2742 + following instruction. */
2745 + prefixes |= PREFIX_FWAIT;
2749 + prefixes = PREFIX_FWAIT;
2754 + /* Rex is ignored when followed by another prefix. */
2757 + oappend (prefix_name (rex, 0));
2765 +/* Return the name of the prefix byte PREF, or NULL if PREF is not a
2768 +static const char *
2769 +prefix_name (int pref, int sizeflag)
2773 + /* REX prefixes family. */
2805 + return "rex64XYZ";
2825 + return (sizeflag & DFLAG) ? "data16" : "data32";
2828 + return (sizeflag & AFLAG) ? "addr32" : "addr64";
2830 + return (sizeflag & AFLAG) ? "addr16" : "addr32";
2831 + case FWAIT_OPCODE:
2838 +static char op1out[100], op2out[100], op3out[100];
2839 +static int op_ad, op_index[3];
2840 +static int two_source_ops;
2841 +static bfd_vma op_address[3];
2842 +static bfd_vma op_riprel[3];
2843 +static bfd_vma start_pc;
2846 + * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
2847 + * (see topic "Redundant prefixes" in the "Differences from 8086"
2848 + * section of the "Virtual 8086 Mode" chapter.)
2849 + * 'pc' should be the address of this instruction, it will
2850 + * be used to print the target address if this is a relative jump or call
2851 + * The function returns the length of this instruction in bytes.
2854 +static char intel_syntax;
2855 +static char open_char;
2856 +static char close_char;
2857 +static char separator_char;
2858 +static char scale_char;
2860 +/* Here for backwards compatibility. When gdb stops using
2861 + print_insn_i386_att and print_insn_i386_intel these functions can
2862 + disappear, and print_insn_i386 be merged into print_insn. */
2864 +print_insn_i386_att (bfd_vma pc, disassemble_info *info)
2868 + return print_insn (pc, info);
2872 +print_insn_i386_intel (bfd_vma pc, disassemble_info *info)
2876 + return print_insn (pc, info);
2880 +print_insn_i386 (bfd_vma pc, disassemble_info *info)
2882 + intel_syntax = -1;
2884 + return print_insn (pc, info);
2888 +print_insn (bfd_vma pc, disassemble_info *info)
2890 + const struct dis386 *dp;
2892 + char *first, *second, *third;
2894 + unsigned char uses_SSE_prefix, uses_LOCK_prefix;
2897 + struct dis_private priv;
2899 + mode_64bit = (info->mach == bfd_mach_x86_64_intel_syntax
2900 + || info->mach == bfd_mach_x86_64);
2902 + if (intel_syntax == (char) -1)
2903 + intel_syntax = (info->mach == bfd_mach_i386_i386_intel_syntax
2904 + || info->mach == bfd_mach_x86_64_intel_syntax);
2906 + if (info->mach == bfd_mach_i386_i386
2907 + || info->mach == bfd_mach_x86_64
2908 + || info->mach == bfd_mach_i386_i386_intel_syntax
2909 + || info->mach == bfd_mach_x86_64_intel_syntax)
2910 + priv.orig_sizeflag = AFLAG | DFLAG;
2911 + else if (info->mach == bfd_mach_i386_i8086)
2912 + priv.orig_sizeflag = 0;
2916 + for (p = info->disassembler_options; p != NULL; )
2918 + if (strncmp (p, "x86-64", 6) == 0)
2921 + priv.orig_sizeflag = AFLAG | DFLAG;
2923 + else if (strncmp (p, "i386", 4) == 0)
2926 + priv.orig_sizeflag = AFLAG | DFLAG;
2928 + else if (strncmp (p, "i8086", 5) == 0)
2931 + priv.orig_sizeflag = 0;
2933 + else if (strncmp (p, "intel", 5) == 0)
2937 + else if (strncmp (p, "att", 3) == 0)
2941 + else if (strncmp (p, "addr", 4) == 0)
2943 + if (p[4] == '1' && p[5] == '6')
2944 + priv.orig_sizeflag &= ~AFLAG;
2945 + else if (p[4] == '3' && p[5] == '2')
2946 + priv.orig_sizeflag |= AFLAG;
2948 + else if (strncmp (p, "data", 4) == 0)
2950 + if (p[4] == '1' && p[5] == '6')
2951 + priv.orig_sizeflag &= ~DFLAG;
2952 + else if (p[4] == '3' && p[5] == '2')
2953 + priv.orig_sizeflag |= DFLAG;
2955 + else if (strncmp (p, "suffix", 6) == 0)
2956 + priv.orig_sizeflag |= SUFFIX_ALWAYS;
2958 + p = strchr (p, ',');
2965 + names64 = intel_names64;
2966 + names32 = intel_names32;
2967 + names16 = intel_names16;
2968 + names8 = intel_names8;
2969 + names8rex = intel_names8rex;
2970 + names_seg = intel_names_seg;
2971 + index16 = intel_index16;
2974 + separator_char = '+';
2979 + names64 = att_names64;
2980 + names32 = att_names32;
2981 + names16 = att_names16;
2982 + names8 = att_names8;
2983 + names8rex = att_names8rex;
2984 + names_seg = att_names_seg;
2985 + index16 = att_index16;
2988 + separator_char = ',';
2992 + /* The output looks better if we put 7 bytes on a line, since that
2993 + puts most long word instructions on a single line. */
2994 + info->bytes_per_line = 7;
2996 + info->private_data = &priv;
2997 + priv.max_fetched = priv.the_buffer;
2998 + priv.insn_start = pc;
3005 + op_index[0] = op_index[1] = op_index[2] = -1;
3009 + start_codep = priv.the_buffer;
3010 + codep = priv.the_buffer;
3013 + if (setjmp (priv.bailout) != 0)
3017 + /* Getting here means we tried for data but didn't get it. That
3018 + means we have an incomplete instruction of some sort. Just
3019 + print the first byte as a prefix or a .byte pseudo-op. */
3020 + if (codep > priv.the_buffer)
3022 + name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
3024 + (*info->fprintf_func) (info->stream, "%s", name);
3027 + /* Just print the first byte as a .byte instruction. */
3028 + (*info->fprintf_func) (info->stream, ".byte 0x%x",
3029 + (unsigned int) priv.the_buffer[0]);
3037 +#endif /* __KERNEL__ */
3042 + insn_codep = codep;
3043 + sizeflag = priv.orig_sizeflag;
3045 + FETCH_DATA (info, codep + 1);
3046 + two_source_ops = (*codep == 0x62) || (*codep == 0xc8);
3048 + if ((prefixes & PREFIX_FWAIT)
3049 + && ((*codep < 0xd8) || (*codep > 0xdf)))
3053 + /* fwait not followed by floating point instruction. Print the
3054 + first prefix, which is probably fwait itself. */
3055 + name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
3057 + name = INTERNAL_DISASSEMBLER_ERROR;
3058 + (*info->fprintf_func) (info->stream, "%s", name);
3062 + if (*codep == 0x0f)
3064 + FETCH_DATA (info, codep + 2);
3065 + dp = &dis386_twobyte[*++codep];
3066 + need_modrm = twobyte_has_modrm[*codep];
3067 + uses_SSE_prefix = twobyte_uses_SSE_prefix[*codep];
3068 + uses_LOCK_prefix = (*codep & ~0x02) == 0x20;
3072 + dp = &dis386[*codep];
3073 + need_modrm = onebyte_has_modrm[*codep];
3074 + uses_SSE_prefix = 0;
3075 + uses_LOCK_prefix = 0;
3079 + if (!uses_SSE_prefix && (prefixes & PREFIX_REPZ))
3081 + oappend ("repz ");
3082 + used_prefixes |= PREFIX_REPZ;
3084 + if (!uses_SSE_prefix && (prefixes & PREFIX_REPNZ))
3086 + oappend ("repnz ");
3087 + used_prefixes |= PREFIX_REPNZ;
3089 + if (!uses_LOCK_prefix && (prefixes & PREFIX_LOCK))
3091 + oappend ("lock ");
3092 + used_prefixes |= PREFIX_LOCK;
3095 + if (prefixes & PREFIX_ADDR)
3097 + sizeflag ^= AFLAG;
3098 + if (dp->bytemode3 != loop_jcxz_mode || intel_syntax)
3100 + if ((sizeflag & AFLAG) || mode_64bit)
3101 + oappend ("addr32 ");
3103 + oappend ("addr16 ");
3104 + used_prefixes |= PREFIX_ADDR;
3108 + if (!uses_SSE_prefix && (prefixes & PREFIX_DATA))
3110 + sizeflag ^= DFLAG;
3111 + if (dp->bytemode3 == cond_jump_mode
3112 + && dp->bytemode1 == v_mode
3115 + if (sizeflag & DFLAG)
3116 + oappend ("data32 ");
3118 + oappend ("data16 ");
3119 + used_prefixes |= PREFIX_DATA;
3125 + FETCH_DATA (info, codep + 1);
3126 + mod = (*codep >> 6) & 3;
3127 + reg = (*codep >> 3) & 7;
3131 + if (dp->name == NULL && dp->bytemode1 == FLOATCODE)
3133 + dofloat (sizeflag);
3138 + if (dp->name == NULL)
3140 + switch (dp->bytemode1)
3143 + dp = &grps[dp->bytemode2][reg];
3146 + case USE_PREFIX_USER_TABLE:
3148 + used_prefixes |= (prefixes & PREFIX_REPZ);
3149 + if (prefixes & PREFIX_REPZ)
3153 + used_prefixes |= (prefixes & PREFIX_DATA);
3154 + if (prefixes & PREFIX_DATA)
3158 + used_prefixes |= (prefixes & PREFIX_REPNZ);
3159 + if (prefixes & PREFIX_REPNZ)
3163 + dp = &prefix_user_table[dp->bytemode2][index];
3166 + case X86_64_SPECIAL:
3167 + dp = &x86_64_table[dp->bytemode2][mode_64bit];
3171 + oappend (INTERNAL_DISASSEMBLER_ERROR);
3176 + if (putop (dp->name, sizeflag) == 0)
3181 + (*dp->op1) (dp->bytemode1, sizeflag);
3186 + (*dp->op2) (dp->bytemode2, sizeflag);
3191 + (*dp->op3) (dp->bytemode3, sizeflag);
3195 + /* See if any prefixes were not used. If so, print the first one
3196 + separately. If we don't do this, we'll wind up printing an
3197 + instruction stream which does not precisely correspond to the
3198 + bytes we are disassembling. */
3199 + if ((prefixes & ~used_prefixes) != 0)
3203 + name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
3205 + name = INTERNAL_DISASSEMBLER_ERROR;
3206 + (*info->fprintf_func) (info->stream, "%s", name);
3209 + if (rex & ~rex_used)
3212 + name = prefix_name (rex | 0x40, priv.orig_sizeflag);
3214 + name = INTERNAL_DISASSEMBLER_ERROR;
3215 + (*info->fprintf_func) (info->stream, "%s ", name);
3218 + obufp = obuf + strlen (obuf);
3219 + for (i = strlen (obuf); i < 6; i++)
3222 + (*info->fprintf_func) (info->stream, "%s", obuf);
3224 + /* The enter and bound instructions are printed with operands in the same
3225 + order as the intel book; everything else is printed in reverse order. */
3226 + if (intel_syntax || two_source_ops)
3231 + op_ad = op_index[0];
3232 + op_index[0] = op_index[2];
3233 + op_index[2] = op_ad;
3244 + if (op_index[0] != -1 && !op_riprel[0])
3245 + (*info->print_address_func) ((bfd_vma) op_address[op_index[0]], info);
3247 + (*info->fprintf_func) (info->stream, "%s", first);
3253 + (*info->fprintf_func) (info->stream, ",");
3254 + if (op_index[1] != -1 && !op_riprel[1])
3255 + (*info->print_address_func) ((bfd_vma) op_address[op_index[1]], info);
3257 + (*info->fprintf_func) (info->stream, "%s", second);
3263 + (*info->fprintf_func) (info->stream, ",");
3264 + if (op_index[2] != -1 && !op_riprel[2])
3265 + (*info->print_address_func) ((bfd_vma) op_address[op_index[2]], info);
3267 + (*info->fprintf_func) (info->stream, "%s", third);
3269 + for (i = 0; i < 3; i++)
3270 + if (op_index[i] != -1 && op_riprel[i])
3272 + (*info->fprintf_func) (info->stream, " # ");
3273 + (*info->print_address_func) ((bfd_vma) (start_pc + codep - start_codep
3274 + + op_address[op_index[i]]), info);
3276 + return codep - priv.the_buffer;
3279 +static const char *float_mem[] = {
3327 + "fisttp{ll||ll|}",
3354 +static const unsigned char float_mem_mode[] = {
3429 +#define ST OP_ST, 0
3430 +#define STi OP_STi, 0
3432 +#define FGRPd9_2 NULL, NULL, 0, NULL, 0, NULL, 0
3433 +#define FGRPd9_4 NULL, NULL, 1, NULL, 0, NULL, 0
3434 +#define FGRPd9_5 NULL, NULL, 2, NULL, 0, NULL, 0
3435 +#define FGRPd9_6 NULL, NULL, 3, NULL, 0, NULL, 0
3436 +#define FGRPd9_7 NULL, NULL, 4, NULL, 0, NULL, 0
3437 +#define FGRPda_5 NULL, NULL, 5, NULL, 0, NULL, 0
3438 +#define FGRPdb_4 NULL, NULL, 6, NULL, 0, NULL, 0
3439 +#define FGRPde_3 NULL, NULL, 7, NULL, 0, NULL, 0
3440 +#define FGRPdf_4 NULL, NULL, 8, NULL, 0, NULL, 0
3442 +static const struct dis386 float_reg[][8] = {
3445 + { "fadd", ST, STi, XX },
3446 + { "fmul", ST, STi, XX },
3447 + { "fcom", STi, XX, XX },
3448 + { "fcomp", STi, XX, XX },
3449 + { "fsub", ST, STi, XX },
3450 + { "fsubr", ST, STi, XX },
3451 + { "fdiv", ST, STi, XX },
3452 + { "fdivr", ST, STi, XX },
3456 + { "fld", STi, XX, XX },
3457 + { "fxch", STi, XX, XX },
3459 + { "(bad)", XX, XX, XX },
3467 + { "fcmovb", ST, STi, XX },
3468 + { "fcmove", ST, STi, XX },
3469 + { "fcmovbe",ST, STi, XX },
3470 + { "fcmovu", ST, STi, XX },
3471 + { "(bad)", XX, XX, XX },
3473 + { "(bad)", XX, XX, XX },
3474 + { "(bad)", XX, XX, XX },
3478 + { "fcmovnb",ST, STi, XX },
3479 + { "fcmovne",ST, STi, XX },
3480 + { "fcmovnbe",ST, STi, XX },
3481 + { "fcmovnu",ST, STi, XX },
3483 + { "fucomi", ST, STi, XX },
3484 + { "fcomi", ST, STi, XX },
3485 + { "(bad)", XX, XX, XX },
3489 + { "fadd", STi, ST, XX },
3490 + { "fmul", STi, ST, XX },
3491 + { "(bad)", XX, XX, XX },
3492 + { "(bad)", XX, XX, XX },
3493 +#if UNIXWARE_COMPAT
3494 + { "fsub", STi, ST, XX },
3495 + { "fsubr", STi, ST, XX },
3496 + { "fdiv", STi, ST, XX },
3497 + { "fdivr", STi, ST, XX },
3499 + { "fsubr", STi, ST, XX },
3500 + { "fsub", STi, ST, XX },
3501 + { "fdivr", STi, ST, XX },
3502 + { "fdiv", STi, ST, XX },
3507 + { "ffree", STi, XX, XX },
3508 + { "(bad)", XX, XX, XX },
3509 + { "fst", STi, XX, XX },
3510 + { "fstp", STi, XX, XX },
3511 + { "fucom", STi, XX, XX },
3512 + { "fucomp", STi, XX, XX },
3513 + { "(bad)", XX, XX, XX },
3514 + { "(bad)", XX, XX, XX },
3518 + { "faddp", STi, ST, XX },
3519 + { "fmulp", STi, ST, XX },
3520 + { "(bad)", XX, XX, XX },
3522 +#if UNIXWARE_COMPAT
3523 + { "fsubp", STi, ST, XX },
3524 + { "fsubrp", STi, ST, XX },
3525 + { "fdivp", STi, ST, XX },
3526 + { "fdivrp", STi, ST, XX },
3528 + { "fsubrp", STi, ST, XX },
3529 + { "fsubp", STi, ST, XX },
3530 + { "fdivrp", STi, ST, XX },
3531 + { "fdivp", STi, ST, XX },
3536 + { "ffreep", STi, XX, XX },
3537 + { "(bad)", XX, XX, XX },
3538 + { "(bad)", XX, XX, XX },
3539 + { "(bad)", XX, XX, XX },
3541 + { "fucomip",ST, STi, XX },
3542 + { "fcomip", ST, STi, XX },
3543 + { "(bad)", XX, XX, XX },
3547 +static char *fgrps[][8] = {
3550 + "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
3555 + "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
3560 + "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
3565 + "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
3570 + "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
3575 + "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
3580 + "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
3581 + "fNsetpm(287 only)","(bad)","(bad)","(bad)",
3586 + "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
3591 + "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
3596 +dofloat (int sizeflag)
3598 + const struct dis386 *dp;
3599 + unsigned char floatop;
3601 + floatop = codep[-1];
3605 + int fp_indx = (floatop - 0xd8) * 8 + reg;
3607 + putop (float_mem[fp_indx], sizeflag);
3609 + OP_E (float_mem_mode[fp_indx], sizeflag);
3612 + /* Skip mod/rm byte. */
3616 + dp = &float_reg[floatop - 0xd8][reg];
3617 + if (dp->name == NULL)
3619 + putop (fgrps[dp->bytemode1][rm], sizeflag);
3621 + /* Instruction fnstsw is only one with strange arg. */
3622 + if (floatop == 0xdf && codep[-1] == 0xe0)
3623 + strcpy (op1out, names16[0]);
3627 + putop (dp->name, sizeflag);
3631 + (*dp->op1) (dp->bytemode1, sizeflag);
3634 + (*dp->op2) (dp->bytemode2, sizeflag);
3639 +OP_ST (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
3645 +OP_STi (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
3647 + sprintf (scratchbuf, "%%st(%d)", rm);
3648 + oappend (scratchbuf + intel_syntax);
3651 +/* Capital letters in template are macros. */
3653 +putop (const char *template, int sizeflag)
3658 + for (p = template; *p; p++)
3673 + while (*++p != '|')
3677 + /* Alternative not valid. */
3678 + strcpy (obuf, "(bad)");
3682 + else if (*p == '\0')
3687 + /* Fall through. */
3692 + while (*++p != '}')
3703 + if (mod != 3 || (sizeflag & SUFFIX_ALWAYS))
3709 + if (sizeflag & SUFFIX_ALWAYS)
3713 + if (intel_syntax && !alt)
3715 + if ((prefixes & PREFIX_DATA) || (sizeflag & SUFFIX_ALWAYS))
3717 + if (sizeflag & DFLAG)
3718 + *obufp++ = intel_syntax ? 'd' : 'l';
3720 + *obufp++ = intel_syntax ? 'w' : 's';
3721 + used_prefixes |= (prefixes & PREFIX_DATA);
3724 + case 'E': /* For jcxz/jecxz */
3727 + if (sizeflag & AFLAG)
3733 + if (sizeflag & AFLAG)
3735 + used_prefixes |= (prefixes & PREFIX_ADDR);
3740 + if ((prefixes & PREFIX_ADDR) || (sizeflag & SUFFIX_ALWAYS))
3742 + if (sizeflag & AFLAG)
3743 + *obufp++ = mode_64bit ? 'q' : 'l';
3745 + *obufp++ = mode_64bit ? 'l' : 'w';
3746 + used_prefixes |= (prefixes & PREFIX_ADDR);
3752 + if ((prefixes & (PREFIX_CS | PREFIX_DS)) == PREFIX_CS
3753 + || (prefixes & (PREFIX_CS | PREFIX_DS)) == PREFIX_DS)
3755 + used_prefixes |= prefixes & (PREFIX_CS | PREFIX_DS);
3758 + if (prefixes & PREFIX_DS)
3772 + if (sizeflag & SUFFIX_ALWAYS)
3776 + if ((prefixes & PREFIX_FWAIT) == 0)
3779 + used_prefixes |= PREFIX_FWAIT;
3782 + USED_REX (REX_MODE64);
3783 + if (rex & REX_MODE64)
3796 + /* Fall through. */
3800 + if ((prefixes & PREFIX_DATA)
3801 + || (rex & REX_MODE64)
3802 + || (sizeflag & SUFFIX_ALWAYS))
3804 + USED_REX (REX_MODE64);
3805 + if (rex & REX_MODE64)
3809 + if (sizeflag & DFLAG)
3813 + used_prefixes |= (prefixes & PREFIX_DATA);
3825 + /* Fall through. */
3827 + if (intel_syntax && !alt)
3829 + USED_REX (REX_MODE64);
3830 + if (mod != 3 || (sizeflag & SUFFIX_ALWAYS))
3832 + if (rex & REX_MODE64)
3836 + if (sizeflag & DFLAG)
3837 + *obufp++ = intel_syntax ? 'd' : 'l';
3840 + used_prefixes |= (prefixes & PREFIX_DATA);
3845 + USED_REX (REX_MODE64);
3848 + if (rex & REX_MODE64)
3853 + else if (sizeflag & DFLAG)
3866 + if (rex & REX_MODE64)
3868 + else if (sizeflag & DFLAG)
3873 + if (!(rex & REX_MODE64))
3874 + used_prefixes |= (prefixes & PREFIX_DATA);
3879 + if (sizeflag & SUFFIX_ALWAYS)
3881 + if (rex & REX_MODE64)
3885 + if (sizeflag & DFLAG)
3889 + used_prefixes |= (prefixes & PREFIX_DATA);
3894 + if (prefixes & PREFIX_DATA)
3898 + used_prefixes |= (prefixes & PREFIX_DATA);
3903 + if (rex & REX_MODE64)
3905 + USED_REX (REX_MODE64);
3909 + /* implicit operand size 'l' for i386 or 'q' for x86-64 */
3911 + /* operand size flag for cwtl, cbtw */
3915 + else if (sizeflag & DFLAG)
3926 + if (sizeflag & DFLAG)
3937 + used_prefixes |= (prefixes & PREFIX_DATA);
3947 +oappend (const char *s)
3949 + strcpy (obufp, s);
3950 + obufp += strlen (s);
3956 + if (prefixes & PREFIX_CS)
3958 + used_prefixes |= PREFIX_CS;
3959 + oappend ("%cs:" + intel_syntax);
3961 + if (prefixes & PREFIX_DS)
3963 + used_prefixes |= PREFIX_DS;
3964 + oappend ("%ds:" + intel_syntax);
3966 + if (prefixes & PREFIX_SS)
3968 + used_prefixes |= PREFIX_SS;
3969 + oappend ("%ss:" + intel_syntax);
3971 + if (prefixes & PREFIX_ES)
3973 + used_prefixes |= PREFIX_ES;
3974 + oappend ("%es:" + intel_syntax);
3976 + if (prefixes & PREFIX_FS)
3978 + used_prefixes |= PREFIX_FS;
3979 + oappend ("%fs:" + intel_syntax);
3981 + if (prefixes & PREFIX_GS)
3983 + used_prefixes |= PREFIX_GS;
3984 + oappend ("%gs:" + intel_syntax);
3989 +OP_indirE (int bytemode, int sizeflag)
3991 + if (!intel_syntax)
3993 + OP_E (bytemode, sizeflag);
3997 +print_operand_value (char *buf, int hex, bfd_vma disp)
4007 + sprintf_vma (tmp, disp);
4008 + for (i = 0; tmp[i] == '0' && tmp[i + 1]; i++);
4009 + strcpy (buf + 2, tmp + i);
4013 + bfd_signed_vma v = disp;
4020 + /* Check for possible overflow on 0x8000000000000000. */
4023 + strcpy (buf, "9223372036854775808");
4029 + strcpy (buf, "0");
4037 + tmp[28 - i] = (v % 10) + '0';
4041 + strcpy (buf, tmp + 29 - i);
4047 + sprintf (buf, "0x%x", (unsigned int) disp);
4049 + sprintf (buf, "%d", (int) disp);
4054 +OP_E (int bytemode, int sizeflag)
4059 + USED_REX (REX_EXTZ);
4060 + if (rex & REX_EXTZ)
4063 + /* Skip mod/rm byte. */
4074 + oappend (names8rex[rm + add]);
4076 + oappend (names8[rm + add]);
4079 + oappend (names16[rm + add]);
4082 + oappend (names32[rm + add]);
4085 + oappend (names64[rm + add]);
4089 + oappend (names64[rm + add]);
4091 + oappend (names32[rm + add]);
4093 + case branch_v_mode:
4095 + oappend (names64[rm + add]);
4098 + if ((sizeflag & DFLAG) || bytemode != branch_v_mode)
4099 + oappend (names32[rm + add]);
4101 + oappend (names16[rm + add]);
4102 + used_prefixes |= (prefixes & PREFIX_DATA);
4108 + USED_REX (REX_MODE64);
4109 + if (rex & REX_MODE64)
4110 + oappend (names64[rm + add]);
4111 + else if ((sizeflag & DFLAG) || bytemode != v_mode)
4112 + oappend (names32[rm + add]);
4114 + oappend (names16[rm + add]);
4115 + used_prefixes |= (prefixes & PREFIX_DATA);
4120 + oappend (INTERNAL_DISASSEMBLER_ERROR);
4129 + if ((sizeflag & AFLAG) || mode_64bit) /* 32 bit address mode */
4144 + FETCH_DATA (the_info, codep + 1);
4145 + index = (*codep >> 3) & 7;
4146 + if (mode_64bit || index != 0x4)
4147 + /* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
4148 + scale = (*codep >> 6) & 3;
4149 + base = *codep & 7;
4150 + USED_REX (REX_EXTY);
4151 + if (rex & REX_EXTY)
4160 + if ((base & 7) == 5)
4163 + if (mode_64bit && !havesib)
4169 + FETCH_DATA (the_info, codep + 1);
4171 + if ((disp & 0x80) != 0)
4179 + if (!intel_syntax)
4180 + if (mod != 0 || (base & 7) == 5)
4182 + print_operand_value (scratchbuf, !riprel, disp);
4183 + oappend (scratchbuf);
4187 + oappend ("(%rip)");
4191 + if (havebase || (havesib && (index != 4 || scale != 0)))
4198 + oappend ("BYTE PTR ");
4202 + oappend ("WORD PTR ");
4204 + case branch_v_mode:
4207 + USED_REX (REX_MODE64);
4208 + if (rex & REX_MODE64)
4209 + oappend ("QWORD PTR ");
4210 + else if ((sizeflag & DFLAG) || bytemode == dq_mode)
4211 + oappend ("DWORD PTR ");
4213 + oappend ("WORD PTR ");
4214 + used_prefixes |= (prefixes & PREFIX_DATA);
4217 + oappend ("DWORD PTR ");
4220 + oappend ("QWORD PTR ");
4224 + oappend ("QWORD PTR ");
4226 + oappend ("DWORD PTR ");
4229 + if (sizeflag & DFLAG)
4231 + used_prefixes |= (prefixes & PREFIX_DATA);
4232 + oappend ("FWORD PTR ");
4235 + oappend ("DWORD PTR ");
4238 + oappend ("TBYTE PTR ");
4241 + oappend ("XMMWORD PTR ");
4247 + *obufp++ = open_char;
4248 + if (intel_syntax && riprel)
4249 + oappend ("rip + ");
4252 + oappend (mode_64bit && (sizeflag & AFLAG)
4253 + ? names64[base] : names32[base]);
4258 + if (!intel_syntax || havebase)
4260 + *obufp++ = separator_char;
4263 + oappend (mode_64bit && (sizeflag & AFLAG)
4264 + ? names64[index] : names32[index]);
4266 + if (scale != 0 || (!intel_syntax && index != 4))
4268 + *obufp++ = scale_char;
4270 + sprintf (scratchbuf, "%d", 1 << scale);
4271 + oappend (scratchbuf);
4274 + if (intel_syntax && disp)
4276 + if ((bfd_signed_vma) disp > 0)
4281 + else if (mod != 1)
4285 + disp = - (bfd_signed_vma) disp;
4288 + print_operand_value (scratchbuf, mod != 1, disp);
4289 + oappend (scratchbuf);
4292 + *obufp++ = close_char;
4295 + else if (intel_syntax)
4297 + if (mod != 0 || (base & 7) == 5)
4299 + if (prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
4300 + | PREFIX_ES | PREFIX_FS | PREFIX_GS))
4304 + oappend (names_seg[ds_reg - es_reg]);
4307 + print_operand_value (scratchbuf, 1, disp);
4308 + oappend (scratchbuf);
4313 + { /* 16 bit address mode */
4320 + if ((disp & 0x8000) != 0)
4325 + FETCH_DATA (the_info, codep + 1);
4327 + if ((disp & 0x80) != 0)
4332 + if ((disp & 0x8000) != 0)
4337 + if (!intel_syntax)
4338 + if (mod != 0 || rm == 6)
4340 + print_operand_value (scratchbuf, 0, disp);
4341 + oappend (scratchbuf);
4344 + if (mod != 0 || rm != 6)
4346 + *obufp++ = open_char;
4348 + oappend (index16[rm]);
4349 + if (intel_syntax && disp)
4351 + if ((bfd_signed_vma) disp > 0)
4356 + else if (mod != 1)
4360 + disp = - (bfd_signed_vma) disp;
4363 + print_operand_value (scratchbuf, mod != 1, disp);
4364 + oappend (scratchbuf);
4367 + *obufp++ = close_char;
4370 + else if (intel_syntax)
4372 + if (prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
4373 + | PREFIX_ES | PREFIX_FS | PREFIX_GS))
4377 + oappend (names_seg[ds_reg - es_reg]);
4380 + print_operand_value (scratchbuf, 1, disp & 0xffff);
4381 + oappend (scratchbuf);
4387 +OP_G (int bytemode, int sizeflag)
4390 + USED_REX (REX_EXTX);
4391 + if (rex & REX_EXTX)
4398 + oappend (names8rex[reg + add]);
4400 + oappend (names8[reg + add]);
4403 + oappend (names16[reg + add]);
4406 + oappend (names32[reg + add]);
4409 + oappend (names64[reg + add]);
4414 + USED_REX (REX_MODE64);
4415 + if (rex & REX_MODE64)
4416 + oappend (names64[reg + add]);
4417 + else if ((sizeflag & DFLAG) || bytemode != v_mode)
4418 + oappend (names32[reg + add]);
4420 + oappend (names16[reg + add]);
4421 + used_prefixes |= (prefixes & PREFIX_DATA);
4425 + oappend (names64[reg + add]);
4427 + oappend (names32[reg + add]);
4430 + oappend (INTERNAL_DISASSEMBLER_ERROR);
4443 + FETCH_DATA (the_info, codep + 8);
4444 + a = *codep++ & 0xff;
4445 + a |= (*codep++ & 0xff) << 8;
4446 + a |= (*codep++ & 0xff) << 16;
4447 + a |= (*codep++ & 0xff) << 24;
4448 + b = *codep++ & 0xff;
4449 + b |= (*codep++ & 0xff) << 8;
4450 + b |= (*codep++ & 0xff) << 16;
4451 + b |= (*codep++ & 0xff) << 24;
4452 + x = a + ((bfd_vma) b << 32);
4460 +static bfd_signed_vma
4463 + bfd_signed_vma x = 0;
4465 + FETCH_DATA (the_info, codep + 4);
4466 + x = *codep++ & (bfd_signed_vma) 0xff;
4467 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 8;
4468 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 16;
4469 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 24;
4473 +static bfd_signed_vma
4476 + bfd_signed_vma x = 0;
4478 + FETCH_DATA (the_info, codep + 4);
4479 + x = *codep++ & (bfd_signed_vma) 0xff;
4480 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 8;
4481 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 16;
4482 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 24;
4484 + x = (x ^ ((bfd_signed_vma) 1 << 31)) - ((bfd_signed_vma) 1 << 31);
4494 + FETCH_DATA (the_info, codep + 2);
4495 + x = *codep++ & 0xff;
4496 + x |= (*codep++ & 0xff) << 8;
4501 +set_op (bfd_vma op, int riprel)
4503 + op_index[op_ad] = op_ad;
4506 + op_address[op_ad] = op;
4507 + op_riprel[op_ad] = riprel;
4511 + /* Mask to get a 32-bit address. */
4512 + op_address[op_ad] = op & 0xffffffff;
4513 + op_riprel[op_ad] = riprel & 0xffffffff;
4518 +OP_REG (int code, int sizeflag)
4522 + USED_REX (REX_EXTZ);
4523 + if (rex & REX_EXTZ)
4528 + case indir_dx_reg:
4534 + case ax_reg: case cx_reg: case dx_reg: case bx_reg:
4535 + case sp_reg: case bp_reg: case si_reg: case di_reg:
4536 + s = names16[code - ax_reg + add];
4538 + case es_reg: case ss_reg: case cs_reg:
4539 + case ds_reg: case fs_reg: case gs_reg:
4540 + s = names_seg[code - es_reg + add];
4542 + case al_reg: case ah_reg: case cl_reg: case ch_reg:
4543 + case dl_reg: case dh_reg: case bl_reg: case bh_reg:
4546 + s = names8rex[code - al_reg + add];
4548 + s = names8[code - al_reg];
4550 + case rAX_reg: case rCX_reg: case rDX_reg: case rBX_reg:
4551 + case rSP_reg: case rBP_reg: case rSI_reg: case rDI_reg:
4554 + s = names64[code - rAX_reg + add];
4557 + code += eAX_reg - rAX_reg;
4558 + /* Fall through. */
4559 + case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
4560 + case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
4561 + USED_REX (REX_MODE64);
4562 + if (rex & REX_MODE64)
4563 + s = names64[code - eAX_reg + add];
4564 + else if (sizeflag & DFLAG)
4565 + s = names32[code - eAX_reg + add];
4567 + s = names16[code - eAX_reg + add];
4568 + used_prefixes |= (prefixes & PREFIX_DATA);
4571 + s = INTERNAL_DISASSEMBLER_ERROR;
4578 +OP_IMREG (int code, int sizeflag)
4584 + case indir_dx_reg:
4590 + case ax_reg: case cx_reg: case dx_reg: case bx_reg:
4591 + case sp_reg: case bp_reg: case si_reg: case di_reg:
4592 + s = names16[code - ax_reg];
4594 + case es_reg: case ss_reg: case cs_reg:
4595 + case ds_reg: case fs_reg: case gs_reg:
4596 + s = names_seg[code - es_reg];
4598 + case al_reg: case ah_reg: case cl_reg: case ch_reg:
4599 + case dl_reg: case dh_reg: case bl_reg: case bh_reg:
4602 + s = names8rex[code - al_reg];
4604 + s = names8[code - al_reg];
4606 + case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
4607 + case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
4608 + USED_REX (REX_MODE64);
4609 + if (rex & REX_MODE64)
4610 + s = names64[code - eAX_reg];
4611 + else if (sizeflag & DFLAG)
4612 + s = names32[code - eAX_reg];
4614 + s = names16[code - eAX_reg];
4615 + used_prefixes |= (prefixes & PREFIX_DATA);
4618 + s = INTERNAL_DISASSEMBLER_ERROR;
4625 +OP_I (int bytemode, int sizeflag)
4627 + bfd_signed_vma op;
4628 + bfd_signed_vma mask = -1;
4633 + FETCH_DATA (the_info, codep + 1);
4643 + /* Fall through. */
4645 + USED_REX (REX_MODE64);
4646 + if (rex & REX_MODE64)
4648 + else if (sizeflag & DFLAG)
4651 + mask = 0xffffffff;
4658 + used_prefixes |= (prefixes & PREFIX_DATA);
4664 + case const_1_mode:
4669 + oappend (INTERNAL_DISASSEMBLER_ERROR);
4674 + scratchbuf[0] = '$';
4675 + print_operand_value (scratchbuf + 1, 1, op);
4676 + oappend (scratchbuf + intel_syntax);
4677 + scratchbuf[0] = '\0';
4681 +OP_I64 (int bytemode, int sizeflag)
4683 + bfd_signed_vma op;
4684 + bfd_signed_vma mask = -1;
4688 + OP_I (bytemode, sizeflag);
4695 + FETCH_DATA (the_info, codep + 1);
4700 + USED_REX (REX_MODE64);
4701 + if (rex & REX_MODE64)
4703 + else if (sizeflag & DFLAG)
4706 + mask = 0xffffffff;
4713 + used_prefixes |= (prefixes & PREFIX_DATA);
4720 + oappend (INTERNAL_DISASSEMBLER_ERROR);
4725 + scratchbuf[0] = '$';
4726 + print_operand_value (scratchbuf + 1, 1, op);
4727 + oappend (scratchbuf + intel_syntax);
4728 + scratchbuf[0] = '\0';
4732 +OP_sI (int bytemode, int sizeflag)
4734 + bfd_signed_vma op;
4735 + bfd_signed_vma mask = -1;
4740 + FETCH_DATA (the_info, codep + 1);
4742 + if ((op & 0x80) != 0)
4744 + mask = 0xffffffff;
4747 + USED_REX (REX_MODE64);
4748 + if (rex & REX_MODE64)
4750 + else if (sizeflag & DFLAG)
4753 + mask = 0xffffffff;
4757 + mask = 0xffffffff;
4759 + if ((op & 0x8000) != 0)
4762 + used_prefixes |= (prefixes & PREFIX_DATA);
4766 + mask = 0xffffffff;
4767 + if ((op & 0x8000) != 0)
4771 + oappend (INTERNAL_DISASSEMBLER_ERROR);
4775 + scratchbuf[0] = '$';
4776 + print_operand_value (scratchbuf + 1, 1, op);
4777 + oappend (scratchbuf + intel_syntax);
4781 +OP_J (int bytemode, int sizeflag)
4784 + bfd_vma mask = -1;
4789 + FETCH_DATA (the_info, codep + 1);
4791 + if ((disp & 0x80) != 0)
4795 + if (sizeflag & DFLAG)
4800 + /* For some reason, a data16 prefix on a jump instruction
4801 + means that the pc is masked to 16 bits after the
4802 + displacement is added! */
4807 + oappend (INTERNAL_DISASSEMBLER_ERROR);
4810 + disp = (start_pc + codep - start_codep + disp) & mask;
4812 + print_operand_value (scratchbuf, 1, disp);
4813 + oappend (scratchbuf);
4817 +OP_SEG (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
4819 + oappend (names_seg[reg]);
4823 +OP_DIR (int dummy ATTRIBUTE_UNUSED, int sizeflag)
4827 + if (sizeflag & DFLAG)
4829 + offset = get32 ();
4834 + offset = get16 ();
4837 + used_prefixes |= (prefixes & PREFIX_DATA);
4839 + sprintf (scratchbuf, "0x%x,0x%x", seg, offset);
4841 + sprintf (scratchbuf, "$0x%x,$0x%x", seg, offset);
4842 + oappend (scratchbuf);
4846 +OP_OFF (int bytemode ATTRIBUTE_UNUSED, int sizeflag)
4852 + if ((sizeflag & AFLAG) || mode_64bit)
4859 + if (!(prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
4860 + | PREFIX_ES | PREFIX_FS | PREFIX_GS)))
4862 + oappend (names_seg[ds_reg - es_reg]);
4866 + print_operand_value (scratchbuf, 1, off);
4867 + oappend (scratchbuf);
4871 +OP_OFF64 (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
4877 + OP_OFF (bytemode, sizeflag);
4887 + if (!(prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
4888 + | PREFIX_ES | PREFIX_FS | PREFIX_GS)))
4890 + oappend (names_seg[ds_reg - es_reg]);
4894 + print_operand_value (scratchbuf, 1, off);
4895 + oappend (scratchbuf);
4899 +ptr_reg (int code, int sizeflag)
4903 + *obufp++ = open_char;
4904 + used_prefixes |= (prefixes & PREFIX_ADDR);
4907 + if (!(sizeflag & AFLAG))
4908 + s = names32[code - eAX_reg];
4910 + s = names64[code - eAX_reg];
4912 + else if (sizeflag & AFLAG)
4913 + s = names32[code - eAX_reg];
4915 + s = names16[code - eAX_reg];
4917 + *obufp++ = close_char;
4922 +OP_ESreg (int code, int sizeflag)
4926 + if (codep[-1] & 1)
4928 + USED_REX (REX_MODE64);
4929 + used_prefixes |= (prefixes & PREFIX_DATA);
4930 + if (rex & REX_MODE64)
4931 + oappend ("QWORD PTR ");
4932 + else if ((sizeflag & DFLAG))
4933 + oappend ("DWORD PTR ");
4935 + oappend ("WORD PTR ");
4938 + oappend ("BYTE PTR ");
4941 + oappend ("%es:" + intel_syntax);
4942 + ptr_reg (code, sizeflag);
4946 +OP_DSreg (int code, int sizeflag)
4950 + if (codep[-1] != 0xd7 && (codep[-1] & 1))
4952 + USED_REX (REX_MODE64);
4953 + used_prefixes |= (prefixes & PREFIX_DATA);
4954 + if (rex & REX_MODE64)
4955 + oappend ("QWORD PTR ");
4956 + else if ((sizeflag & DFLAG))
4957 + oappend ("DWORD PTR ");
4959 + oappend ("WORD PTR ");
4962 + oappend ("BYTE PTR ");
4971 + | PREFIX_GS)) == 0)
4972 + prefixes |= PREFIX_DS;
4974 + ptr_reg (code, sizeflag);
4978 +OP_C (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
4981 + if (rex & REX_EXTX)
4983 + USED_REX (REX_EXTX);
4986 + else if (!mode_64bit && (prefixes & PREFIX_LOCK))
4988 + used_prefixes |= PREFIX_LOCK;
4991 + sprintf (scratchbuf, "%%cr%d", reg + add);
4992 + oappend (scratchbuf + intel_syntax);
4996 +OP_D (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
4999 + USED_REX (REX_EXTX);
5000 + if (rex & REX_EXTX)
5003 + sprintf (scratchbuf, "db%d", reg + add);
5005 + sprintf (scratchbuf, "%%db%d", reg + add);
5006 + oappend (scratchbuf);
5010 +OP_T (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
5012 + sprintf (scratchbuf, "%%tr%d", reg);
5013 + oappend (scratchbuf + intel_syntax);
5017 +OP_Rd (int bytemode, int sizeflag)
5020 + OP_E (bytemode, sizeflag);
5026 +OP_MMX (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
5028 + used_prefixes |= (prefixes & PREFIX_DATA);
5029 + if (prefixes & PREFIX_DATA)
5032 + USED_REX (REX_EXTX);
5033 + if (rex & REX_EXTX)
5035 + sprintf (scratchbuf, "%%xmm%d", reg + add);
5038 + sprintf (scratchbuf, "%%mm%d", reg);
5039 + oappend (scratchbuf + intel_syntax);
5043 +OP_XMM (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
5046 + USED_REX (REX_EXTX);
5047 + if (rex & REX_EXTX)
5049 + sprintf (scratchbuf, "%%xmm%d", reg + add);
5050 + oappend (scratchbuf + intel_syntax);
5054 +OP_EM (int bytemode, int sizeflag)
5058 + if (intel_syntax && bytemode == v_mode)
5060 + bytemode = (prefixes & PREFIX_DATA) ? x_mode : q_mode;
5061 + used_prefixes |= (prefixes & PREFIX_DATA);
5063 + OP_E (bytemode, sizeflag);
5067 + /* Skip mod/rm byte. */
5070 + used_prefixes |= (prefixes & PREFIX_DATA);
5071 + if (prefixes & PREFIX_DATA)
5075 + USED_REX (REX_EXTZ);
5076 + if (rex & REX_EXTZ)
5078 + sprintf (scratchbuf, "%%xmm%d", rm + add);
5081 + sprintf (scratchbuf, "%%mm%d", rm);
5082 + oappend (scratchbuf + intel_syntax);
5086 +OP_EX (int bytemode, int sizeflag)
5091 + if (intel_syntax && bytemode == v_mode)
5093 + switch (prefixes & (PREFIX_DATA|PREFIX_REPZ|PREFIX_REPNZ))
5095 + case 0: bytemode = x_mode; break;
5096 + case PREFIX_REPZ: bytemode = d_mode; used_prefixes |= PREFIX_REPZ; break;
5097 + case PREFIX_DATA: bytemode = x_mode; used_prefixes |= PREFIX_DATA; break;
5098 + case PREFIX_REPNZ: bytemode = q_mode; used_prefixes |= PREFIX_REPNZ; break;
5099 + default: bytemode = 0; break;
5102 + OP_E (bytemode, sizeflag);
5105 + USED_REX (REX_EXTZ);
5106 + if (rex & REX_EXTZ)
5109 + /* Skip mod/rm byte. */
5112 + sprintf (scratchbuf, "%%xmm%d", rm + add);
5113 + oappend (scratchbuf + intel_syntax);
5117 +OP_MS (int bytemode, int sizeflag)
5120 + OP_EM (bytemode, sizeflag);
5126 +OP_XS (int bytemode, int sizeflag)
5129 + OP_EX (bytemode, sizeflag);
5135 +OP_M (int bytemode, int sizeflag)
5138 + BadOp (); /* bad lea,lds,les,lfs,lgs,lss modrm */
5140 + OP_E (bytemode, sizeflag);
5144 +OP_0f07 (int bytemode, int sizeflag)
5146 + if (mod != 3 || rm != 0)
5149 + OP_E (bytemode, sizeflag);
5153 +OP_0fae (int bytemode, int sizeflag)
5158 + strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
5160 + if (reg < 5 || rm != 0)
5162 + BadOp (); /* bad sfence, mfence, or lfence */
5166 + else if (reg != 7)
5168 + BadOp (); /* bad clflush */
5172 + OP_E (bytemode, sizeflag);
5176 +NOP_Fixup (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
5178 + /* NOP with REPZ prefix is called PAUSE. */
5179 + if (prefixes == PREFIX_REPZ)
5180 + strcpy (obuf, "pause");
5183 +static const char *const Suffix3DNow[] = {
5184 +/* 00 */ NULL, NULL, NULL, NULL,
5185 +/* 04 */ NULL, NULL, NULL, NULL,
5186 +/* 08 */ NULL, NULL, NULL, NULL,
5187 +/* 0C */ "pi2fw", "pi2fd", NULL, NULL,
5188 +/* 10 */ NULL, NULL, NULL, NULL,
5189 +/* 14 */ NULL, NULL, NULL, NULL,
5190 +/* 18 */ NULL, NULL, NULL, NULL,
5191 +/* 1C */ "pf2iw", "pf2id", NULL, NULL,
5192 +/* 20 */ NULL, NULL, NULL, NULL,
5193 +/* 24 */ NULL, NULL, NULL, NULL,
5194 +/* 28 */ NULL, NULL, NULL, NULL,
5195 +/* 2C */ NULL, NULL, NULL, NULL,
5196 +/* 30 */ NULL, NULL, NULL, NULL,
5197 +/* 34 */ NULL, NULL, NULL, NULL,
5198 +/* 38 */ NULL, NULL, NULL, NULL,
5199 +/* 3C */ NULL, NULL, NULL, NULL,
5200 +/* 40 */ NULL, NULL, NULL, NULL,
5201 +/* 44 */ NULL, NULL, NULL, NULL,
5202 +/* 48 */ NULL, NULL, NULL, NULL,
5203 +/* 4C */ NULL, NULL, NULL, NULL,
5204 +/* 50 */ NULL, NULL, NULL, NULL,
5205 +/* 54 */ NULL, NULL, NULL, NULL,
5206 +/* 58 */ NULL, NULL, NULL, NULL,
5207 +/* 5C */ NULL, NULL, NULL, NULL,
5208 +/* 60 */ NULL, NULL, NULL, NULL,
5209 +/* 64 */ NULL, NULL, NULL, NULL,
5210 +/* 68 */ NULL, NULL, NULL, NULL,
5211 +/* 6C */ NULL, NULL, NULL, NULL,
5212 +/* 70 */ NULL, NULL, NULL, NULL,
5213 +/* 74 */ NULL, NULL, NULL, NULL,
5214 +/* 78 */ NULL, NULL, NULL, NULL,
5215 +/* 7C */ NULL, NULL, NULL, NULL,
5216 +/* 80 */ NULL, NULL, NULL, NULL,
5217 +/* 84 */ NULL, NULL, NULL, NULL,
5218 +/* 88 */ NULL, NULL, "pfnacc", NULL,
5219 +/* 8C */ NULL, NULL, "pfpnacc", NULL,
5220 +/* 90 */ "pfcmpge", NULL, NULL, NULL,
5221 +/* 94 */ "pfmin", NULL, "pfrcp", "pfrsqrt",
5222 +/* 98 */ NULL, NULL, "pfsub", NULL,
5223 +/* 9C */ NULL, NULL, "pfadd", NULL,
5224 +/* A0 */ "pfcmpgt", NULL, NULL, NULL,
5225 +/* A4 */ "pfmax", NULL, "pfrcpit1", "pfrsqit1",
5226 +/* A8 */ NULL, NULL, "pfsubr", NULL,
5227 +/* AC */ NULL, NULL, "pfacc", NULL,
5228 +/* B0 */ "pfcmpeq", NULL, NULL, NULL,
5229 +/* B4 */ "pfmul", NULL, "pfrcpit2", "pfmulhrw",
5230 +/* B8 */ NULL, NULL, NULL, "pswapd",
5231 +/* BC */ NULL, NULL, NULL, "pavgusb",
5232 +/* C0 */ NULL, NULL, NULL, NULL,
5233 +/* C4 */ NULL, NULL, NULL, NULL,
5234 +/* C8 */ NULL, NULL, NULL, NULL,
5235 +/* CC */ NULL, NULL, NULL, NULL,
5236 +/* D0 */ NULL, NULL, NULL, NULL,
5237 +/* D4 */ NULL, NULL, NULL, NULL,
5238 +/* D8 */ NULL, NULL, NULL, NULL,
5239 +/* DC */ NULL, NULL, NULL, NULL,
5240 +/* E0 */ NULL, NULL, NULL, NULL,
5241 +/* E4 */ NULL, NULL, NULL, NULL,
5242 +/* E8 */ NULL, NULL, NULL, NULL,
5243 +/* EC */ NULL, NULL, NULL, NULL,
5244 +/* F0 */ NULL, NULL, NULL, NULL,
5245 +/* F4 */ NULL, NULL, NULL, NULL,
5246 +/* F8 */ NULL, NULL, NULL, NULL,
5247 +/* FC */ NULL, NULL, NULL, NULL,
5251 +OP_3DNowSuffix (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
5253 + const char *mnemonic;
5255 + FETCH_DATA (the_info, codep + 1);
5256 + /* AMD 3DNow! instructions are specified by an opcode suffix in the
5257 + place where an 8-bit immediate would normally go. ie. the last
5258 + byte of the instruction. */
5259 + obufp = obuf + strlen (obuf);
5260 + mnemonic = Suffix3DNow[*codep++ & 0xff];
5262 + oappend (mnemonic);
5265 + /* Since a variable sized modrm/sib chunk is between the start
5266 + of the opcode (0x0f0f) and the opcode suffix, we need to do
5267 + all the modrm processing first, and don't know until now that
5268 + we have a bad opcode. This necessitates some cleaning up. */
5275 +static const char *simd_cmp_op[] = {
5287 +OP_SIMD_Suffix (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
5289 + unsigned int cmp_type;
5291 + FETCH_DATA (the_info, codep + 1);
5292 + obufp = obuf + strlen (obuf);
5293 + cmp_type = *codep++ & 0xff;
5296 + char suffix1 = 'p', suffix2 = 's';
5297 + used_prefixes |= (prefixes & PREFIX_REPZ);
5298 + if (prefixes & PREFIX_REPZ)
5302 + used_prefixes |= (prefixes & PREFIX_DATA);
5303 + if (prefixes & PREFIX_DATA)
5307 + used_prefixes |= (prefixes & PREFIX_REPNZ);
5308 + if (prefixes & PREFIX_REPNZ)
5309 + suffix1 = 's', suffix2 = 'd';
5312 + sprintf (scratchbuf, "cmp%s%c%c",
5313 + simd_cmp_op[cmp_type], suffix1, suffix2);
5314 + used_prefixes |= (prefixes & PREFIX_REPZ);
5315 + oappend (scratchbuf);
5319 + /* We have a bad extension byte. Clean up. */
5327 +SIMD_Fixup (int extrachar, int sizeflag ATTRIBUTE_UNUSED)
5329 + /* Change movlps/movhps to movhlps/movlhps for 2 register operand
5330 + forms of these instructions. */
5333 + char *p = obuf + strlen (obuf);
5336 + *(p - 1) = *(p - 2);
5337 + *(p - 2) = *(p - 3);
5338 + *(p - 3) = extrachar;
5343 +PNI_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag)
5345 + if (mod == 3 && reg == 1 && rm <= 1)
5347 + /* Override "sidt". */
5348 + char *p = obuf + strlen (obuf) - 4;
5350 + /* We might have a suffix when disassembling with -Msuffix. */
5356 + /* mwait %eax,%ecx */
5357 + strcpy (p, "mwait");
5358 + if (!intel_syntax)
5359 + strcpy (op1out, names32[0]);
5363 + /* monitor %eax,%ecx,%edx" */
5364 + strcpy (p, "monitor");
5365 + if (!intel_syntax)
5368 + strcpy (op1out, names32[0]);
5369 + else if (!(prefixes & PREFIX_ADDR))
5370 + strcpy (op1out, names64[0]);
5373 + strcpy (op1out, names32[0]);
5374 + used_prefixes |= PREFIX_ADDR;
5376 + strcpy (op3out, names32[2]);
5379 + if (!intel_syntax)
5381 + strcpy (op2out, names32[1]);
5382 + two_source_ops = 1;
5388 + OP_M (0, sizeflag);
5392 +SVME_Fixup (int bytemode, int sizeflag)
5424 + OP_M (bytemode, sizeflag);
5427 + /* Override "lidt". */
5428 + p = obuf + strlen (obuf) - 4;
5429 + /* We might have a suffix. */
5433 + if (!(prefixes & PREFIX_ADDR))
5438 + used_prefixes |= PREFIX_ADDR;
5442 + strcpy (op2out, names32[1]);
5443 + two_source_ops = 1;
5444 + /* Fall through. */
5448 + *obufp++ = open_char;
5449 + if (mode_64bit || (sizeflag & AFLAG))
5453 + strcpy (obufp, alt);
5454 + obufp += strlen (alt);
5455 + *obufp++ = close_char;
5462 +INVLPG_Fixup (int bytemode, int sizeflag)
5475 + OP_M (bytemode, sizeflag);
5478 + /* Override "invlpg". */
5479 + strcpy (obuf + strlen (obuf) - 6, alt);
5486 + /* Throw away prefixes and 1st. opcode byte. */
5487 + codep = insn_codep + 1;
5488 + oappend ("(bad)");
5492 +SEG_Fixup (int extrachar, int sizeflag)
5496 + /* We need to add a proper suffix with
5505 + const char *suffix;
5507 + if (prefixes & PREFIX_DATA)
5511 + USED_REX (REX_MODE64);
5512 + if (rex & REX_MODE64)
5517 + strcat (obuf, suffix);
5521 + /* We need to fix the suffix for
5528 + Override "mov[l|q]". */
5529 + char *p = obuf + strlen (obuf) - 1;
5531 + /* We might not have a suffix. */
5537 + OP_E (extrachar, sizeflag);
5541 +VMX_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag)
5543 + if (mod == 3 && reg == 0 && rm >=1 && rm <= 4)
5545 + /* Override "sgdt". */
5546 + char *p = obuf + strlen (obuf) - 4;
5548 + /* We might have a suffix when disassembling with -Msuffix. */
5555 + strcpy (p, "vmcall");
5558 + strcpy (p, "vmlaunch");
5561 + strcpy (p, "vmresume");
5564 + strcpy (p, "vmxoff");
5571 + OP_E (0, sizeflag);
5575 +OP_VMX (int bytemode, int sizeflag)
5577 + used_prefixes |= (prefixes & (PREFIX_DATA | PREFIX_REPZ));
5578 + if (prefixes & PREFIX_DATA)
5579 + strcpy (obuf, "vmclear");
5580 + else if (prefixes & PREFIX_REPZ)
5581 + strcpy (obuf, "vmxon");
5583 + strcpy (obuf, "vmptrld");
5584 + OP_E (bytemode, sizeflag);
5586 diff -Nurp linux-2.6.22-590/arch/i386/kdb/kdba_bp.c linux-2.6.22-600/arch/i386/kdb/kdba_bp.c
5587 --- linux-2.6.22-590/arch/i386/kdb/kdba_bp.c 1970-01-01 01:00:00.000000000 +0100
5588 +++ linux-2.6.22-600/arch/i386/kdb/kdba_bp.c 2008-04-09 18:16:14.000000000 +0200
5591 + * Kernel Debugger Architecture Dependent Breakpoint Handling
5593 + * This file is subject to the terms and conditions of the GNU General Public
5594 + * License. See the file "COPYING" in the main directory of this archive
5595 + * for more details.
5597 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
5600 +#include <linux/string.h>
5601 +#include <linux/kernel.h>
5602 +#include <linux/sched.h>
5603 +#include <linux/smp.h>
5604 +#include <linux/ptrace.h>
5605 +#include <linux/kdb.h>
5606 +#include <linux/kdbprivate.h>
5609 +static char *kdba_rwtypes[] = { "Instruction(Register)", "Data Write",
5610 + "I/O", "Data Access"};
5613 + * Table describing processor architecture hardware
5614 + * breakpoint registers.
5617 +static kdbhard_bp_t kdb_hardbreaks[KDB_MAXHARDBPT];
5622 + * Perform breakpoint processing upon entry to the
5623 + * processor debugger fault. Determine and print
5624 + * the active breakpoint.
5627 + * regs Exception frame containing machine register state
5628 + * error Error number passed to kdb.
5632 + * KDB_DB_BPT Standard instruction or data breakpoint encountered
5633 + * KDB_DB_SS Single Step fault ('ss' command or end of 'ssb' command)
5634 + * KDB_DB_SSB Single Step fault, caller should continue ('ssb' command)
5635 + * KDB_DB_SSBPT Single step over breakpoint
5636 + * KDB_DB_NOBPT No existing kdb breakpoint matches this debug exception
5640 + * Yup, there be goto's here.
5642 + * If multiple processors receive debug exceptions simultaneously,
5643 + * one may be waiting at the kdb fence in kdb() while the user
5644 + * issues a 'bc' command to clear the breakpoint the processor
5645 + * which is waiting has already encountered. If this is the case,
5646 + * the debug registers will no longer match any entry in the
5647 + * breakpoint table, and we'll return the value KDB_DB_NOBPT.
5648 + * This can cause a panic in die_if_kernel(). It is safer to
5649 + * disable the breakpoint (bd), go until all processors are past
5650 + * the breakpoint then clear the breakpoint (bc). This code
5651 + * recognises a breakpoint even when disabled but not when it has
5654 + * WARNING: This routine clears the debug state. It should be called
5655 + * once per debug and the result cached.
5659 +kdba_db_trap(struct pt_regs *regs, int error_unused)
5661 + kdb_machreg_t dr6;
5662 + kdb_machreg_t dr7;
5665 + kdb_dbtrap_t rv = KDB_DB_BPT;
5668 + if (KDB_NULL_REGS(regs))
5669 + return KDB_DB_NOBPT;
5671 + dr6 = kdba_getdr6();
5672 + dr7 = kdba_getdr7();
5674 + if (KDB_DEBUG(BP))
5675 + kdb_printf("kdb: dr6 0x%lx dr7 0x%lx\n", dr6, dr7);
5676 + if (dr6 & DR6_BS) {
5677 + if (KDB_STATE(SSBPT)) {
5678 + if (KDB_DEBUG(BP))
5679 + kdb_printf("ssbpt\n");
5680 + KDB_STATE_CLEAR(SSBPT);
5681 + for(i=0,bp=kdb_breakpoints;
5684 + if (KDB_DEBUG(BP))
5685 + kdb_printf("bp 0x%p enabled %d delayed %d global %d cpu %d\n",
5686 + bp, bp->bp_enabled, bp->bp_delayed, bp->bp_global, bp->bp_cpu);
5687 + if (!bp->bp_enabled)
5689 + if (!bp->bp_global && bp->bp_cpu != smp_processor_id())
5691 + if (KDB_DEBUG(BP))
5692 + kdb_printf("bp for this cpu\n");
5693 + if (bp->bp_delayed) {
5694 + bp->bp_delayed = 0;
5695 + if (KDB_DEBUG(BP))
5696 + kdb_printf("kdba_installbp\n");
5697 + kdba_installbp(regs, bp);
5698 + if (!KDB_STATE(DOING_SS)) {
5699 + regs->eflags &= ~EF_TF;
5700 + return(KDB_DB_SSBPT);
5705 + if (i == KDB_MAXBPT) {
5706 + kdb_printf("kdb: Unable to find delayed breakpoint\n");
5708 + if (!KDB_STATE(DOING_SS)) {
5709 + regs->eflags &= ~EF_TF;
5710 + return(KDB_DB_NOBPT);
5716 + * KDB_STATE_DOING_SS is set when the kernel debugger is using
5717 + * the processor trap flag to single-step a processor. If a
5718 + * single step trap occurs and this flag is clear, the SS trap
5719 + * will be ignored by KDB and the kernel will be allowed to deal
5720 + * with it as necessary (e.g. for ptrace).
5722 + if (!KDB_STATE(DOING_SS))
5726 + rv = KDB_DB_SS; /* Indicate single step */
5727 + if (KDB_STATE(DOING_SSB)) {
5728 + unsigned char instruction[2];
5730 + kdb_id1(regs->eip);
5731 + if (kdb_getarea(instruction, regs->eip) ||
5732 + (instruction[0]&0xf0) == 0xe0 || /* short disp jumps */
5733 + (instruction[0]&0xf0) == 0x70 || /* Misc. jumps */
5734 + instruction[0] == 0xc2 || /* ret */
5735 + instruction[0] == 0x9a || /* call */
5736 + (instruction[0]&0xf8) == 0xc8 || /* enter, leave, iret, int, */
5737 + ((instruction[0] == 0x0f) &&
5738 + ((instruction[1]&0xf0)== 0x80))
5741 + * End the ssb command here.
5743 + KDB_STATE_CLEAR(DOING_SSB);
5744 + KDB_STATE_CLEAR(DOING_SS);
5746 + rv = KDB_DB_SSB; /* Indicate ssb - dismiss immediately */
5750 + * Print current insn
5752 + kdb_printf("SS trap at ");
5753 + kdb_symbol_print(regs->eip, NULL, KDB_SP_DEFAULT|KDB_SP_NEWLINE);
5754 + kdb_id1(regs->eip);
5755 + KDB_STATE_CLEAR(DOING_SS);
5758 + if (rv != KDB_DB_SSB)
5759 + regs->eflags &= ~EF_TF;
5762 + if (dr6 & DR6_B0) {
5763 + rw = DR7_RW0(dr7);
5768 + if (dr6 & DR6_B1) {
5769 + rw = DR7_RW1(dr7);
5774 + if (dr6 & DR6_B2) {
5775 + rw = DR7_RW2(dr7);
5780 + if (dr6 & DR6_B3) {
5781 + rw = DR7_RW3(dr7);
5789 + goto unknown; /* dismiss */
5795 + regs->eflags |= EF_RF;
5798 + * Determine which breakpoint was encountered.
5800 + for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
5801 + if (!(bp->bp_free)
5802 + && (bp->bp_global || bp->bp_cpu == smp_processor_id())
5804 + && (bp->bp_hard->bph_reg == reg)) {
5806 + * Hit this breakpoint.
5808 + kdb_printf("%s breakpoint #%d at " kdb_bfd_vma_fmt "\n",
5813 + * For an instruction breakpoint, disassemble
5814 + * the current instruction.
5817 + kdb_id1(regs->eip);
5825 + regs->eflags |= EF_RF; /* Supress further faults */
5826 + rv = KDB_DB_NOBPT; /* Cause kdb() to return */
5831 + * Clear the pending exceptions.
5841 + * Perform breakpoint processing upon entry to the
5842 + * processor breakpoint instruction fault. Determine and print
5843 + * the active breakpoint.
5846 + * regs Exception frame containing machine register state
5847 + * error Error number passed to kdb.
5851 + * 0 Standard instruction or data breakpoint encountered
5852 + * 1 Single Step fault ('ss' command)
5853 + * 2 Single Step fault, caller should continue ('ssb' command)
5854 + * 3 No existing kdb breakpoint matches this debug exception
5859 + * If multiple processors receive debug exceptions simultaneously,
5860 + * one may be waiting at the kdb fence in kdb() while the user
5861 + * issues a 'bc' command to clear the breakpoint the processor which
5862 + * is waiting has already encountered. If this is the case, the
5863 + * debug registers will no longer match any entry in the breakpoint
5864 + * table, and we'll return the value '3'. This can cause a panic
5865 + * in die_if_kernel(). It is safer to disable the breakpoint (bd),
5866 + * 'go' until all processors are past the breakpoint then clear the
5867 + * breakpoint (bc). This code recognises a breakpoint even when
5868 + * disabled but not when it has been cleared.
5870 + * WARNING: This routine resets the eip. It should be called
5871 + * once per breakpoint and the result cached.
5875 +kdba_bp_trap(struct pt_regs *regs, int error_unused)
5881 + if (KDB_NULL_REGS(regs))
5882 + return KDB_DB_NOBPT;
5885 + * Determine which breakpoint was encountered.
5887 + if (KDB_DEBUG(BP))
5888 + kdb_printf("kdba_bp_trap: eip=0x%lx (not adjusted) "
5889 + "eflags=0x%lx regs=0x%p esp=0x%lx\n",
5890 + regs->eip, regs->eflags, regs, regs->esp);
5892 + rv = KDB_DB_NOBPT; /* Cause kdb() to return */
5894 + for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
5897 + if (!bp->bp_global && bp->bp_cpu != smp_processor_id())
5899 + if ((void *)bp->bp_addr == (void *)(regs->eip - bp->bp_adjust)) {
5900 + /* Hit this breakpoint. */
5901 + regs->eip -= bp->bp_adjust;
5902 + kdb_printf("Instruction(i) breakpoint #%d at 0x%lx (adjusted)\n",
5904 + kdb_id1(regs->eip);
5907 + /* SSBPT is set when the kernel debugger must single
5908 + * step a task in order to re-establish an instruction
5909 + * breakpoint which uses the instruction replacement
5910 + * mechanism. It is cleared by any action that removes
5911 + * the need to single-step the breakpoint.
5913 + KDB_STATE_SET(SSBPT);
5924 + * Handle an instruction-breakpoint trap. Called when re-installing
5925 + * an enabled breakpoint which has has the bp_delay bit set.
5932 + * Ok, we really need to:
5933 + * 1) Restore the original instruction byte
5935 + * 3) Restore breakpoint instruction
5942 +kdba_handle_bp(struct pt_regs *regs, kdb_bp_t *bp)
5944 + if (KDB_NULL_REGS(regs))
5947 + if (KDB_DEBUG(BP))
5948 + kdb_printf("regs->eip = 0x%lx\n", regs->eip);
5951 + * Setup single step
5953 + kdba_setsinglestep(regs);
5956 + * Reset delay attribute
5959 + bp->bp_delayed = 1;
5966 + * Return a string describing type of breakpoint.
5969 + * bph Pointer to hardware breakpoint description
5973 + * Character string.
5980 +kdba_bptype(kdbhard_bp_t *bph)
5984 + mode = kdba_rwtypes[bph->bph_mode];
5992 + * Print register name assigned to breakpoint
5995 + * bph Pointer hardware breakpoint structure
6006 +kdba_printbpreg(kdbhard_bp_t *bph)
6008 + kdb_printf(" in dr%ld", bph->bph_reg);
6014 + * Print string describing hardware breakpoint.
6017 + * bph Pointer to hardware breakpoint description
6028 +kdba_printbp(kdb_bp_t *bp)
6030 + kdb_printf("\n is enabled");
6031 + if (bp->bp_hardtype) {
6032 + kdba_printbpreg(bp->bp_hard);
6033 + if (bp->bp_hard->bph_mode != 0) {
6034 + kdb_printf(" for %d bytes",
6035 + bp->bp_hard->bph_length+1);
6043 + * Parse architecture dependent portion of the
6044 + * breakpoint command.
6051 + * Zero for success, a kdb diagnostic for failure
6055 + * for Ia32 architure, data access, data write and
6056 + * I/O breakpoints are supported in addition to instruction
6059 + * {datar|dataw|io|inst} [length]
6063 +kdba_parsebp(int argc, const char **argv, int *nextargp, kdb_bp_t *bp)
6065 + int nextarg = *nextargp;
6067 + kdbhard_bp_t *bph = &bp->bp_template;
6069 + bph->bph_mode = 0; /* Default to instruction breakpoint */
6070 + bph->bph_length = 0; /* Length must be zero for insn bp */
6071 + if ((argc + 1) != nextarg) {
6072 + if (strnicmp(argv[nextarg], "datar", sizeof("datar")) == 0) {
6073 + bph->bph_mode = 3;
6074 + } else if (strnicmp(argv[nextarg], "dataw", sizeof("dataw")) == 0) {
6075 + bph->bph_mode = 1;
6076 + } else if (strnicmp(argv[nextarg], "io", sizeof("io")) == 0) {
6077 + bph->bph_mode = 2;
6078 + } else if (strnicmp(argv[nextarg], "inst", sizeof("inst")) == 0) {
6079 + bph->bph_mode = 0;
6081 + return KDB_ARGCOUNT;
6084 + bph->bph_length = 3; /* Default to 4 byte */
6088 + if ((argc + 1) != nextarg) {
6089 + unsigned long len;
6091 + diag = kdbgetularg((char *)argv[nextarg],
6097 + if ((len > 4) || (len == 3))
6098 + return KDB_BADLENGTH;
6100 + bph->bph_length = len;
6101 + bph->bph_length--; /* Normalize for debug register */
6105 + if ((argc + 1) != nextarg)
6106 + return KDB_ARGCOUNT;
6109 + * Indicate to architecture independent level that
6110 + * a hardware register assignment is required to enable
6111 + * this breakpoint.
6114 + bph->bph_free = 0;
6116 + if (KDB_DEBUG(BP))
6117 + kdb_printf("kdba_bp: no args, forcehw is %d\n", bp->bp_forcehw);
6118 + if (bp->bp_forcehw) {
6120 + * We are forced to use a hardware register for this
6121 + * breakpoint because either the bph or bpha
6122 + * commands were used to establish this breakpoint.
6124 + bph->bph_free = 0;
6127 + * Indicate to architecture dependent level that
6128 + * the instruction replacement breakpoint technique
6129 + * should be used for this breakpoint.
6131 + bph->bph_free = 1;
6132 + bp->bp_adjust = 1; /* software, int 3 is one byte */
6136 + if (bph->bph_mode != 2 && kdba_verify_rw(bp->bp_addr, bph->bph_length+1)) {
6137 + kdb_printf("Invalid address for breakpoint, ignoring bp command\n");
6138 + return KDB_BADADDR;
6141 + *nextargp = nextarg;
6148 + * Associate a hardware register with a breakpoint.
6155 + * A pointer to the allocated register kdbhard_bp_t structure for
6156 + * success, Null and a non-zero diagnostic for failure.
6163 +kdba_allocbp(kdbhard_bp_t *bph, int *diagp)
6166 + kdbhard_bp_t *newbph;
6168 + for(i=0,newbph=kdb_hardbreaks; i < KDB_MAXHARDBPT; i++, newbph++) {
6169 + if (newbph->bph_free) {
6174 + if (i == KDB_MAXHARDBPT) {
6175 + *diagp = KDB_TOOMANYDBREGS;
6182 + * Copy data from template. Can't just copy the entire template
6183 + * here because the register number in kdb_hardbreaks must be
6186 + newbph->bph_data = bph->bph_data;
6187 + newbph->bph_write = bph->bph_write;
6188 + newbph->bph_mode = bph->bph_mode;
6189 + newbph->bph_length = bph->bph_length;
6192 + * Mark entry allocated.
6194 + newbph->bph_free = 0;
6202 + * Deallocate a hardware breakpoint
6209 + * Zero for success, a kdb diagnostic for failure
6216 +kdba_freebp(kdbhard_bp_t *bph)
6218 + bph->bph_free = 1;
6224 + * Initialize the breakpoint table for the hardware breakpoint
6232 + * Zero for success, a kdb diagnostic for failure
6237 + * There is one entry per register. On the ia32 architecture
6238 + * all the registers are interchangeable, so no special allocation
6239 + * criteria are required.
6246 + kdbhard_bp_t *bph;
6249 + * Clear the hardware breakpoint table
6252 + memset(kdb_hardbreaks, '\0', sizeof(kdb_hardbreaks));
6254 + for(i=0,bph=kdb_hardbreaks; i<KDB_MAXHARDBPT; i++, bph++) {
6256 + bph->bph_free = 1;
6263 + * Install a breakpoint
6266 + * regs Exception frame
6267 + * bp Breakpoint structure for the breakpoint to be installed
6271 + * 0 if breakpoint installed.
6275 + * For hardware breakpoints, a debug register is allocated
6276 + * and assigned to the breakpoint. If no debug register is
6277 + * available, a warning message is printed and the breakpoint
6280 + * For instruction replacement breakpoints, we must single-step
6281 + * over the replaced instruction at this point so we can re-install
6282 + * the breakpoint instruction after the single-step. SSBPT is set
6283 + * when the breakpoint is initially hit and is cleared by any action
6284 + * that removes the need for single-step over the breakpoint.
6288 +kdba_installbp(struct pt_regs *regs, kdb_bp_t *bp)
6291 + * Install the breakpoint, if it is not already installed.
6294 + if (KDB_DEBUG(BP)) {
6295 + kdb_printf("kdba_installbp bp_installed %d\n", bp->bp_installed);
6297 + if (!KDB_STATE(SSBPT))
6299 + if (!bp->bp_installed) {
6300 + if (bp->bp_hardtype) {
6301 + kdba_installdbreg(bp);
6302 + bp->bp_installed = 1;
6303 + if (KDB_DEBUG(BP)) {
6304 + kdb_printf("kdba_installbp hardware reg %ld at " kdb_bfd_vma_fmt "\n",
6305 + bp->bp_hard->bph_reg, bp->bp_addr);
6307 + } else if (bp->bp_delay) {
6308 + if (KDB_DEBUG(BP))
6309 + kdb_printf("kdba_installbp delayed bp\n");
6310 + kdba_handle_bp(regs, bp);
6312 + if (kdb_getarea_size(&(bp->bp_inst), bp->bp_addr, 1) ||
6313 + kdb_putword(bp->bp_addr, IA32_BREAKPOINT_INSTRUCTION, 1)) {
6314 + kdb_printf("kdba_installbp failed to set software breakpoint at 0x%lx\n", bp->bp_addr);
6317 + bp->bp_installed = 1;
6318 + if (KDB_DEBUG(BP))
6319 + kdb_printf("kdba_installbp instruction 0x%x at " kdb_bfd_vma_fmt "\n",
6320 + IA32_BREAKPOINT_INSTRUCTION, bp->bp_addr);
6329 + * Make a breakpoint ineffective.
6343 +kdba_removebp(kdb_bp_t *bp)
6346 + * For hardware breakpoints, remove it from the active register,
6347 + * for software breakpoints, restore the instruction stream.
6349 + if (KDB_DEBUG(BP)) {
6350 + kdb_printf("kdba_removebp bp_installed %d\n", bp->bp_installed);
6352 + if (bp->bp_installed) {
6353 + if (bp->bp_hardtype) {
6354 + if (KDB_DEBUG(BP)) {
6355 + kdb_printf("kdb: removing hardware reg %ld at " kdb_bfd_vma_fmt "\n",
6356 + bp->bp_hard->bph_reg, bp->bp_addr);
6358 + kdba_removedbreg(bp);
6360 + if (KDB_DEBUG(BP))
6361 + kdb_printf("kdb: restoring instruction 0x%x at " kdb_bfd_vma_fmt "\n",
6362 + bp->bp_inst, bp->bp_addr);
6363 + if (kdb_putword(bp->bp_addr, bp->bp_inst, 1))
6366 + bp->bp_installed = 0;
6370 diff -Nurp linux-2.6.22-590/arch/i386/kdb/kdba_bt.c linux-2.6.22-600/arch/i386/kdb/kdba_bt.c
6371 --- linux-2.6.22-590/arch/i386/kdb/kdba_bt.c 1970-01-01 01:00:00.000000000 +0100
6372 +++ linux-2.6.22-600/arch/i386/kdb/kdba_bt.c 2008-04-09 18:16:14.000000000 +0200
6375 + * Kernel Debugger Architecture Dependent Stack Traceback
6377 + * This file is subject to the terms and conditions of the GNU General Public
6378 + * License. See the file "COPYING" in the main directory of this archive
6379 + * for more details.
6381 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
6384 +#include <linux/ctype.h>
6385 +#include <linux/string.h>
6386 +#include <linux/kernel.h>
6387 +#include <linux/sched.h>
6388 +#include <linux/kallsyms.h>
6389 +#include <linux/irq.h>
6390 +#include <linux/kdb.h>
6391 +#include <linux/kdbprivate.h>
6392 +#include <asm/system.h>
6394 +/* On a 4K stack kernel, hardirq_ctx and softirq_ctx are [NR_CPUS] arrays. The
6395 + * first element of each per-cpu stack is a struct thread_info.
6398 +kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
6399 + struct kdb_activation_record *ar)
6401 +#ifdef CONFIG_4KSTACKS
6402 + struct thread_info *tinfo;
6403 + static int first_time = 1;
6404 + static struct thread_info **kdba_hardirq_ctx, **kdba_softirq_ctx;
6406 + kdb_symtab_t symtab;
6407 + kdbgetsymval("hardirq_ctx", &symtab);
6408 + kdba_hardirq_ctx = (struct thread_info **)symtab.sym_start;
6409 + kdbgetsymval("softirq_ctx", &symtab);
6410 + kdba_softirq_ctx = (struct thread_info **)symtab.sym_start;
6413 + tinfo = (struct thread_info *)(addr & -THREAD_SIZE);
6415 + /* Arbitrary address, see if it falls within any of the irq
6419 + for_each_online_cpu(cpu) {
6420 + if (tinfo == kdba_hardirq_ctx[cpu] ||
6421 + tinfo == kdba_softirq_ctx[cpu]) {
6429 + if (tinfo == kdba_hardirq_ctx[cpu] ||
6430 + tinfo == kdba_softirq_ctx[cpu]) {
6431 + ar->stack.physical_start = (kdb_machreg_t)tinfo;
6432 + ar->stack.physical_end = ar->stack.physical_start + THREAD_SIZE;
6433 + ar->stack.logical_start = ar->stack.physical_start +
6434 + sizeof(struct thread_info);
6435 + ar->stack.logical_end = ar->stack.physical_end;
6436 + ar->stack.next = tinfo->previous_esp;
6437 + if (tinfo == kdba_hardirq_ctx[cpu])
6438 + ar->stack.id = "hardirq_ctx";
6440 + ar->stack.id = "softirq_ctx";
6442 +#endif /* CONFIG_4KSTACKS */
6445 +/* Given an address which claims to be on a stack, an optional cpu number and
6446 + * an optional task address, get information about the stack.
6448 + * t == NULL, cpu < 0 indicates an arbitrary stack address with no associated
6449 + * struct task, the address can be in an alternate stack or any task's normal
6452 + * t != NULL, cpu >= 0 indicates a running task, the address can be in an
6453 + * alternate stack or that task's normal stack.
6455 + * t != NULL, cpu < 0 indicates a blocked task, the address can only be in that
6456 + * task's normal stack.
6458 + * t == NULL, cpu >= 0 is not a valid combination.
6462 +kdba_get_stack_info(kdb_machreg_t esp, int cpu,
6463 + struct kdb_activation_record *ar,
6464 + const struct task_struct *t)
6466 + struct thread_info *tinfo;
6467 + struct task_struct *g, *p;
6468 + memset(&ar->stack, 0, sizeof(ar->stack));
6469 + if (KDB_DEBUG(ARA))
6470 + kdb_printf("%s: esp=0x%lx cpu=%d task=%p\n",
6471 + __FUNCTION__, esp, cpu, t);
6472 + if (t == NULL || cpu >= 0) {
6473 + kdba_get_stack_info_alternate(esp, cpu, ar);
6474 + if (ar->stack.logical_start)
6477 + esp &= -THREAD_SIZE;
6478 + tinfo = (struct thread_info *)esp;
6480 + /* Arbitrary stack address without an associated task, see if
6481 + * it falls within any normal process stack, including the idle
6484 + kdb_do_each_thread(g, p) {
6485 + if (tinfo == task_thread_info(p)) {
6489 + } kdb_while_each_thread(g, p);
6490 + for_each_online_cpu(cpu) {
6491 + p = idle_task(cpu);
6492 + if (tinfo == task_thread_info(p)) {
6498 + if (KDB_DEBUG(ARA))
6499 + kdb_printf("%s: found task %p\n", __FUNCTION__, t);
6500 + } else if (cpu >= 0) {
6501 + /* running task */
6502 + struct kdb_running_process *krp = kdb_running_process + cpu;
6503 + if (krp->p != t || tinfo != task_thread_info(t))
6505 + if (KDB_DEBUG(ARA))
6506 + kdb_printf("%s: running task %p\n", __FUNCTION__, t);
6508 + /* blocked task */
6509 + if (tinfo != task_thread_info(t))
6511 + if (KDB_DEBUG(ARA))
6512 + kdb_printf("%s: blocked task %p\n", __FUNCTION__, t);
6515 + ar->stack.physical_start = esp;
6516 + ar->stack.physical_end = esp + THREAD_SIZE;
6517 + ar->stack.logical_start = esp + sizeof(struct thread_info);
6518 + ar->stack.logical_end = ar->stack.physical_end;
6519 + ar->stack.next = 0;
6520 + ar->stack.id = "normal";
6523 + if (ar->stack.physical_start && KDB_DEBUG(ARA)) {
6524 + kdb_printf("%s: ar->stack\n", __FUNCTION__);
6525 + kdb_printf(" physical_start=0x%lx\n", ar->stack.physical_start);
6526 + kdb_printf(" physical_end=0x%lx\n", ar->stack.physical_end);
6527 + kdb_printf(" logical_start=0x%lx\n", ar->stack.logical_start);
6528 + kdb_printf(" logical_end=0x%lx\n", ar->stack.logical_end);
6529 + kdb_printf(" next=0x%lx\n", ar->stack.next);
6530 + kdb_printf(" id=%s\n", ar->stack.id);
6537 + * Print one back trace entry.
6540 + * eip Current program counter, or return address.
6541 + * esp Stack pointer esp when at eip.
6542 + * ar Activation record for this frame.
6543 + * symtab Information about symbol that eip falls within.
6544 + * argcount Maximum number of arguments to print.
6556 +bt_print_one(kdb_machreg_t eip, kdb_machreg_t esp,
6557 + const struct kdb_activation_record *ar,
6558 + const kdb_symtab_t *symtab, int argcount)
6562 + kdb_machreg_t word;
6564 + kdbgetintenv("BTSYMARG", &btsymarg);
6565 + kdbgetintenv("NOSECT", &nosect);
6567 + kdb_printf(kdb_machreg_fmt0, esp);
6568 + kdb_symbol_print(eip, symtab, KDB_SP_SPACEB|KDB_SP_VALUE);
6569 + if (argcount && ar->args) {
6570 + int i, argc = ar->args;
6572 + if (argc > argcount)
6574 + for (i = 0; i < argc; i++) {
6575 + kdb_machreg_t argp = ar->arg[i];
6578 + kdb_getword(&word, argp, sizeof(word));
6579 + kdb_printf("0x%lx", word);
6583 + if (symtab->sym_name) {
6587 + symtab->mod_name);
6588 + if (symtab->sec_name && symtab->sec_start)
6589 + kdb_printf(" 0x%lx 0x%lx",
6590 + symtab->sec_start, symtab->sec_end);
6591 + kdb_printf(" 0x%lx 0x%lx",
6592 + symtab->sym_start, symtab->sym_end);
6596 + if (argcount && ar->args && btsymarg) {
6597 + int i, argc = ar->args;
6598 + kdb_symtab_t arg_symtab;
6599 + for (i = 0; i < argc; i++) {
6600 + kdb_machreg_t argp = ar->arg[i];
6601 + kdb_getword(&word, argp, sizeof(word));
6602 + if (kdbnearsym(word, &arg_symtab)) {
6604 + kdb_symbol_print(word, &arg_symtab,
6605 + KDB_SP_DEFAULT|KDB_SP_NEWLINE);
6611 +/* Getting the starting point for a backtrace on a running process is
6612 + * moderately tricky. kdba_save_running() saved the esp in krp->arch.esp, but
6613 + * that esp is not 100% accurate, it can be offset by a frame pointer or by the
6614 + * size of local variables in kdba_main_loop() and kdb_save_running().
6616 + * The calling sequence is kdb() -> kdba_main_loop() -> kdb_save_running() ->
6617 + * kdba_save_running(). Walk up the stack until we find a return address
6618 + * inside the main kdb() function and start the backtrace from there.
6622 +kdba_bt_stack_running(const struct task_struct *p,
6623 + const struct kdb_activation_record *ar,
6624 + kdb_machreg_t *eip, kdb_machreg_t *esp,
6625 + kdb_machreg_t *ebp)
6627 + kdb_machreg_t addr, sp;
6628 + kdb_symtab_t symtab;
6629 + struct kdb_running_process *krp = kdb_running_process + task_cpu(p);
6632 + if (kdbgetsymval("kdb", &symtab) == 0)
6634 + if (kdbnearsym(symtab.sym_start, &symtab) == 0)
6636 + sp = krp->arch.esp;
6637 + if (sp < ar->stack.logical_start || sp >= ar->stack.logical_end)
6639 + while (sp < ar->stack.logical_end) {
6640 + addr = *(kdb_machreg_t *)sp;
6641 + if (addr >= symtab.sym_start && addr < symtab.sym_end) {
6645 + sp += sizeof(kdb_machreg_t);
6658 + * addr Pointer to Address provided to 'bt' command, if any.
6660 + * p Pointer to task for 'btp' command.
6664 + * zero for success, a kdb diagnostic if error
6668 + * mds comes in handy when examining the stack to do a manual
6673 +kdba_bt_stack(kdb_machreg_t addr, int argcount, const struct task_struct *p)
6675 + struct kdb_activation_record ar;
6676 + kdb_machreg_t eip, esp, ebp, cs;
6677 + kdb_symtab_t symtab;
6678 + int first_time = 1, count = 0, btsp = 0, suppress;
6679 + struct pt_regs *regs = NULL;
6681 + kdbgetintenv("BTSP", &btsp);
6683 + memset(&ar, 0, sizeof(ar));
6686 + * The caller may have supplied an address at which the
6687 + * stack traceback operation should begin. This address
6688 + * is assumed by this code to point to a return-address
6689 + * on the stack to be traced back.
6691 + * The end result of this will make it appear as if a function
6692 + * entitled '<unknown>' was called from the function which
6693 + * contains return-address.
6699 + cs = __KERNEL_CS; /* have to assume kernel space */
6701 + kdba_get_stack_info(esp, -1, &ar, NULL);
6703 + if (task_curr(p)) {
6704 + struct kdb_running_process *krp =
6705 + kdb_running_process + task_cpu(p);
6707 + if (krp->seqno && krp->p == p
6708 + && krp->seqno >= kdb_seqno - 1) {
6709 + /* valid saved state, continue processing */
6712 + ("Process did not save state, cannot backtrace\n");
6717 + if (KDB_NULL_REGS(regs))
6718 + return KDB_BADREG;
6719 + kdba_getregcontents("xcs", regs, &cs);
6720 + if ((cs & 0xffff) != __KERNEL_CS) {
6721 + kdb_printf("Stack is not in kernel space, backtrace not available\n");
6724 + kdba_getregcontents("eip", regs, &eip);
6725 + kdba_getregcontents("ebp", regs, &ebp);
6726 + esp = krp->arch.esp;
6727 + kdba_get_stack_info(esp, kdb_process_cpu(p), &ar, p);
6728 + if (kdba_bt_stack_running(p, &ar, &eip, &esp, &ebp) == 0) {
6729 + kdb_printf("%s: cannot adjust esp=0x%lx for a running task\n",
6730 + __FUNCTION__, esp);
6733 + /* Not on cpu, assume blocked. Blocked tasks do not
6734 + * have pt_regs. p->thread.{esp,eip} are set, esp
6735 + * points to the ebp value, assume kernel space.
6737 + eip = p->thread.eip;
6738 + esp = p->thread.esp;
6739 + ebp = *(unsigned long *)esp;
6742 + kdba_get_stack_info(esp, -1, &ar, p);
6745 + if (!ar.stack.physical_start) {
6746 + kdb_printf("esp=0x%lx is not in a valid kernel stack, backtrace not available\n",
6751 + kdb_printf("esp eip Function (args)\n");
6752 + if (ar.stack.next && !suppress)
6753 + kdb_printf(" ======================= <%s>\n",
6756 + /* Run through all the stacks */
6757 + while (ar.stack.physical_start) {
6759 + eip = *(kdb_machreg_t *)esp;
6761 + if (!suppress && __kernel_text_address(eip)) {
6762 + kdbnearsym(eip, &symtab);
6763 + bt_print_one(eip, esp, &ar, &symtab, argcount);
6766 + if ((struct pt_regs *)esp == regs) {
6767 + if (ar.stack.next && suppress)
6768 + kdb_printf(" ======================= <%s>\n",
6773 + esp += sizeof(eip);
6776 + if (esp < ar.stack.logical_end)
6778 + if (!ar.stack.next)
6780 + esp = ar.stack.next;
6781 + if (KDB_DEBUG(ARA))
6782 + kdb_printf("new esp=0x%lx\n", esp);
6783 + kdba_get_stack_info(esp, -1, &ar, NULL);
6784 + if (!ar.stack.physical_start) {
6785 + kdb_printf("+++ Cannot resolve next stack\n");
6786 + } else if (!suppress) {
6787 + kdb_printf(" ======================= <%s>\n",
6794 + kdb_printf("bt truncated, count limit reached\n");
6795 + else if (suppress)
6797 + ("bt did not find pt_regs - no trace produced. Suggest 'set BTSP 1'\n");
6805 + * Do a backtrace starting at a specified stack address. Use this if the
6806 + * heuristics get the stack decode wrong.
6809 + * addr Address provided to 'bt' command.
6814 + * zero for success, a kdb diagnostic if error
6818 + * mds %esp comes in handy when examining the stack to do a manual
6822 +int kdba_bt_address(kdb_machreg_t addr, int argcount)
6824 + return kdba_bt_stack(addr, argcount, NULL);
6830 + * Do a backtrace for a specified process.
6833 + * p Struct task pointer extracted by 'bt' command.
6838 + * zero for success, a kdb diagnostic if error
6843 +int kdba_bt_process(const struct task_struct *p, int argcount)
6845 + return kdba_bt_stack(0, argcount, p);
6847 diff -Nurp linux-2.6.22-590/arch/i386/kdb/kdba_id.c linux-2.6.22-600/arch/i386/kdb/kdba_id.c
6848 --- linux-2.6.22-590/arch/i386/kdb/kdba_id.c 1970-01-01 01:00:00.000000000 +0100
6849 +++ linux-2.6.22-600/arch/i386/kdb/kdba_id.c 2008-04-09 18:16:14.000000000 +0200
6852 + * Kernel Debugger Architecture Dependent Instruction Disassembly
6854 + * This file is subject to the terms and conditions of the GNU General Public
6855 + * License. See the file "COPYING" in the main directory of this archive
6856 + * for more details.
6858 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
6861 +#include <stdarg.h>
6862 +#include <linux/kernel.h>
6863 +#include <linux/init.h>
6864 +#include <linux/ctype.h>
6865 +#include <linux/string.h>
6866 +#include <linux/kdb.h>
6867 +#include <linux/kdbprivate.h>
6872 + * Get a symbol for the disassembler.
6875 + * addr Address for which to get symbol
6876 + * dip Pointer to disassemble_info
6881 + * Not used for kdb.
6886 +kdba_dis_getsym(bfd_vma addr, disassemble_info *dip)
6893 + * kdba_printaddress
6895 + * Print (symbolically) an address.
6898 + * addr Address for which to get symbol
6899 + * dip Pointer to disassemble_info
6900 + * flag True if a ":<tab>" sequence should follow the address
6910 +kdba_printaddress(kdb_machreg_t addr, disassemble_info *dip, int flag)
6912 + kdb_symtab_t symtab;
6914 + unsigned int offset;
6917 + * Print a symbol name or address as necessary.
6919 + kdbnearsym(addr, &symtab);
6920 + if (symtab.sym_name) {
6921 + /* Do not use kdb_symbol_print here, it always does
6922 + * kdb_printf but we want dip->fprintf_func.
6924 + dip->fprintf_func(dip->stream,
6926 + (int)(2*sizeof(addr)), addr, symtab.sym_name);
6927 + if ((offset = addr - symtab.sym_start) == 0) {
6931 + unsigned int o = offset;
6934 + dip->fprintf_func(dip->stream, "+0x%x", offset);
6938 + dip->fprintf_func(dip->stream, "0x%lx", addr);
6945 + dip->fprintf_func(dip->stream, ":%*s", spaces, " ");
6950 + * kdba_dis_printaddr
6952 + * Print (symbolically) an address. Called by GNU disassembly
6953 + * code via disassemble_info structure.
6956 + * addr Address for which to get symbol
6957 + * dip Pointer to disassemble_info
6962 + * This function will never append ":<tab>" to the printed
6963 + * symbolic address.
6967 +kdba_dis_printaddr(bfd_vma addr, disassemble_info *dip)
6969 + kdba_printaddress(addr, dip, 0);
6975 + * Fetch 'length' bytes from 'addr' into 'buf'.
6978 + * addr Address for which to get symbol
6979 + * buf Address of buffer to fill with bytes from 'addr'
6980 + * length Number of bytes to fetch
6981 + * dip Pointer to disassemble_info
6983 + * 0 if data is available, otherwise error.
6991 +kdba_dis_getmem(bfd_vma addr, bfd_byte *buf, unsigned int length, disassemble_info *dip)
6993 + return kdb_getarea_size(buf, addr, length);
6997 + * kdba_id_parsemode
6999 + * Parse IDMODE environment variable string and
7000 + * set appropriate value into "disassemble_info" structure.
7003 + * mode Mode string
7004 + * dip Disassemble_info structure pointer
7008 + * We handle the values 'x86' and '8086' to enable either
7009 + * 32-bit instruction set or 16-bit legacy instruction set.
7013 +kdba_id_parsemode(const char *mode, disassemble_info *dip)
7017 + if (strcmp(mode, "x86") == 0) {
7018 + dip->mach = bfd_mach_i386_i386;
7019 + } else if (strcmp(mode, "8086") == 0) {
7020 + dip->mach = bfd_mach_i386_i8086;
7022 + return KDB_BADMODE;
7032 + * Check that the pc is satisfactory.
7035 + * pc Program Counter Value.
7045 +kdba_check_pc(kdb_machreg_t *pc)
7051 + * kdba_id_printinsn
7053 + * Format and print a single instruction at 'pc'. Return the
7054 + * length of the instruction.
7057 + * pc Program Counter Value.
7058 + * dip Disassemble_info structure pointer
7060 + * Length of instruction, -1 for error.
7064 + * Depends on 'IDMODE' environment variable.
7068 +kdba_id_printinsn(kdb_machreg_t pc, disassemble_info *dip)
7070 + kdba_printaddress(pc, dip, 1);
7071 + return print_insn_i386_att(pc, dip);
7077 + * Initialize the architecture dependent elements of
7078 + * the disassembly information structure
7079 + * for the GNU disassembler.
7093 +kdba_id_init(disassemble_info *dip)
7095 + dip->read_memory_func = kdba_dis_getmem;
7096 + dip->print_address_func = kdba_dis_printaddr;
7097 + dip->symbol_at_address_func = kdba_dis_getsym;
7099 + dip->flavour = bfd_target_elf_flavour;
7100 + dip->arch = bfd_arch_i386;
7101 + dip->mach = bfd_mach_i386_i386;
7102 + dip->endian = BFD_ENDIAN_LITTLE;
7104 + dip->display_endian = BFD_ENDIAN_LITTLE;
7106 diff -Nurp linux-2.6.22-590/arch/i386/kdb/kdba_io.c linux-2.6.22-600/arch/i386/kdb/kdba_io.c
7107 --- linux-2.6.22-590/arch/i386/kdb/kdba_io.c 1970-01-01 01:00:00.000000000 +0100
7108 +++ linux-2.6.22-600/arch/i386/kdb/kdba_io.c 2008-04-09 18:16:14.000000000 +0200
7111 + * Kernel Debugger Architecture Dependent Console I/O handler
7113 + * This file is subject to the terms and conditions of the GNU General Public
7114 + * License. See the file "COPYING" in the main directory of this archive
7115 + * for more details.
7117 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
7120 +#include <linux/sched.h>
7121 +#include <linux/kernel.h>
7122 +#include <asm/io.h>
7123 +#include <linux/delay.h>
7124 +#include <linux/console.h>
7125 +#include <linux/ctype.h>
7126 +#include <linux/keyboard.h>
7127 +#include <linux/serial.h>
7128 +#include <linux/serial_reg.h>
7130 +#include <linux/kdb.h>
7131 +#include <linux/kdbprivate.h>
7132 +#include <pc_keyb.h>
7134 +#ifdef CONFIG_VT_CONSOLE
7135 +#define KDB_BLINK_LED 1
7137 +#undef KDB_BLINK_LED
7140 +#ifdef CONFIG_KDB_USB
7141 +struct kdb_usb_exchange kdb_usb_infos;
7143 +EXPORT_SYMBOL(kdb_usb_infos);
7145 +static unsigned char kdb_usb_keycode[256] = {
7146 + 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
7147 + 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
7148 + 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
7149 + 27, 43, 84, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
7150 + 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
7151 + 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
7152 + 72, 73, 82, 83, 86,127,116,117, 85, 89, 90, 91, 92, 93, 94, 95,
7153 + 120,121,122,123,134,138,130,132,128,129,131,137,133,135,136,113,
7154 + 115,114, 0, 0, 0,124, 0,181,182,183,184,185,186,187,188,189,
7155 + 190,191,192,193,194,195,196,197,198, 0, 0, 0, 0, 0, 0, 0,
7156 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7157 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7158 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7159 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7160 + 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
7161 + 150,158,159,128,136,177,178,176,142,152,173,140
7165 + * This function drives the UHCI controller,
7166 + * fetch the USB scancode and decode it
7168 +static int get_usb_char(void)
7170 + static int usb_lock;
7171 + unsigned char keycode, spec;
7172 + extern u_short plain_map[], shift_map[], ctrl_map[];
7174 + /* Is USB initialized ? */
7175 + if(!kdb_usb_infos.poll_func || !kdb_usb_infos.urb)
7178 + /* Transfer char if they are present */
7179 + (*kdb_usb_infos.poll_func)(kdb_usb_infos.uhci, (struct urb *)kdb_usb_infos.urb);
7181 + spec = kdb_usb_infos.buffer[0];
7182 + keycode = kdb_usb_infos.buffer[2];
7183 + kdb_usb_infos.buffer[0] = (char)0;
7184 + kdb_usb_infos.buffer[2] = (char)0;
7186 + if(kdb_usb_infos.buffer[3])
7189 + /* A normal key is pressed, decode it */
7191 + keycode = kdb_usb_keycode[keycode];
7193 + /* 2 Keys pressed at one time ? */
7194 + if (spec && keycode) {
7198 + case 0x20: /* Shift */
7199 + return shift_map[keycode];
7201 + case 0x10: /* Ctrl */
7202 + return ctrl_map[keycode];
7204 + case 0x40: /* Alt */
7209 + if(keycode) { /* If only one key pressed */
7212 + case 0x1C: /* Enter */
7215 + case 0x3A: /* Capslock */
7216 + usb_lock ? (usb_lock = 0) : (usb_lock = 1);
7218 + case 0x0E: /* Backspace */
7220 + case 0x0F: /* TAB */
7222 + case 0x77: /* Pause */
7226 + return plain_map[keycode];
7229 + return shift_map[keycode];
7236 +#endif /* CONFIG_KDB_USB */
7239 + * This module contains code to read characters from the keyboard or a serial
7242 + * It is used by the kernel debugger, and is polled, not interrupt driven.
7246 +#ifdef KDB_BLINK_LED
7248 + * send: Send a byte to the keyboard controller. Used primarily to
7249 + * alter LED settings.
7253 +kdb_kbdsend(unsigned char byte)
7256 + for (timeout = 200 * 1000; timeout && (inb(KBD_STATUS_REG) & KBD_STAT_IBF); timeout--);
7257 + outb(byte, KBD_DATA_REG);
7259 + for (timeout = 200 * 1000; timeout && (~inb(KBD_STATUS_REG) & KBD_STAT_OBF); timeout--);
7260 + inb(KBD_DATA_REG);
7265 +kdb_toggleled(int led)
7271 + kdb_kbdsend(KBD_CMD_SET_LEDS);
7272 + kdb_kbdsend((unsigned char)leds);
7274 +#endif /* KDB_BLINK_LED */
7276 +#if defined(CONFIG_SERIAL_8250_CONSOLE) || defined(CONFIG_SERIAL_CORE_CONSOLE)
7277 +#define CONFIG_SERIAL_CONSOLE
7280 +#if defined(CONFIG_SERIAL_CONSOLE)
7282 +struct kdb_serial kdb_serial;
7284 +static unsigned int
7285 +serial_inp(struct kdb_serial *kdb_serial, unsigned long offset)
7287 + offset <<= kdb_serial->ioreg_shift;
7289 + switch (kdb_serial->io_type) {
7290 + case SERIAL_IO_MEM:
7291 + return readb((void __iomem *)(kdb_serial->iobase + offset));
7294 + return inb(kdb_serial->iobase + offset);
7299 +/* Check if there is a byte ready at the serial port */
7300 +static int get_serial_char(void)
7304 + if (kdb_serial.iobase == 0)
7307 + if (serial_inp(&kdb_serial, UART_LSR) & UART_LSR_DR) {
7308 + ch = serial_inp(&kdb_serial, UART_RX);
7315 +#endif /* CONFIG_SERIAL_CONSOLE */
7317 +#ifdef CONFIG_VT_CONSOLE
7319 +static int kbd_exists;
7322 + * Check if the keyboard controller has a keypress for us.
7323 + * Some parts (Enter Release, LED change) are still blocking polled here,
7324 + * but hopefully they are all short.
7326 +static int get_kbd_char(void)
7328 + int scancode, scanstatus;
7329 + static int shift_lock; /* CAPS LOCK state (0-off, 1-on) */
7330 + static int shift_key; /* Shift next keypress */
7331 + static int ctrl_key;
7333 + extern u_short plain_map[], shift_map[], ctrl_map[];
7335 + if (KDB_FLAG(NO_I8042) || KDB_FLAG(NO_VT_CONSOLE) ||
7336 + (inb(KBD_STATUS_REG) == 0xff && inb(KBD_DATA_REG) == 0xff)) {
7342 + if ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0)
7346 + * Fetch the scancode
7348 + scancode = inb(KBD_DATA_REG);
7349 + scanstatus = inb(KBD_STATUS_REG);
7352 + * Ignore mouse events.
7354 + if (scanstatus & KBD_STAT_MOUSE_OBF)
7358 + * Ignore release, trigger on make
7359 + * (except for shift keys, where we want to
7360 + * keep the shift state so long as the key is
7364 + if (((scancode&0x7f) == 0x2a) || ((scancode&0x7f) == 0x36)) {
7366 + * Next key may use shift table
7368 + if ((scancode & 0x80) == 0) {
7376 + if ((scancode&0x7f) == 0x1d) {
7380 + if ((scancode & 0x80) == 0) {
7388 + if ((scancode & 0x80) != 0)
7394 + * Translate scancode
7397 + if (scancode == 0x3a) {
7399 + * Toggle caps lock
7403 +#ifdef KDB_BLINK_LED
7404 + kdb_toggleled(0x4);
7409 + if (scancode == 0x0e) {
7417 + switch (scancode) {
7418 + case 0xF: /* Tab */
7420 + case 0x53: /* Del */
7422 + case 0x47: /* Home */
7424 + case 0x4F: /* End */
7426 + case 0x4B: /* Left */
7428 + case 0x48: /* Up */
7430 + case 0x50: /* Down */
7432 + case 0x4D: /* Right */
7436 + if (scancode == 0xe0) {
7441 + * For Japanese 86/106 keyboards
7442 + * See comment in drivers/char/pc_keyb.c.
7443 + * - Masahiro Adegawa
7445 + if (scancode == 0x73) {
7447 + } else if (scancode == 0x7d) {
7451 + if (!shift_lock && !shift_key && !ctrl_key) {
7452 + keychar = plain_map[scancode];
7453 + } else if (shift_lock || shift_key) {
7454 + keychar = shift_map[scancode];
7455 + } else if (ctrl_key) {
7456 + keychar = ctrl_map[scancode];
7459 + kdb_printf("Unknown state/scancode (%d)\n", scancode);
7461 + keychar &= 0x0fff;
7462 + if (keychar == '\t')
7464 + switch (KTYP(keychar)) {
7467 + if (isprint(keychar))
7468 + break; /* printable characters */
7469 + /* drop through */
7471 + if (keychar == K_ENTER)
7473 + /* drop through */
7475 + return(-1); /* ignore unprintables */
7478 + if ((scancode & 0x7f) == 0x1c) {
7480 + * enter key. All done. Absorb the release scancode.
7482 + while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0)
7486 + * Fetch the scancode
7488 + scancode = inb(KBD_DATA_REG);
7489 + scanstatus = inb(KBD_STATUS_REG);
7491 + while (scanstatus & KBD_STAT_MOUSE_OBF) {
7492 + scancode = inb(KBD_DATA_REG);
7493 + scanstatus = inb(KBD_STATUS_REG);
7496 + if (scancode != 0x9c) {
7498 + * Wasn't an enter-release, why not?
7500 + kdb_printf("kdb: expected enter got 0x%x status 0x%x\n",
7501 + scancode, scanstatus);
7508 + return keychar & 0xff;
7510 +#endif /* CONFIG_VT_CONSOLE */
7512 +#ifdef KDB_BLINK_LED
7514 +/* Leave numlock alone, setting it messes up laptop keyboards with the keypad
7515 + * mapped over normal keys.
7517 +static int kdba_blink_mask = 0x1 | 0x4;
7519 +#define BOGOMIPS (boot_cpu_data.loops_per_jiffy/(500000/HZ))
7520 +static int blink_led(void)
7522 + static long delay;
7524 + if (kbd_exists == 0)
7527 + if (--delay < 0) {
7528 + if (BOGOMIPS == 0) /* early kdb */
7529 + delay = 150000000/1000; /* arbitrary bogomips */
7531 + delay = 150000000/BOGOMIPS; /* Roughly 1 second when polling */
7532 + kdb_toggleled(kdba_blink_mask);
7538 +get_char_func poll_funcs[] = {
7539 +#if defined(CONFIG_VT_CONSOLE)
7542 +#if defined(CONFIG_SERIAL_CONSOLE)
7545 +#ifdef KDB_BLINK_LED
7548 +#ifdef CONFIG_KDB_USB
7555 + * On some Compaq Deskpro's, there is a keyboard freeze many times after
7556 + * exiting from the kdb. As kdb's keyboard handler is not interrupt-driven and
7557 + * uses a polled interface, it makes more sense to disable motherboard keyboard
7558 + * controller's OBF interrupts during kdb's polling.In case, of interrupts
7559 + * remaining enabled during kdb's polling, it may cause un-necessary
7560 + * interrupts being signalled during keypresses, which are also sometimes seen
7561 + * as spurious interrupts after exiting from kdb. This hack to disable OBF
7562 + * interrupts before entry to kdb and re-enabling them at kdb exit point also
7563 + * solves the keyboard freeze issue. These functions are called from
7564 + * kdb_local(), hence these are arch. specific setup and cleanup functions
7565 + * executing only on the local processor - ashishk@sco.com
7568 +void kdba_local_arch_setup(void)
7570 +#ifdef CONFIG_VT_CONSOLE
7573 + while (kbd_read_status() & KBD_STAT_IBF);
7574 + kbd_write_command(KBD_CCMD_READ_MODE);
7576 + while (kbd_read_status() & KBD_STAT_IBF);
7577 + while ( !(kbd_read_status() & KBD_STAT_OBF) );
7578 + c = kbd_read_input();
7579 + c &= ~KBD_MODE_KBD_INT;
7580 + while (kbd_read_status() & KBD_STAT_IBF);
7581 + kbd_write_command(KBD_CCMD_WRITE_MODE);
7583 + while (kbd_read_status() & KBD_STAT_IBF);
7584 + kbd_write_output(c);
7586 + while (kbd_read_status() & KBD_STAT_IBF);
7588 +#endif /* CONFIG_VT_CONSOLE */
7591 +void kdba_local_arch_cleanup(void)
7593 +#ifdef CONFIG_VT_CONSOLE
7596 + while (kbd_read_status() & KBD_STAT_IBF);
7597 + kbd_write_command(KBD_CCMD_READ_MODE);
7599 + while (kbd_read_status() & KBD_STAT_IBF);
7600 + while ( !(kbd_read_status() & KBD_STAT_OBF) );
7601 + c = kbd_read_input();
7602 + c |= KBD_MODE_KBD_INT;
7603 + while (kbd_read_status() & KBD_STAT_IBF);
7604 + kbd_write_command(KBD_CCMD_WRITE_MODE);
7606 + while (kbd_read_status() & KBD_STAT_IBF);
7607 + kbd_write_output(c);
7609 + while (kbd_read_status() & KBD_STAT_IBF);
7611 +#endif /* CONFIG_VT_CONSOLE */
7613 diff -Nurp linux-2.6.22-590/arch/i386/kdb/kdbasupport.c linux-2.6.22-600/arch/i386/kdb/kdbasupport.c
7614 --- linux-2.6.22-590/arch/i386/kdb/kdbasupport.c 1970-01-01 01:00:00.000000000 +0100
7615 +++ linux-2.6.22-600/arch/i386/kdb/kdbasupport.c 2008-04-09 18:16:14.000000000 +0200
7618 + * Kernel Debugger Architecture Independent Support Functions
7620 + * This file is subject to the terms and conditions of the GNU General Public
7621 + * License. See the file "COPYING" in the main directory of this archive
7622 + * for more details.
7624 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
7627 +#include <linux/string.h>
7628 +#include <linux/stddef.h>
7629 +#include <linux/kernel.h>
7630 +#include <linux/module.h>
7631 +#include <linux/init.h>
7632 +#include <linux/irq.h>
7633 +#include <linux/ptrace.h>
7634 +#include <linux/mm.h>
7635 +#include <linux/sched.h>
7636 +#include <linux/hardirq.h>
7637 +#include <linux/kdb.h>
7638 +#include <linux/kdbprivate.h>
7640 +#include <asm/processor.h>
7641 +#include <asm/msr.h>
7642 +#include <asm/uaccess.h>
7643 +#include <asm/desc.h>
7645 +static kdb_machreg_t
7646 +kdba_getcr(int regnum)
7648 + kdb_machreg_t contents = 0;
7651 + __asm__ ("movl %%cr0,%0\n\t":"=r"(contents));
7656 + __asm__ ("movl %%cr2,%0\n\t":"=r"(contents));
7659 + __asm__ ("movl %%cr3,%0\n\t":"=r"(contents));
7662 + __asm__ ("movl %%cr4,%0\n\t":"=r"(contents));
7672 +kdba_putdr(int regnum, kdb_machreg_t contents)
7676 + __asm__ ("movl %0,%%db0\n\t"::"r"(contents));
7679 + __asm__ ("movl %0,%%db1\n\t"::"r"(contents));
7682 + __asm__ ("movl %0,%%db2\n\t"::"r"(contents));
7685 + __asm__ ("movl %0,%%db3\n\t"::"r"(contents));
7691 + __asm__ ("movl %0,%%db6\n\t"::"r"(contents));
7694 + __asm__ ("movl %0,%%db7\n\t"::"r"(contents));
7701 +static kdb_machreg_t
7702 +kdba_getdr(int regnum)
7704 + kdb_machreg_t contents = 0;
7707 + __asm__ ("movl %%db0,%0\n\t":"=r"(contents));
7710 + __asm__ ("movl %%db1,%0\n\t":"=r"(contents));
7713 + __asm__ ("movl %%db2,%0\n\t":"=r"(contents));
7716 + __asm__ ("movl %%db3,%0\n\t":"=r"(contents));
7722 + __asm__ ("movl %%db6,%0\n\t":"=r"(contents));
7725 + __asm__ ("movl %%db7,%0\n\t":"=r"(contents));
7737 + return kdba_getdr(6);
7743 + return kdba_getdr(7);
7747 +kdba_putdr6(kdb_machreg_t contents)
7749 + kdba_putdr(6, contents);
7753 +kdba_putdr7(kdb_machreg_t contents)
7755 + kdba_putdr(7, contents);
7759 +kdba_installdbreg(kdb_bp_t *bp)
7761 + kdb_machreg_t dr7;
7763 + dr7 = kdba_getdr7();
7765 + kdba_putdr(bp->bp_hard->bph_reg, bp->bp_addr);
7769 + set_in_cr4(X86_CR4_DE);
7771 + switch (bp->bp_hard->bph_reg){
7773 + DR7_RW0SET(dr7,bp->bp_hard->bph_mode);
7774 + DR7_LEN0SET(dr7,bp->bp_hard->bph_length);
7778 + DR7_RW1SET(dr7,bp->bp_hard->bph_mode);
7779 + DR7_LEN1SET(dr7,bp->bp_hard->bph_length);
7783 + DR7_RW2SET(dr7,bp->bp_hard->bph_mode);
7784 + DR7_LEN2SET(dr7,bp->bp_hard->bph_length);
7788 + DR7_RW3SET(dr7,bp->bp_hard->bph_mode);
7789 + DR7_LEN3SET(dr7,bp->bp_hard->bph_length);
7793 + kdb_printf("kdb: Bad debug register!! %ld\n",
7794 + bp->bp_hard->bph_reg);
7803 +kdba_removedbreg(kdb_bp_t *bp)
7806 + kdb_machreg_t dr7;
7811 + regnum = bp->bp_hard->bph_reg;
7813 + dr7 = kdba_getdr7();
7815 + kdba_putdr(regnum, 0);
7835 + kdb_printf("kdb: Bad debug register!! %d\n", regnum);
7844 + * kdba_getregcontents
7846 + * Return the contents of the register specified by the
7847 + * input string argument. Return an error if the string
7848 + * does not match a machine register.
7850 + * The following pseudo register names are supported:
7851 + * ®s - Prints address of exception frame
7852 + * kesp - Prints kernel stack pointer at time of fault
7853 + * cesp - Prints current kernel stack pointer, inside kdb
7854 + * ceflags - Prints current flags, inside kdb
7855 + * %<regname> - Uses the value of the registers at the
7856 + * last time the user process entered kernel
7857 + * mode, instead of the registers at the time
7858 + * kdb was entered.
7861 + * regname Pointer to string naming register
7862 + * regs Pointer to structure containing registers.
7864 + * *contents Pointer to unsigned long to recieve register contents
7867 + * KDB_BADREG Invalid register name
7871 + * If kdb was entered via an interrupt from the kernel itself then
7872 + * ss and esp are *not* on the stack.
7875 +static struct kdbregs {
7877 + size_t reg_offset;
7879 + { "eax", offsetof(struct pt_regs, eax) },
7880 + { "ebx", offsetof(struct pt_regs, ebx) },
7881 + { "ecx", offsetof(struct pt_regs, ecx) },
7882 + { "edx", offsetof(struct pt_regs, edx) },
7884 + { "esi", offsetof(struct pt_regs, esi) },
7885 + { "edi", offsetof(struct pt_regs, edi) },
7886 + { "esp", offsetof(struct pt_regs, esp) },
7887 + { "eip", offsetof(struct pt_regs, eip) },
7889 + { "ebp", offsetof(struct pt_regs, ebp) },
7890 + { "xss", offsetof(struct pt_regs, xss) },
7891 + { "xcs", offsetof(struct pt_regs, xcs) },
7892 + { "eflags", offsetof(struct pt_regs, eflags) },
7894 + { "xds", offsetof(struct pt_regs, xds) },
7895 + { "xes", offsetof(struct pt_regs, xes) },
7896 + { "origeax", offsetof(struct pt_regs, orig_eax) },
7900 +static const int nkdbreglist = sizeof(kdbreglist) / sizeof(struct kdbregs);
7902 +static struct kdbregs dbreglist[] = {
7911 +static const int ndbreglist = sizeof(dbreglist) / sizeof(struct kdbregs);
7914 +kdba_getregcontents(const char *regname,
7915 + struct pt_regs *regs,
7916 + kdb_machreg_t *contents)
7920 + if (strcmp(regname, "cesp") == 0) {
7921 + asm volatile("movl %%esp,%0":"=m" (*contents));
7925 + if (strcmp(regname, "ceflags") == 0) {
7926 + unsigned long flags;
7927 + local_save_flags(flags);
7928 + *contents = flags;
7932 + if (regname[0] == '%') {
7933 + /* User registers: %%e[a-c]x, etc */
7935 + regs = (struct pt_regs *)
7936 + (kdb_current_task->thread.esp0 - sizeof(struct pt_regs));
7939 + for (i=0; i<ndbreglist; i++) {
7940 + if (strnicmp(dbreglist[i].reg_name,
7942 + strlen(regname)) == 0)
7946 + if ((i < ndbreglist)
7947 + && (strlen(dbreglist[i].reg_name) == strlen(regname))) {
7948 + *contents = kdba_getdr(dbreglist[i].reg_offset);
7953 + kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
7954 + return KDB_BADREG;
7957 + if (strcmp(regname, "®s") == 0) {
7958 + *contents = (unsigned long)regs;
7962 + if (strcmp(regname, "kesp") == 0) {
7963 + *contents = (unsigned long)regs + sizeof(struct pt_regs);
7964 + if ((regs->xcs & 0xffff) == __KERNEL_CS) {
7965 + /* esp and ss are not on stack */
7971 + for (i=0; i<nkdbreglist; i++) {
7972 + if (strnicmp(kdbreglist[i].reg_name,
7974 + strlen(regname)) == 0)
7978 + if ((i < nkdbreglist)
7979 + && (strlen(kdbreglist[i].reg_name) == strlen(regname))) {
7980 + if ((regs->xcs & 0xffff) == __KERNEL_CS) {
7981 + /* No cpl switch, esp and ss are not on stack */
7982 + if (strcmp(kdbreglist[i].reg_name, "esp") == 0) {
7983 + *contents = (kdb_machreg_t)regs +
7984 + sizeof(struct pt_regs) - 2*4;
7987 + if (strcmp(kdbreglist[i].reg_name, "xss") == 0) {
7991 + :"=m" (*contents));
7995 + *contents = *(unsigned long *)((unsigned long)regs +
7996 + kdbreglist[i].reg_offset);
8000 + return KDB_BADREG;
8004 + * kdba_setregcontents
8006 + * Set the contents of the register specified by the
8007 + * input string argument. Return an error if the string
8008 + * does not match a machine register.
8010 + * Supports modification of user-mode registers via
8011 + * %<register-name>
8014 + * regname Pointer to string naming register
8015 + * regs Pointer to structure containing registers.
8016 + * contents Unsigned long containing new register contents
8020 + * KDB_BADREG Invalid register name
8027 +kdba_setregcontents(const char *regname,
8028 + struct pt_regs *regs,
8029 + unsigned long contents)
8033 + if (regname[0] == '%') {
8035 + regs = (struct pt_regs *)
8036 + (kdb_current_task->thread.esp0 - sizeof(struct pt_regs));
8039 + for (i=0; i<ndbreglist; i++) {
8040 + if (strnicmp(dbreglist[i].reg_name,
8042 + strlen(regname)) == 0)
8046 + if ((i < ndbreglist)
8047 + && (strlen(dbreglist[i].reg_name) == strlen(regname))) {
8048 + kdba_putdr(dbreglist[i].reg_offset, contents);
8053 + kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
8054 + return KDB_BADREG;
8057 + for (i=0; i<nkdbreglist; i++) {
8058 + if (strnicmp(kdbreglist[i].reg_name,
8060 + strlen(regname)) == 0)
8064 + if ((i < nkdbreglist)
8065 + && (strlen(kdbreglist[i].reg_name) == strlen(regname))) {
8066 + *(unsigned long *)((unsigned long)regs
8067 + + kdbreglist[i].reg_offset) = contents;
8071 + return KDB_BADREG;
8077 + * Dump the specified register set to the display.
8080 + * regs Pointer to structure containing registers.
8081 + * type Character string identifying register set to dump
8082 + * extra string further identifying register (optional)
8089 + * This function will dump the general register set if the type
8090 + * argument is NULL (struct pt_regs). The alternate register
8091 + * set types supported by this function:
8093 + * d Debug registers
8094 + * c Control registers
8095 + * u User registers at most recent entry to kernel
8096 + * for the process currently selected with "pid" command.
8097 + * Following not yet implemented:
8098 + * r Memory Type Range Registers (extra defines register)
8100 + * MSR on i386/x86_64 are handled by rdmsr/wrmsr commands.
8104 +kdba_dumpregs(struct pt_regs *regs,
8106 + const char *extra)
8112 + && (type[0] == 'u')) {
8114 + regs = (struct pt_regs *)
8115 + (kdb_current_task->thread.esp0 - sizeof(struct pt_regs));
8118 + if (type == NULL) {
8119 + struct kdbregs *rlp;
8120 + kdb_machreg_t contents;
8123 + kdb_printf("%s: pt_regs not available, use bt* or pid to select a different task\n", __FUNCTION__);
8124 + return KDB_BADREG;
8127 + for (i=0, rlp=kdbreglist; i<nkdbreglist; i++,rlp++) {
8128 + kdb_printf("%s = ", rlp->reg_name);
8129 + kdba_getregcontents(rlp->reg_name, regs, &contents);
8130 + kdb_printf("0x%08lx ", contents);
8131 + if ((++count % 4) == 0)
8135 + kdb_printf("®s = 0x%p\n", regs);
8140 + switch (type[0]) {
8143 + unsigned long dr[8];
8145 + for(i=0; i<8; i++) {
8146 + if ((i == 4) || (i == 5)) continue;
8147 + dr[i] = kdba_getdr(i);
8149 + kdb_printf("dr0 = 0x%08lx dr1 = 0x%08lx dr2 = 0x%08lx dr3 = 0x%08lx\n",
8150 + dr[0], dr[1], dr[2], dr[3]);
8151 + kdb_printf("dr6 = 0x%08lx dr7 = 0x%08lx\n",
8157 + unsigned long cr[5];
8159 + for (i=0; i<5; i++) {
8160 + cr[i] = kdba_getcr(i);
8162 + kdb_printf("cr0 = 0x%08lx cr1 = 0x%08lx cr2 = 0x%08lx cr3 = 0x%08lx\ncr4 = 0x%08lx\n",
8163 + cr[0], cr[1], cr[2], cr[3], cr[4]);
8169 + return KDB_BADREG;
8175 +EXPORT_SYMBOL(kdba_dumpregs);
8178 +kdba_getpc(struct pt_regs *regs)
8180 + return regs ? regs->eip : 0;
8184 +kdba_setpc(struct pt_regs *regs, kdb_machreg_t newpc)
8186 + if (KDB_NULL_REGS(regs))
8187 + return KDB_BADREG;
8188 + regs->eip = newpc;
8189 + KDB_STATE_SET(IP_ADJUSTED);
8196 + * Do any architecture specific set up before entering the main kdb loop.
8197 + * The primary function of this routine is to make all processes look the
8198 + * same to kdb, kdb must be able to list a process without worrying if the
8199 + * process is running or blocked, so make all process look as though they
8203 + * reason The reason KDB was invoked
8204 + * error The hardware-defined error code
8205 + * error2 kdb's current reason code. Initially error but can change
8206 + * acording to kdb state.
8207 + * db_result Result from break or debug point.
8208 + * regs The exception frame at time of fault/breakpoint. If reason
8209 + * is SILENT or CPU_UP then regs is NULL, otherwise it should
8210 + * always be valid.
8212 + * 0 KDB was invoked for an event which it wasn't responsible
8213 + * 1 KDB handled the event for which it was invoked.
8215 + * Sets eip and esp in current->thread.
8223 +kdba_main_loop(kdb_reason_t reason, kdb_reason_t reason2, int error,
8224 + kdb_dbtrap_t db_result, struct pt_regs *regs)
8227 + kdb_save_running(regs);
8228 + ret = kdb_main_loop(reason, reason2, error, db_result, regs);
8229 + kdb_unsave_running(regs);
8234 +kdba_disableint(kdb_intstate_t *state)
8236 + unsigned long *fp = (unsigned long *)state;
8237 + unsigned long flags;
8239 + local_irq_save(flags);
8245 +kdba_restoreint(kdb_intstate_t *state)
8247 + unsigned long flags = *(int *)state;
8248 + local_irq_restore(flags);
8252 +kdba_setsinglestep(struct pt_regs *regs)
8254 + if (KDB_NULL_REGS(regs))
8256 + if (regs->eflags & EF_IE)
8257 + KDB_STATE_SET(A_IF);
8259 + KDB_STATE_CLEAR(A_IF);
8260 + regs->eflags = (regs->eflags | EF_TF) & ~EF_IE;
8264 +kdba_clearsinglestep(struct pt_regs *regs)
8266 + if (KDB_NULL_REGS(regs))
8268 + if (KDB_STATE(A_IF))
8269 + regs->eflags |= EF_IE;
8271 + regs->eflags &= ~EF_IE;
8275 +kdba_setjmp(kdb_jmp_buf *jb)
8277 +#if defined(CONFIG_FRAME_POINTER)
8278 + __asm__ ("movl 8(%esp), %eax\n\t"
8279 + "movl %ebx, 0(%eax)\n\t"
8280 + "movl %esi, 4(%eax)\n\t"
8281 + "movl %edi, 8(%eax)\n\t"
8282 + "movl (%esp), %ecx\n\t"
8283 + "movl %ecx, 12(%eax)\n\t"
8284 + "leal 8(%esp), %ecx\n\t"
8285 + "movl %ecx, 16(%eax)\n\t"
8286 + "movl 4(%esp), %ecx\n\t"
8287 + "movl %ecx, 20(%eax)\n\t");
8288 +#else /* CONFIG_FRAME_POINTER */
8289 + __asm__ ("movl 4(%esp), %eax\n\t"
8290 + "movl %ebx, 0(%eax)\n\t"
8291 + "movl %esi, 4(%eax)\n\t"
8292 + "movl %edi, 8(%eax)\n\t"
8293 + "movl %ebp, 12(%eax)\n\t"
8294 + "leal 4(%esp), %ecx\n\t"
8295 + "movl %ecx, 16(%eax)\n\t"
8296 + "movl 0(%esp), %ecx\n\t"
8297 + "movl %ecx, 20(%eax)\n\t");
8298 +#endif /* CONFIG_FRAME_POINTER */
8303 +kdba_longjmp(kdb_jmp_buf *jb, int reason)
8305 +#if defined(CONFIG_FRAME_POINTER)
8306 + __asm__("movl 8(%esp), %ecx\n\t"
8307 + "movl 12(%esp), %eax\n\t"
8308 + "movl 20(%ecx), %edx\n\t"
8309 + "movl 0(%ecx), %ebx\n\t"
8310 + "movl 4(%ecx), %esi\n\t"
8311 + "movl 8(%ecx), %edi\n\t"
8312 + "movl 12(%ecx), %ebp\n\t"
8313 + "movl 16(%ecx), %esp\n\t"
8315 +#else /* CONFIG_FRAME_POINTER */
8316 + __asm__("movl 4(%esp), %ecx\n\t"
8317 + "movl 8(%esp), %eax\n\t"
8318 + "movl 20(%ecx), %edx\n\t"
8319 + "movl 0(%ecx), %ebx\n\t"
8320 + "movl 4(%ecx), %esi\n\t"
8321 + "movl 8(%ecx), %edi\n\t"
8322 + "movl 12(%ecx), %ebp\n\t"
8323 + "movl 16(%ecx), %esp\n\t"
8325 +#endif /* CONFIG_FRAME_POINTER */
8331 + * Format a struct pt_regs
8334 + * argc argument count
8335 + * argv argument vector
8339 + * zero for success, a kdb diagnostic if error
8343 + * If no address is supplied, it uses the last irq pt_regs.
8347 +kdba_pt_regs(int argc, const char **argv)
8350 + kdb_machreg_t addr;
8353 + struct pt_regs *p;
8354 + static const char *fmt = " %-11.11s 0x%lx\n";
8357 + addr = (kdb_machreg_t) get_irq_regs();
8358 + } else if (argc == 1) {
8360 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
8364 + return KDB_ARGCOUNT;
8367 + p = (struct pt_regs *) addr;
8368 + kdb_printf("struct pt_regs 0x%p-0x%p\n", p, (unsigned char *)p + sizeof(*p) - 1);
8369 + kdb_print_nameval("ebx", p->ebx);
8370 + kdb_print_nameval("ecx", p->ecx);
8371 + kdb_print_nameval("edx", p->edx);
8372 + kdb_print_nameval("esi", p->esi);
8373 + kdb_print_nameval("edi", p->edi);
8374 + kdb_print_nameval("ebp", p->ebp);
8375 + kdb_print_nameval("eax", p->eax);
8376 + kdb_printf(fmt, "xds", p->xds);
8377 + kdb_printf(fmt, "xes", p->xes);
8378 + kdb_print_nameval("orig_eax", p->orig_eax);
8379 + kdb_print_nameval("eip", p->eip);
8380 + kdb_printf(fmt, "xcs", p->xcs);
8381 + kdb_printf(fmt, "eflags", p->eflags);
8382 + kdb_printf(fmt, "esp", p->esp);
8383 + kdb_printf(fmt, "xss", p->xss);
8390 + * Print processes that are using more than a specific percentage of their
8394 + * argc argument count
8395 + * argv argument vector
8399 + * zero for success, a kdb diagnostic if error
8403 + * If no percentage is supplied, it uses 60.
8407 +kdba_stackdepth1(struct task_struct *p, unsigned long esp)
8409 + struct thread_info *tinfo;
8414 + tinfo = (struct thread_info *)(esp & -THREAD_SIZE);
8415 + used = sizeof(*tinfo) + THREAD_SIZE - (esp & (THREAD_SIZE-1));
8417 + if (kdb_task_has_cpu(p)) {
8418 + struct kdb_activation_record ar;
8419 + memset(&ar, 0, sizeof(ar));
8420 + kdba_get_stack_info_alternate(esp, -1, &ar);
8421 + type = ar.stack.id;
8425 + kdb_printf(" %s stack %p esp %lx used %d\n", type, tinfo, esp, used);
8426 + esp = tinfo->previous_esp;
8431 +kdba_stackdepth(int argc, const char **argv)
8433 + int diag, cpu, threshold, used, over;
8434 + unsigned long percentage;
8435 + unsigned long esp;
8438 + struct task_struct *p, *g;
8439 + struct kdb_running_process *krp;
8440 + struct thread_info *tinfo;
8444 + } else if (argc == 1) {
8446 + diag = kdbgetaddrarg(argc, argv, &nextarg, &percentage, &offset, NULL);
8450 + return KDB_ARGCOUNT;
8452 + percentage = max_t(int, percentage, 1);
8453 + percentage = min_t(int, percentage, 100);
8454 + threshold = ((2 * THREAD_SIZE * percentage) / 100 + 1) >> 1;
8455 + kdb_printf("stackdepth: processes using more than %ld%% (%d bytes) of stack\n",
8456 + percentage, threshold);
8458 + /* Run the active tasks first, they can have multiple stacks */
8459 + for (cpu = 0, krp = kdb_running_process; cpu < NR_CPUS; ++cpu, ++krp) {
8460 + if (!cpu_online(cpu))
8463 + esp = krp->arch.esp;
8466 + tinfo = (struct thread_info *)(esp & -THREAD_SIZE);
8467 + used = sizeof(*tinfo) + THREAD_SIZE - (esp & (THREAD_SIZE-1));
8468 + if (used >= threshold)
8470 + esp = tinfo->previous_esp;
8473 + kdba_stackdepth1(p, krp->arch.esp);
8475 + /* Now the tasks that are not on cpus */
8476 + kdb_do_each_thread(g, p) {
8477 + if (kdb_task_has_cpu(p))
8479 + esp = p->thread.esp;
8480 + used = sizeof(*tinfo) + THREAD_SIZE - (esp & (THREAD_SIZE-1));
8481 + over = used >= threshold;
8483 + kdba_stackdepth1(p, esp);
8484 + } kdb_while_each_thread(g, p);
8489 +asmlinkage int kdb_call(void);
8491 +/* Executed once on each cpu at startup. */
8498 +kdba_arch_init(void)
8501 + set_intr_gate(KDB_VECTOR, kdb_interrupt);
8503 + set_intr_gate(KDBENTER_VECTOR, kdb_call);
8507 +arch_initcall(kdba_arch_init);
8512 + * Architecture specific initialization.
8527 + kdba_arch_init(); /* Need to register KDBENTER_VECTOR early */
8528 + kdb_register("pt_regs", kdba_pt_regs, "address", "Format struct pt_regs", 0);
8529 + kdb_register("stackdepth", kdba_stackdepth, "[percentage]", "Print processes using >= stack percentage", 0);
8537 + * Architecture specific adjustment of instruction pointer before leaving
8541 + * reason The reason KDB was invoked
8542 + * error The hardware-defined error code
8543 + * regs The exception frame at time of fault/breakpoint. If reason
8544 + * is SILENT or CPU_UP then regs is NULL, otherwise it should
8545 + * always be valid.
8555 +kdba_adjust_ip(kdb_reason_t reason, int error, struct pt_regs *regs)
8561 +kdba_set_current_task(const struct task_struct *p)
8563 + kdb_current_task = p;
8564 + if (kdb_task_has_cpu(p)) {
8565 + struct kdb_running_process *krp = kdb_running_process + kdb_process_cpu(p);
8566 + kdb_current_regs = krp->regs;
8569 + kdb_current_regs = NULL;
8573 + * asm-i386 uaccess.h supplies __copy_to_user which relies on MMU to
8574 + * trap invalid addresses in the _xxx fields. Verify the other address
8575 + * of the pair is valid by accessing the first and last byte ourselves,
8576 + * then any access violations should only be caused by the _xxx
8581 +kdba_putarea_size(unsigned long to_xxx, void *from, size_t size)
8583 + mm_segment_t oldfs = get_fs();
8586 + c = *((volatile char *)from);
8587 + c = *((volatile char *)from + size - 1);
8589 + if (to_xxx < PAGE_OFFSET) {
8590 + return kdb_putuserarea_size(to_xxx, from, size);
8593 + set_fs(KERNEL_DS);
8594 + r = __copy_to_user_inatomic((void __user *)to_xxx, from, size);
8600 +kdba_getarea_size(void *to, unsigned long from_xxx, size_t size)
8602 + mm_segment_t oldfs = get_fs();
8604 + *((volatile char *)to) = '\0';
8605 + *((volatile char *)to + size - 1) = '\0';
8607 + if (from_xxx < PAGE_OFFSET) {
8608 + return kdb_getuserarea_size(to, from_xxx, size);
8611 + set_fs(KERNEL_DS);
8614 + r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 1);
8617 + r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 2);
8620 + r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 4);
8623 + r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, 8);
8626 + r = __copy_to_user_inatomic((void __user *)to, (void *)from_xxx, size);
8634 +kdba_verify_rw(unsigned long addr, size_t size)
8636 + unsigned char data[size];
8637 + return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, data, size));
8642 +#include <mach_ipi.h>
8644 +/* When first entering KDB, try a normal IPI. That reduces backtrace problems
8645 + * on the other cpus.
8650 + if (!KDB_FLAG(NOIPI))
8651 + send_IPI_allbutself(KDB_VECTOR);
8654 +/* The normal KDB IPI handler */
8656 +smp_kdb_interrupt(struct pt_regs *regs)
8658 + struct pt_regs *old_regs = set_irq_regs(regs);
8661 + kdb_ipi(regs, NULL);
8663 + set_irq_regs(old_regs);
8666 +/* Invoked once from kdb_wait_for_cpus when waiting for cpus. For those cpus
8667 + * that have not responded to the normal KDB interrupt yet, hit them with an
8671 +kdba_wait_for_cpus(void)
8674 + if (KDB_FLAG(CATASTROPHIC))
8676 + kdb_printf(" Sending NMI to cpus that have not responded yet\n");
8677 + for_each_online_cpu(c)
8678 + if (kdb_running_process[c].seqno < kdb_seqno - 1)
8679 + send_IPI_mask(cpumask_of_cpu(c), NMI_VECTOR);
8682 +#endif /* CONFIG_SMP */
8683 diff -Nurp linux-2.6.22-590/arch/i386/kdb/kdb_cmds linux-2.6.22-600/arch/i386/kdb/kdb_cmds
8684 --- linux-2.6.22-590/arch/i386/kdb/kdb_cmds 1970-01-01 01:00:00.000000000 +0100
8685 +++ linux-2.6.22-600/arch/i386/kdb/kdb_cmds 2008-04-09 18:16:14.000000000 +0200
8687 +# Standard architecture specific commands for kdb.
8688 +# These commands are appended to those in kdb/kdb_cmds, see that file for
8691 +# Standard debugging information for first level support, invoked from archkdb*
8692 +# commands that are defined in kdb/kdb_cmds.
8694 +defcmd archkdbcommon "" "Common arch debugging"
8704 diff -Nurp linux-2.6.22-590/arch/i386/kdb/Makefile linux-2.6.22-600/arch/i386/kdb/Makefile
8705 --- linux-2.6.22-590/arch/i386/kdb/Makefile 1970-01-01 01:00:00.000000000 +0100
8706 +++ linux-2.6.22-600/arch/i386/kdb/Makefile 2008-04-09 18:16:14.000000000 +0200
8709 +# This file is subject to the terms and conditions of the GNU General Public
8710 +# License. See the file "COPYING" in the main directory of this archive
8711 +# for more details.
8713 +# Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
8716 +obj-$(CONFIG_KDB) := kdba_bp.o kdba_id.o kdba_io.o kdbasupport.o i386-dis.o
8718 +override CFLAGS := $(CFLAGS:%-pg=% )
8720 +CFLAGS_kdba_io.o += -I $(TOPDIR)/arch/$(ARCH)/kdb
8721 diff -Nurp linux-2.6.22-590/arch/i386/kdb/pc_keyb.h linux-2.6.22-600/arch/i386/kdb/pc_keyb.h
8722 --- linux-2.6.22-590/arch/i386/kdb/pc_keyb.h 1970-01-01 01:00:00.000000000 +0100
8723 +++ linux-2.6.22-600/arch/i386/kdb/pc_keyb.h 2008-04-09 18:16:14.000000000 +0200
8726 + * include/linux/pc_keyb.h
8728 + * PC Keyboard And Keyboard Controller
8730 + * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
8734 + * Configuration Switches
8737 +#undef KBD_REPORT_ERR /* Report keyboard errors */
8738 +#define KBD_REPORT_UNKN /* Report unknown scan codes */
8739 +#define KBD_REPORT_TIMEOUTS /* Report keyboard timeouts */
8740 +#undef KBD_IS_FOCUS_9000 /* We have the brain-damaged FOCUS-9000 keyboard */
8741 +#undef INITIALIZE_MOUSE /* Define if your PS/2 mouse needs initialization. */
8745 +#define KBD_INIT_TIMEOUT 1000 /* Timeout in ms for initializing the keyboard */
8746 +#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
8747 +#define KBD_TIMEOUT 1000 /* Timeout in ms for keyboard command acknowledge */
8750 + * Internal variables of the driver
8753 +extern unsigned char pckbd_read_mask;
8754 +extern unsigned char aux_device_present;
8757 + * Keyboard Controller Registers on normal PCs.
8760 +#define KBD_STATUS_REG 0x64 /* Status register (R) */
8761 +#define KBD_CNTL_REG 0x64 /* Controller command register (W) */
8762 +#define KBD_DATA_REG 0x60 /* Keyboard data register (R/W) */
8765 + * Keyboard Controller Commands
8768 +#define KBD_CCMD_READ_MODE 0x20 /* Read mode bits */
8769 +#define KBD_CCMD_WRITE_MODE 0x60 /* Write mode bits */
8770 +#define KBD_CCMD_GET_VERSION 0xA1 /* Get controller version */
8771 +#define KBD_CCMD_MOUSE_DISABLE 0xA7 /* Disable mouse interface */
8772 +#define KBD_CCMD_MOUSE_ENABLE 0xA8 /* Enable mouse interface */
8773 +#define KBD_CCMD_TEST_MOUSE 0xA9 /* Mouse interface test */
8774 +#define KBD_CCMD_SELF_TEST 0xAA /* Controller self test */
8775 +#define KBD_CCMD_KBD_TEST 0xAB /* Keyboard interface test */
8776 +#define KBD_CCMD_KBD_DISABLE 0xAD /* Keyboard interface disable */
8777 +#define KBD_CCMD_KBD_ENABLE 0xAE /* Keyboard interface enable */
8778 +#define KBD_CCMD_WRITE_AUX_OBUF 0xD3 /* Write to output buffer as if
8779 + initiated by the auxiliary device */
8780 +#define KBD_CCMD_WRITE_MOUSE 0xD4 /* Write the following byte to the mouse */
8783 + * Keyboard Commands
8786 +#define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */
8787 +#define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */
8788 +#define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
8789 +#define KBD_CMD_DISABLE 0xF5 /* Disable scanning */
8790 +#define KBD_CMD_RESET 0xFF /* Reset */
8793 + * Keyboard Replies
8796 +#define KBD_REPLY_POR 0xAA /* Power on reset */
8797 +#define KBD_REPLY_ACK 0xFA /* Command ACK */
8798 +#define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */
8801 + * Status Register Bits
8804 +#define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */
8805 +#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
8806 +#define KBD_STAT_SELFTEST 0x04 /* Self test successful */
8807 +#define KBD_STAT_CMD 0x08 /* Last write was a command write (0=data) */
8808 +#define KBD_STAT_UNLOCKED 0x10 /* Zero if keyboard locked */
8809 +#define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */
8810 +#define KBD_STAT_GTO 0x40 /* General receive/xmit timeout */
8811 +#define KBD_STAT_PERR 0x80 /* Parity error */
8813 +#define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
8816 + * Controller Mode Register Bits
8819 +#define KBD_MODE_KBD_INT 0x01 /* Keyboard data generate IRQ1 */
8820 +#define KBD_MODE_MOUSE_INT 0x02 /* Mouse data generate IRQ12 */
8821 +#define KBD_MODE_SYS 0x04 /* The system flag (?) */
8822 +#define KBD_MODE_NO_KEYLOCK 0x08 /* The keylock doesn't affect the keyboard if set */
8823 +#define KBD_MODE_DISABLE_KBD 0x10 /* Disable keyboard interface */
8824 +#define KBD_MODE_DISABLE_MOUSE 0x20 /* Disable mouse interface */
8825 +#define KBD_MODE_KCC 0x40 /* Scan code conversion to PC format */
8826 +#define KBD_MODE_RFU 0x80
8832 +#define AUX_SET_RES 0xE8 /* Set resolution */
8833 +#define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */
8834 +#define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */
8835 +#define AUX_GET_SCALE 0xE9 /* Get scaling factor */
8836 +#define AUX_SET_STREAM 0xEA /* Set stream mode */
8837 +#define AUX_SET_SAMPLE 0xF3 /* Set sample rate */
8838 +#define AUX_ENABLE_DEV 0xF4 /* Enable aux device */
8839 +#define AUX_DISABLE_DEV 0xF5 /* Disable aux device */
8840 +#define AUX_RESET 0xFF /* Reset aux device */
8841 +#define AUX_ACK 0xFA /* Command byte ACK. */
8843 +#define AUX_BUF_SIZE 2048 /* This might be better divisible by
8844 + three to make overruns stay in sync
8845 + but then the read function would need
8846 + a lock etc - ick */
8849 + unsigned long head;
8850 + unsigned long tail;
8851 + wait_queue_head_t proc_list;
8852 + struct fasync_struct *fasync;
8853 + unsigned char buf[AUX_BUF_SIZE];
8857 +/* How to access the keyboard macros on this platform. */
8858 +#define kbd_read_input() inb(KBD_DATA_REG)
8859 +#define kbd_read_status() inb(KBD_STATUS_REG)
8860 +#define kbd_write_output(val) outb(val, KBD_DATA_REG)
8861 +#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
8862 diff -Nurp linux-2.6.22-590/arch/i386/kernel/entry.S linux-2.6.22-600/arch/i386/kernel/entry.S
8863 --- linux-2.6.22-590/arch/i386/kernel/entry.S 2008-04-09 18:10:46.000000000 +0200
8864 +++ linux-2.6.22-600/arch/i386/kernel/entry.S 2008-04-09 18:16:14.000000000 +0200
8865 @@ -976,6 +976,26 @@ ENTRY(alignment_check)
8867 END(alignment_check)
8873 + pushl %eax # save orig EAX
8874 + CFI_ADJUST_CFA_OFFSET 4
8876 + movl %esp,%ecx # struct pt_regs
8877 + movl $0,%edx # error_code
8878 + movl $1,%eax # KDB_REASON_ENTER
8884 +BUILD_INTERRUPT(kdb_interrupt,KDB_VECTOR)
8885 +#endif /* CONFIG_SMP */
8887 +#endif /* CONFIG_KDB */
8891 pushl $0 # no error code
8892 diff -Nurp linux-2.6.22-590/arch/i386/kernel/io_apic.c linux-2.6.22-600/arch/i386/kernel/io_apic.c
8893 --- linux-2.6.22-590/arch/i386/kernel/io_apic.c 2008-04-09 18:10:46.000000000 +0200
8894 +++ linux-2.6.22-600/arch/i386/kernel/io_apic.c 2008-04-09 18:16:14.000000000 +0200
8896 #include <linux/sysdev.h>
8897 #include <linux/pci.h>
8898 #include <linux/msi.h>
8901 +#include <linux/kdb.h>
8902 +#endif /* CONFIG_KDB */
8903 #include <linux/htirq.h>
8904 #include <linux/freezer.h>
8905 #include <linux/kthread.h>
8906 @@ -1244,6 +1248,10 @@ next:
8908 if (vector == SYSCALL_VECTOR)
8911 + if (vector == KDBENTER_VECTOR)
8913 +#endif /* CONFIG_KDB */
8914 for (i = 0; i < NR_IRQ_VECTORS; i++)
8915 if (irq_vector[i] == vector)
8917 diff -Nurp linux-2.6.22-590/arch/i386/kernel/reboot.c linux-2.6.22-600/arch/i386/kernel/reboot.c
8918 --- linux-2.6.22-590/arch/i386/kernel/reboot.c 2007-07-09 01:32:17.000000000 +0200
8919 +++ linux-2.6.22-600/arch/i386/kernel/reboot.c 2008-04-09 18:16:14.000000000 +0200
8923 #include <linux/mm.h>
8925 +#include <linux/kdb.h>
8926 +#endif /* CONFIG_KDB */
8927 #include <linux/module.h>
8928 #include <linux/delay.h>
8929 #include <linux/init.h>
8930 @@ -313,6 +316,14 @@ static void native_machine_shutdown(void
8931 * all of the others, and disable their local APICs.
8936 + * If this restart is occuring while kdb is running (e.g. reboot
8937 + * command), the other CPU's are already stopped. Don't try to
8938 + * stop them yet again.
8940 + if (!KDB_IS_RUNNING())
8941 +#endif /* CONFIG_KDB */
8943 #endif /* CONFIG_SMP */
8945 diff -Nurp linux-2.6.22-590/arch/i386/kernel/traps.c linux-2.6.22-600/arch/i386/kernel/traps.c
8946 --- linux-2.6.22-590/arch/i386/kernel/traps.c 2008-04-09 18:10:52.000000000 +0200
8947 +++ linux-2.6.22-600/arch/i386/kernel/traps.c 2008-04-09 18:16:14.000000000 +0200
8949 #include <linux/mca.h>
8953 +#include <linux/kdb.h>
8954 +#endif /* CONFIG_KDB */
8956 #include <asm/processor.h>
8957 #include <asm/system.h>
8959 @@ -438,6 +442,10 @@ void die(const char * str, struct pt_reg
8961 die.lock_owner = -1;
8962 spin_unlock_irqrestore(&die.lock, flags);
8965 + kdb(KDB_REASON_OOPS, err, regs);
8966 +#endif /* CONFIG_KDB */
8970 @@ -561,7 +569,7 @@ fastcall void do_##name(struct pt_regs *
8973 DO_VM86_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->eip)
8974 -#ifndef CONFIG_KPROBES
8975 +#if !defined(CONFIG_KPROBES) && !defined(CONFIG_KDB)
8976 DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
8978 DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
8979 @@ -670,6 +678,9 @@ io_check_error(unsigned char reason, str
8980 static __kprobes void
8981 unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
8984 + (void)kdb(KDB_REASON_NMI, reason, regs);
8985 +#endif /* CONFIG_KDB */
8987 /* Might actually be able to figure out what the guilty party
8989 @@ -705,6 +716,9 @@ void __kprobes die_nmi(struct pt_regs *r
8990 printk(" on CPU%d, eip %08lx, registers:\n",
8991 smp_processor_id(), regs->eip);
8992 show_registers(regs);
8994 + kdb(KDB_REASON_NMI, 0, regs);
8995 +#endif /* CONFIG_KDB */
8997 spin_unlock(&nmi_print_lock);
8999 @@ -727,7 +741,17 @@ static __kprobes void default_do_nmi(str
9000 /* Only the BSP gets external NMIs from the system. */
9001 if (!smp_processor_id())
9002 reason = get_nmi_reason();
9005 +#if defined(CONFIG_SMP) && defined(CONFIG_KDB)
9007 + * Call the kernel debugger to see if this NMI is due
9008 + * to an KDB requested IPI. If so, kdb will handle it.
9010 + if (kdb_ipi(regs, NULL)) {
9013 +#endif /* defined(CONFIG_SMP) && defined(CONFIG_KDB) */
9015 if (!(reason & 0xc0)) {
9016 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
9018 @@ -776,6 +800,10 @@ fastcall __kprobes void do_nmi(struct pt
9019 #ifdef CONFIG_KPROBES
9020 fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
9023 + if (kdb(KDB_REASON_BREAK, error_code, regs))
9026 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
9029 @@ -815,6 +843,11 @@ fastcall void __kprobes do_debug(struct
9031 get_debugreg(condition, 6);
9034 + if (kdb(KDB_REASON_DEBUG, error_code, regs))
9036 +#endif /* CONFIG_KDB */
9038 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
9039 SIGTRAP) == NOTIFY_STOP)
9041 @@ -868,6 +901,16 @@ clear_TF_reenable:
9045 +#if defined(CONFIG_KDB) && !defined(CONFIG_KPROBES)
9046 +fastcall void do_int3(struct pt_regs * regs, long error_code)
9048 + if (kdb(KDB_REASON_BREAK, error_code, regs))
9050 + do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
9052 +#endif /* CONFIG_KDB && !CONFIG_KPROBES */
9056 * Note that we play around with the 'TS' bit in an attempt to get
9057 * the correct behaviour even in the presence of the asynchronous
9058 diff -Nurp linux-2.6.22-590/arch/i386/Makefile linux-2.6.22-600/arch/i386/Makefile
9059 --- linux-2.6.22-590/arch/i386/Makefile 2008-04-09 18:10:46.000000000 +0200
9060 +++ linux-2.6.22-600/arch/i386/Makefile 2008-04-09 18:16:14.000000000 +0200
9061 @@ -108,6 +108,7 @@ drivers-$(CONFIG_PCI) += arch/i386/pci
9062 # must be linked after kernel/
9063 drivers-$(CONFIG_OPROFILE) += arch/i386/oprofile/
9064 drivers-$(CONFIG_PM) += arch/i386/power/
9065 +drivers-$(CONFIG_KDB) += arch/i386/kdb/
9067 CFLAGS += $(mflags-y)
9068 AFLAGS += $(mflags-y)
9069 diff -Nurp linux-2.6.22-590/arch/x86_64/Kconfig.debug linux-2.6.22-600/arch/x86_64/Kconfig.debug
9070 --- linux-2.6.22-590/arch/x86_64/Kconfig.debug 2007-07-09 01:32:17.000000000 +0200
9071 +++ linux-2.6.22-600/arch/x86_64/Kconfig.debug 2008-04-09 18:16:24.000000000 +0200
9072 @@ -16,6 +16,76 @@ config DEBUG_RODATA
9073 of the kernel code won't be covered by a 2MB TLB anymore.
9074 If in doubt, say "N".
9077 + bool "Built-in Kernel Debugger support"
9078 + depends on DEBUG_KERNEL
9080 + select KALLSYMS_ALL
9082 + This option provides a built-in kernel debugger. The built-in
9083 + kernel debugger contains commands which allow memory to be examined,
9084 + instructions to be disassembled and breakpoints to be set. For details,
9085 + see Documentation/kdb/kdb.mm and the manual pages kdb_bt, kdb_ss, etc.
9086 + Kdb can also be used via the serial port. Set up the system to
9087 + have a serial console (see Documentation/serial-console.txt).
9088 + The key sequence <escape>KDB on the serial port will cause the
9089 + kernel debugger to be entered with input from the serial port and
9090 + output to the serial console. If unsure, say N.
9093 + tristate "KDB modules"
9096 + KDB can be extended by adding your own modules, in directory
9097 + kdb/modules. This option selects the way that these modules should
9098 + be compiled, as free standing modules (select M) or built into the
9099 + kernel (select Y). If unsure say M.
9102 + bool "KDB off by default"
9105 + Normally kdb is activated by default, as long as CONFIG_KDB is set.
9106 + If you want to ship a kernel with kdb support but only have kdb
9107 + turned on when the user requests it then select this option. When
9108 + compiled with CONFIG_KDB_OFF, kdb ignores all events unless you boot
9109 + with kdb=on or you echo "1" > /proc/sys/kernel/kdb. This option also
9110 + works in reverse, if kdb is normally activated, you can boot with
9111 + kdb=off or echo "0" > /proc/sys/kernel/kdb to deactivate kdb. If
9114 +config KDB_CONTINUE_CATASTROPHIC
9115 + int "KDB continues after catastrophic errors"
9119 + This integer controls the behaviour of kdb when the kernel gets a
9120 + catastrophic error, i.e. for a panic, oops, NMI or other watchdog
9121 + tripping. CONFIG_KDB_CONTINUE_CATASTROPHIC interacts with
9122 + /proc/sys/kernel/kdb and CONFIG_DUMP (if your kernel has the LKCD
9124 + When KDB is active (/proc/sys/kernel/kdb == 1) and a catastrophic
9125 + error occurs, nothing extra happens until you type 'go'.
9126 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 0 (default). The first time
9127 + you type 'go', kdb warns you. The second time you type 'go', KDB
9128 + tries to continue - no guarantees that the kernel is still usable.
9129 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 1. KDB tries to continue - no
9130 + guarantees that the kernel is still usable.
9131 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 2. If your kernel has the LKCD
9132 + patch and LKCD is configured to take a dump then KDB forces a dump.
9133 + Whether or not a dump is taken, KDB forces a reboot.
9134 + When KDB is not active (/proc/sys/kernel/kdb == 0) and a catastrophic
9135 + error occurs, the following steps are automatic, no human
9136 + intervention is required.
9137 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 0 (default) or 1. KDB attempts
9138 + to continue - no guarantees that the kernel is still usable.
9139 + CONFIG_KDB_CONTINUE_CATASTROPHIC == 2. If your kernel has the LKCD
9140 + patch and LKCD is configured to take a dump then KDB automatically
9141 + forces a dump. Whether or not a dump is taken, KDB forces a
9143 + If you are not sure, say 0. Read Documentation/kdb/dump.txt before
9147 depends on IOMMU && DEBUG_KERNEL
9148 bool "Enable IOMMU debugging"
9149 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/ChangeLog linux-2.6.22-600/arch/x86_64/kdb/ChangeLog
9150 --- linux-2.6.22-590/arch/x86_64/kdb/ChangeLog 1970-01-01 01:00:00.000000000 +0100
9151 +++ linux-2.6.22-600/arch/x86_64/kdb/ChangeLog 2008-04-09 18:16:24.000000000 +0200
9153 +2007-07-26 Keith Owens <kaos@sgi.com>
9155 + * New x86 backtrace code.
9156 + * kdb v4.4-2.6.22-x86_64-2.
9158 +2007-07-09 Keith Owens <kaos@sgi.com>
9160 + * kdb v4.4-2.6.22-x86_64-1.
9162 +2007-07-02 Keith Owens <kaos@sgi.com>
9164 + * kdb v4.4-2.6.22-rc7-x86_64-1.
9166 +2007-06-25 Keith Owens <kaos@sgi.com>
9168 + * Hook into DIE_NMIWATCHDOG.
9169 + * kdb v4.4-2.6.22-rc5-x86_64-2.
9171 +2007-06-20 Keith Owens <kaos@sgi.com>
9173 + * kdb v4.4-2.6.22-rc5-x86_64-1.
9175 +2007-06-08 Keith Owens <kaos@sgi.com>
9177 + * kdb v4.4-2.6.22-rc4-x86_64-1.
9179 +2007-05-28 Keith Owens <kaos@sgi.com>
9181 + * kdb v4.4-2.6.22-rc3-x86_64-1.
9183 +2007-05-22 Keith Owens <kaos@sgi.com>
9185 + * Register KDBENTER_VECTOR early on the boot cpu.
9186 + * kdb v4.4-2.6.22-rc2-x86_64-2.
9188 +2007-05-22 Keith Owens <kaos@sgi.com>
9190 + * kdb v4.4-2.6.22-rc2-x86_64-1.
9192 +2007-05-22 Keith Owens <kaos@sgi.com>
9194 + * kdb v4.4-2.6.22-rc1-x86_64-1.
9196 +2007-05-17 Keith Owens <kaos@sgi.com>
9198 + * Update dumpregs comments for rdmsr and wrmsr commands.
9199 + Bernardo Innocenti.
9200 + * kdb v4.4-2.6.21-x86_64-3.
9202 +2007-05-15 Keith Owens <kaos@sgi.com>
9204 + * Change kdba_late_init to kdba_arch_init so KDB_ENTER() can be used
9206 + * kdb v4.4-2.6.21-x86_64-2.
9208 +2007-04-29 Keith Owens <kaos@sgi.com>
9210 + * kdb v4.4-2.6.21-x86_64-1.
9212 +2007-04-16 Keith Owens <kaos@sgi.com>
9214 + * Select KALLSYMS and KALLSYMS_ALL when KDB is selected.
9215 + * kdb v4.4-2.6.21-rc7-x86_64-2.
9217 +2007-04-16 Keith Owens <kaos@sgi.com>
9219 + * kdb v4.4-2.6.21-rc7-x86_64-1.
9221 +2007-04-10 Keith Owens <kaos@sgi.com>
9223 + * kdb v4.4-2.6.21-rc6-x86_64-1.
9225 +2007-04-02 Keith Owens <kaos@sgi.com>
9227 + * kdb v4.4-2.6.21-rc5-x86_64-1.
9229 +2007-03-19 Keith Owens <kaos@sgi.com>
9231 + * kdb v4.4-2.6.21-rc4-x86_64-1.
9233 +2007-03-14 Keith Owens <kaos@sgi.com>
9235 + * kdb v4.4-2.6.21-rc3-x86_64-1.
9237 +2007-03-14 Keith Owens <kaos@sgi.com>
9239 + * kdb v4.4-2.6.21-rc2-x86_64-1.
9241 +2007-03-01 Keith Owens <kaos@sgi.com>
9243 + * kdb v4.4-2.6.21-rc1-x86_64-1.
9245 +2007-03-01 Keith Owens <kaos@sgi.com>
9247 + * Remove sparse warnings.
9248 + * kdb v4.4-2.6.20-x86_64-3.
9250 +2007-02-16 Keith Owens <kaos@sgi.com>
9252 + * Initialise variable bits of struct disassemble_info each time.
9253 + * kdb v4.4-2.6.20-x86_64-2.
9255 +2007-02-06 Keith Owens <kaos@sgi.com>
9257 + * kdb v4.4-2.6.20-x86_64-1.
9259 +2007-02-01 Keith Owens <kaos@sgi.com>
9261 + * kdb v4.4-2.6.20-rc7-x86_64-1.
9263 +2007-01-10 Keith Owens <kaos@sgi.com>
9265 + * Correct setjmp for the FRAME_POINTER=y case.
9266 + * Remove duplicate longjmp code for FRAME_POINTER=n/y.
9267 + * kdb v4.4-2.6.20-rc4-x86_64-2.
9269 +2007-01-08 Keith Owens <kaos@sgi.com>
9271 + * kdb v4.4-2.6.20-rc4-x86_64-1.
9273 +2007-01-02 Keith Owens <kaos@sgi.com>
9275 + * kdb v4.4-2.6.20-rc3-x86_64-1.
9277 +2006-12-20 Keith Owens <kaos@sgi.com>
9279 + * kdb v4.4-2.6.20-rc1-x86_64-1.
9281 +2006-12-07 Keith Owens <kaos@sgi.com>
9283 + * Export kdba_dumpregs.
9284 + * kdb v4.4-2.6.19-x86_64-2.
9286 +2006-11-30 Keith Owens <kaos@sgi.com>
9288 + * kdb v4.4-2.6.19-x86_64-1.
9290 +2006-11-27 Keith Owens <kaos@sgi.com>
9292 + * Only use VT keyboard if the command line allows it and ACPI indicates
9293 + that there is an i8042.
9294 + * kdb v4.4-2.6.19-rc6-x86_64-2.
9296 +2006-11-20 Keith Owens <kaos@sgi.com>
9298 + * kdb v4.4-2.6.19-rc6-x86_64-1.
9300 +2006-11-09 Keith Owens <kaos@sgi.com>
9302 + * Only use VT console if the command line allows it.
9303 + * kdb v4.4-2.6.19-rc5-x86_64-2.
9305 +2006-11-08 Keith Owens <kaos@sgi.com>
9307 + * kdb v4.4-2.6.19-rc5-x86_64-1.
9309 +2006-11-01 Keith Owens <kaos@sgi.com>
9311 + * kdb v4.4-2.6.19-rc4-x86_64-1.
9313 +2006-10-24 Keith Owens <kaos@sgi.com>
9315 + * kdb v4.4-2.6.19-rc3-x86_64-1.
9317 +2006-10-24 Keith Owens <kaos@sgi.com>
9319 + * Remove redundant regs and envp parameters.
9320 + * kdb v4.4-2.6.19-rc2-x86_64-2.
9322 +2006-10-18 Keith Owens <kaos@sgi.com>
9324 + * kdb v4.4-2.6.19-rc2-x86_64-1.
9326 +2006-10-11 Keith Owens <kaos@sgi.com>
9328 + * Make the KDBENTER_VECTOR an interrupt gate instead of a trap gate, it
9329 + simplifies the code and disables interrupts on KDB_ENTER().
9330 + * Exclude the KDBENTER_VECTOR from irq assignment.
9331 + * Enable KDB_ENTER() again.
9332 + * kdb v4.4-2.6.19-rc1-x86_64-2.
9334 +2006-10-09 Keith Owens <kaos@sgi.com>
9336 + * KDB_ENTER() is getting spurious activations on some x86_64 hardware.
9337 + Deactivate KDB_ENTER() until it is fixed.
9338 + * kdb v4.4-2.6.19-rc1-x86_64-1.
9340 +2006-10-06 Keith Owens <kaos@sgi.com>
9342 + * Remove #include <linux/config.h>
9343 + * kdb v4.4-2.6.18-x86_64-2.
9345 +2006-09-20 Keith Owens <kaos@sgi.com>
9347 + * kdb v4.4-2.6.18-x86_64-1.
9349 +2006-09-15 Keith Owens <kaos@sgi.com>
9351 + * kdb v4.4-2.6.18-rc7-x86_64-1.
9353 +2006-08-30 Keith Owens <kaos@sgi.com>
9355 + * Do not print debugstackptr in cpu_pda, it will be deleted soon.
9356 + * Add KDB_ENTER().
9357 + * Add warning for problems when following alternate stacks.
9358 + * kdb v4.4-2.6.18-rc5-x86_64-3.
9360 +2006-08-29 Keith Owens <kaos@sgi.com>
9362 + * Rewrite all backtrace code.
9363 + * Add pt_regs and cpu_pda commands.
9364 + * Include patch to define orig_ist, to be removed once that patch is in
9365 + the community tree.
9366 + * kdb v4.4-2.6.18-rc5-x86_64-2.
9368 +2006-08-28 Keith Owens <kaos@sgi.com>
9370 + * kdb v4.4-2.6.18-rc5-x86_64-1.
9372 +2006-08-08 Keith Owens <kaos@sgi.com>
9374 + * kdb v4.4-2.6.18-rc4-x86_64-1.
9376 +2006-08-04 Keith Owens <kaos@sgi.com>
9378 + * kdb v4.4-2.6.18-rc3-x86_64-1.
9380 +2006-07-18 Keith Owens <kaos@sgi.com>
9382 + * kdb v4.4-2.6.18-rc2-x86_64-1.
9384 +2006-07-12 Keith Owens <kaos@sgi.com>
9387 + * kdb v4.4-2.6.18-rc1-x86_64-2.
9389 +2006-07-07 Keith Owens <kaos@sgi.com>
9391 + * kdb v4.4-2.6.18-rc1-x86_64-1.
9393 +2006-07-04 Keith Owens <kaos@sgi.com>
9395 + * Make KDB rendezvous on x86_64 a two stage approach.
9396 + * Move smp_kdb_stop() and smp_kdb_interrupt() to kdbasupport.c.
9397 + * Move setting of interrupt traps to kdbasupport.c.
9398 + * Add KDB_REASON_CPU_UP support.
9399 + * Move per cpu setup to kdba_cpu_up().
9400 + * Delete kdba_enable_mce, architectures now do their own setup.
9401 + * Delete kdba_enable_lbr, kdba_disable_lbr, kdba_print_lbr,
9402 + page_fault_mca. Only ever implemented on x86, difficult to maintain
9403 + and rarely used in the field.
9404 + * Replace #ifdef KDB_HAVE_LONGJMP with #ifdef kdba_setjmp.
9405 + * kdb v4.4-2.6.17-x86_64-2.
9407 +2006-06-19 Keith Owens <kaos@sgi.com>
9409 + * kdb v4.4-2.6.17-x86_64-1.
9411 +2006-05-31 Keith Owens <kaos@sgi.com>
9413 + * Define arch/x86_64/kdb/kdb_cmds.
9414 + * kdb v4.4-2.6.17-rc5-x86_64-2.
9416 +2006-05-25 Keith Owens <kaos@sgi.com>
9418 + * kdb v4.4-2.6.17-rc5-x86_64-1.
9420 +2006-05-15 Keith Owens <kaos@sgi.com>
9422 + * Refresh bfd related files from binutils 2.16.91.0.2.
9423 + * kdb v4.4-2.6.17-rc4-x86_64-2.
9425 +2006-05-12 Keith Owens <kaos@sgi.com>
9427 + * kdb v4.4-2.6-17-rc4-x86_64-1.
9429 +2006-04-22 Keith Owens <kaos@sgi.com>
9431 + * kdb v4.4-2.6-17-rc2-x86_64-1.
9433 +2006-04-13 Keith Owens <kaos@sgi.com>
9435 + * Remove trailing white space.
9436 + * kdb v4.4-2.6-17-rc1-x86_64-1.
9438 +2006-03-25 Jack F. Vogel <jfv@bluesong.net>
9439 + * Sync with Keith's changes for 2.6.16
9440 + * code from Andi Kleen to support above
9442 +2005-09-30 Jack F. Vogel <jfv@bluesong.net>
9443 + * Port to 2.6.14-rc2
9444 + * sync with a couple changes from Keith
9445 + * Add backtrace code from Jim Houston
9448 +2005-08-31 Jack F. Vogel <jfv@bluesong.net>
9449 + * Change to linker script for kexec
9450 + thanks to Steven Dake <sdake@mvista.com>
9452 +2005-08-30 Jack F. Vogel <jfv@bluesong.net>
9453 + * Notify struct should not be devinit
9454 + thanks IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
9456 +2005-08-25 Jack F. Vogel <jfv@bluesong.net>
9457 + * Update to 2.6.11
9458 + * Fix to synchronize with the notify changes
9459 + thanks to Jim Houston.
9461 +2004-09-30 Keith Owens <kaos@sgi.com>
9462 + * Port to 2.6.9-rc2
9463 + * Fix line editting characters. Jim Houston, Comcast.
9464 + * kdb v4.4-2.6.9-rc2-x86-64-1.
9466 +2004-08-15 Jack F. Vogel <jfv@bluesong.net>
9468 + * tighten up the code, using the built-in
9469 + die_chain notify interface, thanks to
9470 + Andi Kleen for pointing this out.
9472 +2004-05-15 Jack F. Vogel <jfv@bluesong.net>
9473 + * port to 2.6.6 for x86_64
9475 +2003-12-15 Cliff Neighbors <cliff@fabric7.com>
9476 + * initial port from i386 to x86_64
9478 +2002-08-10 Keith Owens <kaos@sgi.com>
9480 + * Replace kdb_port with kdb_serial to support memory mapped I/O.
9481 + Note: This needs kdb v2.3-2.4.19-common-2 or later.
9482 + * kdb v2.3-2.4.19-i386-3.
9484 +2002-08-09 Keith Owens <kaos@sgi.com>
9486 + * Use -fno-optimize-sibling-calls for kdb if gcc supports it.
9487 + * .text.lock does not consume an activation frame.
9488 + * kdb v2.3-2.4.19-i386-2.
9490 +2002-08-07 Keith Owens <kaos@sgi.com>
9492 + * Upgrade to 2.4.19.
9493 + * Remove individual SGI copyrights, the general SGI copyright applies.
9494 + * New .text.lock name. Hugh Dickins.
9495 + * Set KERNEL_CS in kdba_getcurrentframe. Hugh Dickins.
9496 + * Clean up disassembly layout. Hugh Dickins, Keith Owens.
9497 + * Replace hard coded stack size with THREAD_SIZE. Hugh Dickins.
9498 + * Better stack layout on bt with no frame pointers. Hugh Dickins.
9499 + * Make i386 IO breakpoints (bpha <address> IO) work again.
9500 + Martin Wilck, Keith Owens.
9501 + * Remove fixed KDB_MAX_COMMANDS size.
9502 + * Add set_fs() around __copy_to_user on kernel addresses.
9504 + * Position i386 for CONFIG_NUMA_REPLICATE.
9505 + * kdb v2.3-2.4.19-i386-1.
9507 +2002-07-09 Keith Owens <kaos@sgi.com>
9509 + * Upgrade to 2.4.19-rc1.
9511 +2002-06-14 Keith Owens <kaos@sgi.com>
9513 + * Upgrade to 2.4.19-pre10.
9514 + * kdb v2.1-2.4.19-pre10-i386-1.
9516 +2002-04-09 Keith Owens <kaos@sgi.com>
9518 + * Upgrade to 2.4.19-pre6.
9519 + * kdb v2.1-2.4.19-pre6-i386-1.
9521 +2002-02-26 Keith Owens <kaos@sgi.com>
9523 + * Upgrade to 2.4.18.
9524 + * kdb v2.1-2.4.18-i386-1.
9526 +2002-01-18 Keith Owens <kaos@sgi.com>
9528 + * Use new kdb_get/put functions.
9529 + * Define kdba_{get,put}area_size functions for i386.
9530 + * Remove over-engineered dblist callback functions.
9531 + * Correctly handle failing call disp32 in backtrace.
9532 + * Remove bp_instvalid flag, redundant code.
9533 + * Remove dead code.
9534 + * kdb v2.1-2.4.17-i386-1.
9536 +2002-01-04 Keith Owens <kaos@sgi.com>
9538 + * Sync xfs <-> kdb i386 code.
9540 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/kdba_bp.c linux-2.6.22-600/arch/x86_64/kdb/kdba_bp.c
9541 --- linux-2.6.22-590/arch/x86_64/kdb/kdba_bp.c 1970-01-01 01:00:00.000000000 +0100
9542 +++ linux-2.6.22-600/arch/x86_64/kdb/kdba_bp.c 2008-04-09 18:16:24.000000000 +0200
9545 + * Kernel Debugger Architecture Dependent Breakpoint Handling
9547 + * This file is subject to the terms and conditions of the GNU General Public
9548 + * License. See the file "COPYING" in the main directory of this archive
9549 + * for more details.
9551 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
9554 +#include <linux/string.h>
9555 +#include <linux/kernel.h>
9556 +#include <linux/sched.h>
9557 +#include <linux/smp.h>
9558 +#include <linux/ptrace.h>
9559 +#include <linux/kdb.h>
9560 +#include <linux/kdbprivate.h>
9563 +static char *kdba_rwtypes[] = { "Instruction(Register)", "Data Write",
9564 + "I/O", "Data Access"};
9567 + * Table describing processor architecture hardware
9568 + * breakpoint registers.
9571 +kdbhard_bp_t kdb_hardbreaks[KDB_MAXHARDBPT];
9576 + * Perform breakpoint processing upon entry to the
9577 + * processor debugger fault. Determine and print
9578 + * the active breakpoint.
9581 + * regs Exception frame containing machine register state
9582 + * error Error number passed to kdb.
9586 + * KDB_DB_BPT Standard instruction or data breakpoint encountered
9587 + * KDB_DB_SS Single Step fault ('ss' command or end of 'ssb' command)
9588 + * KDB_DB_SSB Single Step fault, caller should continue ('ssb' command)
9589 + * KDB_DB_SSBPT Single step over breakpoint
9590 + * KDB_DB_NOBPT No existing kdb breakpoint matches this debug exception
9594 + * Yup, there be goto's here.
9596 + * If multiple processors receive debug exceptions simultaneously,
9597 + * one may be waiting at the kdb fence in kdb() while the user
9598 + * issues a 'bc' command to clear the breakpoint the processor
9599 + * which is waiting has already encountered. If this is the case,
9600 + * the debug registers will no longer match any entry in the
9601 + * breakpoint table, and we'll return the value KDB_DB_NOBPT.
9602 + * This can cause a panic in die_if_kernel(). It is safer to
9603 + * disable the breakpoint (bd), go until all processors are past
9604 + * the breakpoint then clear the breakpoint (bc). This code
9605 + * recognises a breakpoint even when disabled but not when it has
9608 + * WARNING: This routine clears the debug state. It should be called
9609 + * once per debug and the result cached.
9613 +kdba_db_trap(struct pt_regs *regs, int error_unused)
9615 + kdb_machreg_t dr6;
9616 + kdb_machreg_t dr7;
9619 + kdb_dbtrap_t rv = KDB_DB_BPT;
9622 + if (KDB_NULL_REGS(regs))
9623 + return KDB_DB_NOBPT;
9625 + dr6 = kdba_getdr6();
9626 + dr7 = kdba_getdr7();
9628 + if (KDB_DEBUG(BP))
9629 + kdb_printf("kdb: dr6 0x%lx dr7 0x%lx\n", dr6, dr7);
9630 + if (dr6 & DR6_BS) {
9631 + if (KDB_STATE(SSBPT)) {
9632 + if (KDB_DEBUG(BP))
9633 + kdb_printf("ssbpt\n");
9634 + KDB_STATE_CLEAR(SSBPT);
9635 + for(i=0,bp=kdb_breakpoints;
9638 + if (KDB_DEBUG(BP))
9639 + kdb_printf("bp 0x%p enabled %d delayed %d global %d cpu %d\n",
9640 + bp, bp->bp_enabled, bp->bp_delayed, bp->bp_global, bp->bp_cpu);
9641 + if (!bp->bp_enabled)
9643 + if (!bp->bp_global && bp->bp_cpu != smp_processor_id())
9645 + if (KDB_DEBUG(BP))
9646 + kdb_printf("bp for this cpu\n");
9647 + if (bp->bp_delayed) {
9648 + bp->bp_delayed = 0;
9649 + if (KDB_DEBUG(BP))
9650 + kdb_printf("kdba_installbp\n");
9651 + kdba_installbp(regs, bp);
9652 + if (!KDB_STATE(DOING_SS)) {
9653 + regs->eflags &= ~EF_TF;
9654 + return(KDB_DB_SSBPT);
9659 + if (i == KDB_MAXBPT) {
9660 + kdb_printf("kdb: Unable to find delayed breakpoint\n");
9662 + if (!KDB_STATE(DOING_SS)) {
9663 + regs->eflags &= ~EF_TF;
9664 + return(KDB_DB_NOBPT);
9670 + * KDB_STATE_DOING_SS is set when the kernel debugger is using
9671 + * the processor trap flag to single-step a processor. If a
9672 + * single step trap occurs and this flag is clear, the SS trap
9673 + * will be ignored by KDB and the kernel will be allowed to deal
9674 + * with it as necessary (e.g. for ptrace).
9676 + if (!KDB_STATE(DOING_SS))
9680 + rv = KDB_DB_SS; /* Indicate single step */
9681 + if (KDB_STATE(DOING_SSB)) {
9682 + unsigned char instruction[2];
9684 + kdb_id1(regs->rip);
9685 + if (kdb_getarea(instruction, regs->rip) ||
9686 + (instruction[0]&0xf0) == 0xe0 || /* short disp jumps */
9687 + (instruction[0]&0xf0) == 0x70 || /* Misc. jumps */
9688 + instruction[0] == 0xc2 || /* ret */
9689 + instruction[0] == 0x9a || /* call */
9690 + (instruction[0]&0xf8) == 0xc8 || /* enter, leave, iret, int, */
9691 + ((instruction[0] == 0x0f) &&
9692 + ((instruction[1]&0xf0)== 0x80))
9695 + * End the ssb command here.
9697 + KDB_STATE_CLEAR(DOING_SSB);
9698 + KDB_STATE_CLEAR(DOING_SS);
9700 + rv = KDB_DB_SSB; /* Indicate ssb - dismiss immediately */
9704 + * Print current insn
9706 + kdb_printf("SS trap at ");
9707 + kdb_symbol_print(regs->rip, NULL, KDB_SP_DEFAULT|KDB_SP_NEWLINE);
9708 + kdb_id1(regs->rip);
9709 + KDB_STATE_CLEAR(DOING_SS);
9712 + if (rv != KDB_DB_SSB)
9713 + regs->eflags &= ~EF_TF;
9716 + if (dr6 & DR6_B0) {
9717 + rw = DR7_RW0(dr7);
9722 + if (dr6 & DR6_B1) {
9723 + rw = DR7_RW1(dr7);
9728 + if (dr6 & DR6_B2) {
9729 + rw = DR7_RW2(dr7);
9734 + if (dr6 & DR6_B3) {
9735 + rw = DR7_RW3(dr7);
9743 + goto unknown; /* dismiss */
9749 + regs->eflags |= EF_RF;
9752 + * Determine which breakpoint was encountered.
9754 + for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
9755 + if (!(bp->bp_free)
9756 + && (bp->bp_global || bp->bp_cpu == smp_processor_id())
9758 + && (bp->bp_hard->bph_reg == reg)) {
9760 + * Hit this breakpoint.
9762 + kdb_printf("%s breakpoint #%d at " kdb_bfd_vma_fmt "\n",
9766 + * For an instruction breakpoint, disassemble
9767 + * the current instruction.
9770 + kdb_id1(regs->rip);
9778 + regs->eflags |= EF_RF; /* Supress further faults */
9779 + rv = KDB_DB_NOBPT; /* Cause kdb() to return */
9784 + * Clear the pending exceptions.
9794 + * Perform breakpoint processing upon entry to the
9795 + * processor breakpoint instruction fault. Determine and print
9796 + * the active breakpoint.
9799 + * regs Exception frame containing machine register state
9800 + * error Error number passed to kdb.
9804 + * 0 Standard instruction or data breakpoint encountered
9805 + * 1 Single Step fault ('ss' command)
9806 + * 2 Single Step fault, caller should continue ('ssb' command)
9807 + * 3 No existing kdb breakpoint matches this debug exception
9812 + * If multiple processors receive debug exceptions simultaneously,
9813 + * one may be waiting at the kdb fence in kdb() while the user
9814 + * issues a 'bc' command to clear the breakpoint the processor which
9815 + * is waiting has already encountered. If this is the case, the
9816 + * debug registers will no longer match any entry in the breakpoint
9817 + * table, and we'll return the value '3'. This can cause a panic
9818 + * in die_if_kernel(). It is safer to disable the breakpoint (bd),
9819 + * 'go' until all processors are past the breakpoint then clear the
9820 + * breakpoint (bc). This code recognises a breakpoint even when
9821 + * disabled but not when it has been cleared.
9823 + * WARNING: This routine resets the rip. It should be called
9824 + * once per breakpoint and the result cached.
9828 +kdba_bp_trap(struct pt_regs *regs, int error_unused)
9834 + if (KDB_NULL_REGS(regs))
9835 + return KDB_DB_NOBPT;
9837 + * Determine which breakpoint was encountered.
9839 + if (KDB_DEBUG(BP))
9840 + kdb_printf("kdba_bp_trap: rip=0x%lx (not adjusted) "
9841 + "eflags=0x%lx ef=0x%p rsp=0x%lx\n",
9842 + regs->rip, regs->eflags, regs, regs->rsp);
9844 + rv = KDB_DB_NOBPT; /* Cause kdb() to return */
9846 + for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
9849 + if (!bp->bp_global && bp->bp_cpu != smp_processor_id())
9851 + if ((void *)bp->bp_addr == (void *)(regs->rip - bp->bp_adjust)) {
9852 + /* Hit this breakpoint. */
9853 + regs->rip -= bp->bp_adjust;
9854 + kdb_printf("Instruction(i) breakpoint #%d at 0x%lx (adjusted)\n",
9856 + kdb_id1(regs->rip);
9859 + /* SSBPT is set when the kernel debugger must single
9860 + * step a task in order to re-establish an instruction
9861 + * breakpoint which uses the instruction replacement
9862 + * mechanism. It is cleared by any action that removes
9863 + * the need to single-step the breakpoint.
9865 + KDB_STATE_SET(SSBPT);
9876 + * Handle an instruction-breakpoint trap. Called when re-installing
9877 + * an enabled breakpoint which has has the bp_delay bit set.
9884 + * Ok, we really need to:
9885 + * 1) Restore the original instruction byte
9887 + * 3) Restore breakpoint instruction
9894 +kdba_handle_bp(struct pt_regs *regs, kdb_bp_t *bp)
9897 + if (KDB_NULL_REGS(regs))
9900 + if (KDB_DEBUG(BP))
9901 + kdb_printf("regs->rip = 0x%lx\n", regs->rip);
9904 + * Setup single step
9906 + kdba_setsinglestep(regs);
9909 + * Reset delay attribute
9912 + bp->bp_delayed = 1;
9919 + * Return a string describing type of breakpoint.
9922 + * bph Pointer to hardware breakpoint description
9926 + * Character string.
9933 +kdba_bptype(kdbhard_bp_t *bph)
9937 + mode = kdba_rwtypes[bph->bph_mode];
9945 + * Print register name assigned to breakpoint
9948 + * bph Pointer hardware breakpoint structure
9959 +kdba_printbpreg(kdbhard_bp_t *bph)
9961 + kdb_printf(" in dr%ld", bph->bph_reg);
9967 + * Print string describing hardware breakpoint.
9970 + * bph Pointer to hardware breakpoint description
9981 +kdba_printbp(kdb_bp_t *bp)
9983 + kdb_printf("\n is enabled");
9984 + if (bp->bp_hardtype) {
9985 + kdba_printbpreg(bp->bp_hard);
9986 + if (bp->bp_hard->bph_mode != 0) {
9987 + kdb_printf(" for %d bytes",
9988 + bp->bp_hard->bph_length+1);
9996 + * Parse architecture dependent portion of the
9997 + * breakpoint command.
10004 + * Zero for success, a kdb diagnostic for failure
10008 + * for Ia32 architure, data access, data write and
10009 + * I/O breakpoints are supported in addition to instruction
10012 + * {datar|dataw|io|inst} [length]
10016 +kdba_parsebp(int argc, const char **argv, int *nextargp, kdb_bp_t *bp)
10018 + int nextarg = *nextargp;
10020 + kdbhard_bp_t *bph = &bp->bp_template;
10022 + bph->bph_mode = 0; /* Default to instruction breakpoint */
10023 + bph->bph_length = 0; /* Length must be zero for insn bp */
10024 + if ((argc + 1) != nextarg) {
10025 + if (strnicmp(argv[nextarg], "datar", sizeof("datar")) == 0) {
10026 + bph->bph_mode = 3;
10027 + } else if (strnicmp(argv[nextarg], "dataw", sizeof("dataw")) == 0) {
10028 + bph->bph_mode = 1;
10029 + } else if (strnicmp(argv[nextarg], "io", sizeof("io")) == 0) {
10030 + bph->bph_mode = 2;
10031 + } else if (strnicmp(argv[nextarg], "inst", sizeof("inst")) == 0) {
10032 + bph->bph_mode = 0;
10034 + return KDB_ARGCOUNT;
10037 + bph->bph_length = 3; /* Default to 4 byte */
10041 + if ((argc + 1) != nextarg) {
10042 + unsigned long len;
10044 + diag = kdbgetularg((char *)argv[nextarg],
10050 + if ((len > 4) || (len == 3))
10051 + return KDB_BADLENGTH;
10053 + bph->bph_length = len;
10054 + bph->bph_length--; /* Normalize for debug register */
10058 + if ((argc + 1) != nextarg)
10059 + return KDB_ARGCOUNT;
10062 + * Indicate to architecture independent level that
10063 + * a hardware register assignment is required to enable
10064 + * this breakpoint.
10067 + bph->bph_free = 0;
10069 + if (KDB_DEBUG(BP))
10070 + kdb_printf("kdba_bp: no args, forcehw is %d\n", bp->bp_forcehw);
10071 + if (bp->bp_forcehw) {
10073 + * We are forced to use a hardware register for this
10074 + * breakpoint because either the bph or bpha
10075 + * commands were used to establish this breakpoint.
10077 + bph->bph_free = 0;
10080 + * Indicate to architecture dependent level that
10081 + * the instruction replacement breakpoint technique
10082 + * should be used for this breakpoint.
10084 + bph->bph_free = 1;
10085 + bp->bp_adjust = 1; /* software, int 3 is one byte */
10089 + if (bph->bph_mode != 2 && kdba_verify_rw(bp->bp_addr, bph->bph_length+1)) {
10090 + kdb_printf("Invalid address for breakpoint, ignoring bp command\n");
10091 + return KDB_BADADDR;
10094 + *nextargp = nextarg;
10101 + * Associate a hardware register with a breakpoint.
10108 + * A pointer to the allocated register kdbhard_bp_t structure for
10109 + * success, Null and a non-zero diagnostic for failure.
10116 +kdba_allocbp(kdbhard_bp_t *bph, int *diagp)
10119 + kdbhard_bp_t *newbph;
10121 + for(i=0,newbph=kdb_hardbreaks; i < KDB_MAXHARDBPT; i++, newbph++) {
10122 + if (newbph->bph_free) {
10127 + if (i == KDB_MAXHARDBPT) {
10128 + *diagp = KDB_TOOMANYDBREGS;
10135 + * Copy data from template. Can't just copy the entire template
10136 + * here because the register number in kdb_hardbreaks must be
10139 + newbph->bph_data = bph->bph_data;
10140 + newbph->bph_write = bph->bph_write;
10141 + newbph->bph_mode = bph->bph_mode;
10142 + newbph->bph_length = bph->bph_length;
10145 + * Mark entry allocated.
10147 + newbph->bph_free = 0;
10155 + * Deallocate a hardware breakpoint
10162 + * Zero for success, a kdb diagnostic for failure
10169 +kdba_freebp(kdbhard_bp_t *bph)
10171 + bph->bph_free = 1;
10177 + * Initialize the breakpoint table for the hardware breakpoint
10185 + * Zero for success, a kdb diagnostic for failure
10190 + * There is one entry per register. On the ia32 architecture
10191 + * all the registers are interchangeable, so no special allocation
10192 + * criteria are required.
10199 + kdbhard_bp_t *bph;
10202 + * Clear the hardware breakpoint table
10205 + memset(kdb_hardbreaks, '\0', sizeof(kdb_hardbreaks));
10207 + for(i=0,bph=kdb_hardbreaks; i<KDB_MAXHARDBPT; i++, bph++) {
10208 + bph->bph_reg = i;
10209 + bph->bph_free = 1;
10216 + * Install a breakpoint
10219 + * regs Exception frame
10220 + * bp Breakpoint structure for the breakpoint to be installed
10224 + * 0 if breakpoint installed.
10228 + * For hardware breakpoints, a debug register is allocated
10229 + * and assigned to the breakpoint. If no debug register is
10230 + * available, a warning message is printed and the breakpoint
10233 + * For instruction replacement breakpoints, we must single-step
10234 + * over the replaced instruction at this point so we can re-install
10235 + * the breakpoint instruction after the single-step.
10239 +kdba_installbp(struct pt_regs *regs, kdb_bp_t *bp)
10242 + * Install the breakpoint, if it is not already installed.
10245 + if (KDB_DEBUG(BP)) {
10246 + kdb_printf("kdba_installbp bp_installed %d\n", bp->bp_installed);
10248 + if (!KDB_STATE(SSBPT))
10249 + bp->bp_delay = 0;
10250 + if (!bp->bp_installed) {
10251 + if (bp->bp_hardtype) {
10252 + kdba_installdbreg(bp);
10253 + bp->bp_installed = 1;
10254 + if (KDB_DEBUG(BP)) {
10255 + kdb_printf("kdba_installbp hardware reg %ld at " kdb_bfd_vma_fmt "\n",
10256 + bp->bp_hard->bph_reg, bp->bp_addr);
10258 + } else if (bp->bp_delay) {
10259 + if (KDB_DEBUG(BP))
10260 + kdb_printf("kdba_installbp delayed bp\n");
10261 + kdba_handle_bp(regs, bp);
10263 + if (kdb_getarea_size(&(bp->bp_inst), bp->bp_addr, 1) ||
10264 + kdb_putword(bp->bp_addr, IA32_BREAKPOINT_INSTRUCTION, 1)) {
10265 + kdb_printf("kdba_installbp failed to set software breakpoint at " kdb_bfd_vma_fmt "\n", bp->bp_addr);
10268 + bp->bp_installed = 1;
10269 + if (KDB_DEBUG(BP))
10270 + kdb_printf("kdba_installbp instruction 0x%x at " kdb_bfd_vma_fmt "\n",
10271 + IA32_BREAKPOINT_INSTRUCTION, bp->bp_addr);
10280 + * Make a breakpoint ineffective.
10294 +kdba_removebp(kdb_bp_t *bp)
10297 + * For hardware breakpoints, remove it from the active register,
10298 + * for software breakpoints, restore the instruction stream.
10300 + if (KDB_DEBUG(BP)) {
10301 + kdb_printf("kdba_removebp bp_installed %d\n", bp->bp_installed);
10303 + if (bp->bp_installed) {
10304 + if (bp->bp_hardtype) {
10305 + if (KDB_DEBUG(BP)) {
10306 + kdb_printf("kdb: removing hardware reg %ld at " kdb_bfd_vma_fmt "\n",
10307 + bp->bp_hard->bph_reg, bp->bp_addr);
10309 + kdba_removedbreg(bp);
10311 + if (KDB_DEBUG(BP))
10312 + kdb_printf("kdb: restoring instruction 0x%x at " kdb_bfd_vma_fmt "\n",
10313 + bp->bp_inst, bp->bp_addr);
10314 + if (kdb_putword(bp->bp_addr, bp->bp_inst, 1))
10317 + bp->bp_installed = 0;
10321 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/kdba_bt.c linux-2.6.22-600/arch/x86_64/kdb/kdba_bt.c
10322 --- linux-2.6.22-590/arch/x86_64/kdb/kdba_bt.c 1970-01-01 01:00:00.000000000 +0100
10323 +++ linux-2.6.22-600/arch/x86_64/kdb/kdba_bt.c 2008-04-09 18:16:24.000000000 +0200
10326 + * Kernel Debugger Architecture Dependent Stack Traceback
10328 + * This file is subject to the terms and conditions of the GNU General Public
10329 + * License. See the file "COPYING" in the main directory of this archive
10330 + * for more details.
10332 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
10335 +#include <linux/ctype.h>
10336 +#include <linux/string.h>
10337 +#include <linux/kernel.h>
10338 +#include <linux/sched.h>
10339 +#include <linux/kallsyms.h>
10340 +#include <linux/irq.h>
10341 +#include <linux/kdb.h>
10342 +#include <linux/kdbprivate.h>
10343 +#include <asm/system.h>
10345 +/* x86_64 has multiple alternate stacks, with different sizes and different
10346 + * offsets to get the link from one stack to the next. Some of the stacks are
10347 + * referenced via cpu_pda, some via per_cpu orig_ist. Debug events can even
10348 + * have multiple nested stacks within the single physical stack, each nested
10349 + * stack has its own link and some of those links are wrong.
10351 + * Consistent it's not!
10353 + * Do not assume that these stacks are aligned on their size.
10355 +#define INTERRUPT_STACK (N_EXCEPTION_STACKS + 1)
10357 +kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
10358 + struct kdb_activation_record *ar)
10362 + unsigned int total_size;
10363 + unsigned int nested_size;
10364 + unsigned int next;
10365 + } *sdp, stack_data[] = {
10366 + [STACKFAULT_STACK - 1] = { "stackfault", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
10367 + [DOUBLEFAULT_STACK - 1] = { "doublefault", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
10368 + [NMI_STACK - 1] = { "nmi", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
10369 + [DEBUG_STACK - 1] = { "debug", DEBUG_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
10370 + [MCE_STACK - 1] = { "machine check", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
10371 + [INTERRUPT_STACK - 1] = { "interrupt", IRQSTACKSIZE, IRQSTACKSIZE, IRQSTACKSIZE - sizeof(void *) },
10373 + unsigned long total_start = 0, total_size, total_end;
10374 + int sd, found = 0;
10376 + for (sd = 0, sdp = stack_data;
10377 + sd < ARRAY_SIZE(stack_data);
10379 + total_size = sdp->total_size;
10381 + continue; /* in case stack_data[] has any holes */
10383 + /* Arbitrary address which can be on any cpu, see if it
10384 + * falls within any of the alternate stacks
10387 + for_each_online_cpu(c) {
10388 + if (sd == INTERRUPT_STACK - 1)
10389 + total_end = (unsigned long)cpu_pda(c)->irqstackptr;
10391 + total_end = per_cpu(orig_ist, c).ist[sd];
10392 + total_start = total_end - total_size;
10393 + if (addr >= total_start && addr < total_end) {
10402 + /* Only check the supplied or found cpu */
10403 + if (sd == INTERRUPT_STACK - 1)
10404 + total_end = (unsigned long)cpu_pda(cpu)->irqstackptr;
10406 + total_end = per_cpu(orig_ist, cpu).ist[sd];
10407 + total_start = total_end - total_size;
10408 + if (addr >= total_start && addr < total_end) {
10415 + /* find which nested stack the address is in */
10416 + while (addr > total_start + sdp->nested_size)
10417 + total_start += sdp->nested_size;
10418 + ar->stack.physical_start = total_start;
10419 + ar->stack.physical_end = total_start + sdp->nested_size;
10420 + ar->stack.logical_start = total_start;
10421 + ar->stack.logical_end = total_start + sdp->next;
10422 + ar->stack.next = *(unsigned long *)ar->stack.logical_end;
10423 + ar->stack.id = sdp->id;
10425 + /* Nasty: common_interrupt builds a partial pt_regs, with r15 through
10426 + * rbx not being filled in. It passes struct pt_regs* to do_IRQ (in
10427 + * rdi) but the stack pointer is not adjusted to account for r15
10428 + * through rbx. This has two effects :-
10430 + * (1) struct pt_regs on an external interrupt actually overlaps with
10431 + * the local stack area used by do_IRQ. Not only are r15-rbx
10432 + * undefined, the area that claims to hold their values can even
10433 + * change as the irq is processed..
10435 + * (2) The back stack pointer saved for the new frame is not pointing
10436 + * at pt_regs, it is pointing at rbx within the pt_regs passed to
10439 + * There is nothing that I can do about (1) but I have to fix (2)
10440 + * because kdb backtrace looks for pt_regs.
10443 + if (sd == INTERRUPT_STACK - 1)
10444 + ar->stack.next -= offsetof(struct pt_regs, rbx);
10447 +/* Given an address which claims to be on a stack, an optional cpu number and
10448 + * an optional task address, get information about the stack.
10450 + * t == NULL, cpu < 0 indicates an arbitrary stack address with no associated
10451 + * struct task, the address can be in an alternate stack or any task's normal
10454 + * t != NULL, cpu >= 0 indicates a running task, the address can be in an
10455 + * alternate stack or that task's normal stack.
10457 + * t != NULL, cpu < 0 indicates a blocked task, the address can only be in that
10458 + * task's normal stack.
10460 + * t == NULL, cpu >= 0 is not a valid combination.
10464 +kdba_get_stack_info(kdb_machreg_t rsp, int cpu,
10465 + struct kdb_activation_record *ar,
10466 + const struct task_struct *t)
10468 + struct thread_info *tinfo;
10469 + struct task_struct *g, *p;
10470 + memset(&ar->stack, 0, sizeof(ar->stack));
10471 + if (KDB_DEBUG(ARA))
10472 + kdb_printf("%s: rsp=0x%lx cpu=%d task=%p\n",
10473 + __FUNCTION__, rsp, cpu, t);
10474 + if (t == NULL || cpu >= 0) {
10475 + kdba_get_stack_info_alternate(rsp, cpu, ar);
10476 + if (ar->stack.logical_start)
10479 + rsp &= -THREAD_SIZE;
10480 + tinfo = (struct thread_info *)rsp;
10482 + /* Arbitrary stack address without an associated task, see if
10483 + * it falls within any normal process stack, including the idle
10486 + kdb_do_each_thread(g, p) {
10487 + if (tinfo == task_thread_info(p)) {
10491 + } kdb_while_each_thread(g, p);
10492 + for_each_online_cpu(cpu) {
10493 + p = idle_task(cpu);
10494 + if (tinfo == task_thread_info(p)) {
10500 + if (KDB_DEBUG(ARA))
10501 + kdb_printf("%s: found task %p\n", __FUNCTION__, t);
10502 + } else if (cpu >= 0) {
10503 + /* running task */
10504 + struct kdb_running_process *krp = kdb_running_process + cpu;
10505 + if (krp->p != t || tinfo != task_thread_info(t))
10507 + if (KDB_DEBUG(ARA))
10508 + kdb_printf("%s: running task %p\n", __FUNCTION__, t);
10510 + /* blocked task */
10511 + if (tinfo != task_thread_info(t))
10513 + if (KDB_DEBUG(ARA))
10514 + kdb_printf("%s: blocked task %p\n", __FUNCTION__, t);
10517 + ar->stack.physical_start = rsp;
10518 + ar->stack.physical_end = rsp + THREAD_SIZE;
10519 + ar->stack.logical_start = rsp + sizeof(struct thread_info);
10520 + ar->stack.logical_end = ar->stack.physical_end;
10521 + ar->stack.next = 0;
10522 + ar->stack.id = "normal";
10525 + if (ar->stack.physical_start && KDB_DEBUG(ARA)) {
10526 + kdb_printf("%s: ar->stack\n", __FUNCTION__);
10527 + kdb_printf(" physical_start=0x%lx\n", ar->stack.physical_start);
10528 + kdb_printf(" physical_end=0x%lx\n", ar->stack.physical_end);
10529 + kdb_printf(" logical_start=0x%lx\n", ar->stack.logical_start);
10530 + kdb_printf(" logical_end=0x%lx\n", ar->stack.logical_end);
10531 + kdb_printf(" next=0x%lx\n", ar->stack.next);
10532 + kdb_printf(" id=%s\n", ar->stack.id);
10539 + * Print one back trace entry.
10542 + * rip Current program counter, or return address.
10543 + * rsp Stack pointer rsp when at rip.
10544 + * ar Activation record for this frame.
10545 + * symtab Information about symbol that rip falls within.
10546 + * argcount Maximum number of arguments to print.
10558 +bt_print_one(kdb_machreg_t rip, kdb_machreg_t rsp,
10559 + const struct kdb_activation_record *ar,
10560 + const kdb_symtab_t *symtab, int argcount)
10562 + int btsymarg = 0;
10564 + kdb_machreg_t word;
10566 + kdbgetintenv("BTSYMARG", &btsymarg);
10567 + kdbgetintenv("NOSECT", &nosect);
10569 + kdb_printf(kdb_machreg_fmt0, rsp);
10570 + kdb_symbol_print(rip, symtab, KDB_SP_SPACEB|KDB_SP_VALUE);
10571 + if (argcount && ar->args) {
10572 + int i, argc = ar->args;
10573 + kdb_printf(" (");
10574 + if (argc > argcount)
10576 + for (i = 0; i < argc; i++) {
10577 + kdb_machreg_t argp = ar->arg[i];
10579 + kdb_printf(", ");
10580 + kdb_getword(&word, argp, sizeof(word));
10581 + kdb_printf("0x%lx", word);
10585 + if (symtab->sym_name) {
10587 + kdb_printf("\n");
10588 + kdb_printf(" %s",
10589 + symtab->mod_name);
10590 + if (symtab->sec_name && symtab->sec_start)
10591 + kdb_printf(" 0x%lx 0x%lx",
10592 + symtab->sec_start, symtab->sec_end);
10593 + kdb_printf(" 0x%lx 0x%lx",
10594 + symtab->sym_start, symtab->sym_end);
10597 + kdb_printf("\n");
10598 + if (argcount && ar->args && btsymarg) {
10599 + int i, argc = ar->args;
10600 + kdb_symtab_t arg_symtab;
10601 + for (i = 0; i < argc; i++) {
10602 + kdb_machreg_t argp = ar->arg[i];
10603 + kdb_getword(&word, argp, sizeof(word));
10604 + if (kdbnearsym(word, &arg_symtab)) {
10606 + kdb_symbol_print(word, &arg_symtab,
10607 + KDB_SP_DEFAULT|KDB_SP_NEWLINE);
10613 +/* Getting the starting point for a backtrace on a running process is
10614 + * moderately tricky. kdba_save_running() saved the rsp in krp->arch.rsp, but
10615 + * that rsp is not 100% accurate, it can be offset by a frame pointer or by the
10616 + * size of local variables in kdba_main_loop() and kdb_save_running().
10618 + * The calling sequence is kdb() -> kdba_main_loop() -> kdb_save_running() ->
10619 + * kdba_save_running(). Walk up the stack until we find a return address
10620 + * inside the main kdb() function and start the backtrace from there.
10624 +kdba_bt_stack_running(const struct task_struct *p,
10625 + const struct kdb_activation_record *ar,
10626 + kdb_machreg_t *rip, kdb_machreg_t *rsp,
10627 + kdb_machreg_t *rbp)
10629 + kdb_machreg_t addr, sp;
10630 + kdb_symtab_t symtab;
10631 + struct kdb_running_process *krp = kdb_running_process + task_cpu(p);
10634 + if (kdbgetsymval("kdb", &symtab) == 0)
10636 + if (kdbnearsym(symtab.sym_start, &symtab) == 0)
10638 + sp = krp->arch.rsp;
10639 + if (sp < ar->stack.logical_start || sp >= ar->stack.logical_end)
10641 + while (sp < ar->stack.logical_end) {
10642 + addr = *(kdb_machreg_t *)sp;
10643 + if (addr >= symtab.sym_start && addr < symtab.sym_end) {
10647 + sp += sizeof(kdb_machreg_t);
10651 + *rbp = *rsp = sp;
10660 + * addr Pointer to Address provided to 'bt' command, if any.
10662 + * p Pointer to task for 'btp' command.
10666 + * zero for success, a kdb diagnostic if error
10670 + * mds comes in handy when examining the stack to do a manual
10675 +kdba_bt_stack(kdb_machreg_t addr, int argcount, const struct task_struct *p)
10677 + struct kdb_activation_record ar;
10678 + kdb_machreg_t rip, rsp, rbp, cs;
10679 + kdb_symtab_t symtab;
10680 + int first_time = 1, count = 0, btsp = 0, suppress;
10681 + struct pt_regs *regs = NULL;
10683 + kdbgetintenv("BTSP", &btsp);
10684 + suppress = !btsp;
10685 + memset(&ar, 0, sizeof(ar));
10688 + * The caller may have supplied an address at which the
10689 + * stack traceback operation should begin. This address
10690 + * is assumed by this code to point to a return-address
10691 + * on the stack to be traced back.
10693 + * The end result of this will make it appear as if a function
10694 + * entitled '<unknown>' was called from the function which
10695 + * contains return-address.
10701 + cs = __KERNEL_CS; /* have to assume kernel space */
10703 + kdba_get_stack_info(rsp, -1, &ar, NULL);
10705 + if (task_curr(p)) {
10706 + struct kdb_running_process *krp =
10707 + kdb_running_process + task_cpu(p);
10709 + if (krp->seqno && krp->p == p
10710 + && krp->seqno >= kdb_seqno - 1) {
10711 + /* valid saved state, continue processing */
10714 + ("Process did not save state, cannot backtrace\n");
10718 + regs = krp->regs;
10719 + if (KDB_NULL_REGS(regs))
10720 + return KDB_BADREG;
10721 + kdba_getregcontents("cs", regs, &cs);
10722 + if ((cs & 0xffff) != __KERNEL_CS) {
10723 + kdb_printf("Stack is not in kernel space, backtrace not available\n");
10726 + kdba_getregcontents("rip", regs, &rip);
10727 + kdba_getregcontents("rbp", regs, &rbp);
10728 + rsp = krp->arch.rsp;
10729 + kdba_get_stack_info(rsp, kdb_process_cpu(p), &ar, p);
10730 + if (kdba_bt_stack_running(p, &ar, &rip, &rsp, &rbp) == 0) {
10731 + kdb_printf("%s: cannot adjust rsp=0x%lx for a running task\n",
10732 + __FUNCTION__, rsp);
10735 + /* Not on cpu, assume blocked. Blocked tasks do
10736 + * not have pt_regs. p->thread.rsp is set, rsp
10737 + * points to the rbp value, assume kernel space.
10739 + * The rip is no longer in the thread struct. We know
10740 + * that the stack value was saved in schedule near the
10741 + * label thread_return. Setting rip to thread_return-1
10742 + * lets the stack trace find that we are in schedule
10743 + * and correctly decode its prologue. We extract the
10744 + * saved rbp and adjust the stack to undo the effects
10745 + * of the inline assembly code which switches the
10748 + extern void thread_return(void);
10749 + rip = (kdb_machreg_t)&thread_return-1;
10750 + rsp = p->thread.rsp;
10751 + rbp = *(unsigned long *)rsp;
10753 + cs = __KERNEL_CS;
10755 + kdba_get_stack_info(rsp, -1, &ar, p);
10758 + if (!ar.stack.physical_start) {
10759 + kdb_printf("rsp=0x%lx is not in a valid kernel stack, backtrace not available\n",
10764 + kdb_printf("rsp rip Function (args)\n");
10765 + if (ar.stack.next && !suppress)
10766 + kdb_printf(" ======================= <%s>\n",
10769 + /* Run through all the stacks */
10770 + while (ar.stack.physical_start) {
10772 + rip = *(kdb_machreg_t *)rsp;
10774 + if (!suppress && __kernel_text_address(rip)) {
10775 + kdbnearsym(rip, &symtab);
10776 + bt_print_one(rip, rsp, &ar, &symtab, argcount);
10779 + if ((struct pt_regs *)rsp == regs) {
10780 + if (ar.stack.next && suppress)
10781 + kdb_printf(" ======================= <%s>\n",
10786 + rsp += sizeof(rip);
10789 + if (rsp < ar.stack.logical_end)
10791 + if (!ar.stack.next)
10793 + rsp = ar.stack.next;
10794 + if (KDB_DEBUG(ARA))
10795 + kdb_printf("new rsp=0x%lx\n", rsp);
10796 + kdba_get_stack_info(rsp, -1, &ar, NULL);
10797 + if (!ar.stack.physical_start) {
10798 + kdb_printf("+++ Cannot resolve next stack\n");
10799 + } else if (!suppress) {
10800 + kdb_printf(" ======================= <%s>\n",
10807 + kdb_printf("bt truncated, count limit reached\n");
10808 + else if (suppress)
10810 + ("bt did not find pt_regs - no trace produced. Suggest 'set BTSP 1'\n");
10816 + * kdba_bt_address
10818 + * Do a backtrace starting at a specified stack address. Use this if the
10819 + * heuristics get the stack decode wrong.
10822 + * addr Address provided to 'bt' command.
10827 + * zero for success, a kdb diagnostic if error
10831 + * mds %rsp comes in handy when examining the stack to do a manual
10835 +int kdba_bt_address(kdb_machreg_t addr, int argcount)
10837 + return kdba_bt_stack(addr, argcount, NULL);
10841 + * kdba_bt_process
10843 + * Do a backtrace for a specified process.
10846 + * p Struct task pointer extracted by 'bt' command.
10851 + * zero for success, a kdb diagnostic if error
10856 +int kdba_bt_process(const struct task_struct *p, int argcount)
10858 + return kdba_bt_stack(0, argcount, p);
10860 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/kdba_id.c linux-2.6.22-600/arch/x86_64/kdb/kdba_id.c
10861 --- linux-2.6.22-590/arch/x86_64/kdb/kdba_id.c 1970-01-01 01:00:00.000000000 +0100
10862 +++ linux-2.6.22-600/arch/x86_64/kdb/kdba_id.c 2008-04-09 18:16:24.000000000 +0200
10865 + * Kernel Debugger Architecture Dependent Instruction Disassembly
10867 + * This file is subject to the terms and conditions of the GNU General Public
10868 + * License. See the file "COPYING" in the main directory of this archive
10869 + * for more details.
10871 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
10874 +#include <stdarg.h>
10875 +#include <linux/kernel.h>
10876 +#include <linux/init.h>
10877 +#include <linux/ctype.h>
10878 +#include <linux/string.h>
10879 +#include <linux/kdb.h>
10880 +#include <linux/kdbprivate.h>
10883 + * kdba_dis_getsym
10885 + * Get a symbol for the disassembler.
10888 + * addr Address for which to get symbol
10889 + * dip Pointer to disassemble_info
10894 + * Not used for kdb.
10899 +kdba_dis_getsym(bfd_vma addr, disassemble_info *dip)
10906 + * kdba_printaddress
10908 + * Print (symbolically) an address.
10911 + * addr Address for which to get symbol
10912 + * dip Pointer to disassemble_info
10913 + * flag True if a ":<tab>" sequence should follow the address
10923 +kdba_printaddress(kdb_machreg_t addr, disassemble_info *dip, int flag)
10925 + kdb_symtab_t symtab;
10927 + unsigned int offset;
10930 + * Print a symbol name or address as necessary.
10932 + kdbnearsym(addr, &symtab);
10933 + if (symtab.sym_name) {
10934 + /* Do not use kdb_symbol_print here, it always does
10935 + * kdb_printf but we want dip->fprintf_func.
10937 + dip->fprintf_func(dip->stream,
10939 + (int)(2*sizeof(addr)), addr, symtab.sym_name);
10940 + if ((offset = addr - symtab.sym_start) == 0) {
10944 + unsigned int o = offset;
10947 + dip->fprintf_func(dip->stream, "+0x%x", offset);
10951 + dip->fprintf_func(dip->stream, "0x%lx", addr);
10955 + if (spaces < 1) {
10958 + dip->fprintf_func(dip->stream, ":%*s", spaces, " ");
10963 + * kdba_dis_printaddr
10965 + * Print (symbolically) an address. Called by GNU disassembly
10966 + * code via disassemble_info structure.
10969 + * addr Address for which to get symbol
10970 + * dip Pointer to disassemble_info
10975 + * This function will never append ":<tab>" to the printed
10976 + * symbolic address.
10980 +kdba_dis_printaddr(bfd_vma addr, disassemble_info *dip)
10982 + kdba_printaddress(addr, dip, 0);
10986 + * kdba_dis_getmem
10988 + * Fetch 'length' bytes from 'addr' into 'buf'.
10991 + * addr Address for which to get symbol
10992 + * buf Address of buffer to fill with bytes from 'addr'
10993 + * length Number of bytes to fetch
10994 + * dip Pointer to disassemble_info
10996 + * 0 if data is available, otherwise error.
11004 +kdba_dis_getmem(bfd_vma addr, bfd_byte *buf, unsigned int length, disassemble_info *dip)
11006 + return kdb_getarea_size(buf, addr, length);
11010 + * kdba_id_parsemode
11012 + * Parse IDMODE environment variable string and
11013 + * set appropriate value into "disassemble_info" structure.
11016 + * mode Mode string
11017 + * dip Disassemble_info structure pointer
11021 + * We handle the values 'x86' and '8086' to enable either
11022 + * 32-bit instruction set or 16-bit legacy instruction set.
11026 +kdba_id_parsemode(const char *mode, disassemble_info *dip)
11029 + if (strcmp(mode, "x86_64") == 0) {
11030 + dip->mach = bfd_mach_x86_64;
11031 + } else if (strcmp(mode, "x86") == 0) {
11032 + dip->mach = bfd_mach_i386_i386;
11033 + } else if (strcmp(mode, "8086") == 0) {
11034 + dip->mach = bfd_mach_i386_i8086;
11036 + return KDB_BADMODE;
11046 + * Check that the pc is satisfactory.
11049 + * pc Program Counter Value.
11059 +kdba_check_pc(kdb_machreg_t *pc)
11065 + * kdba_id_printinsn
11067 + * Format and print a single instruction at 'pc'. Return the
11068 + * length of the instruction.
11071 + * pc Program Counter Value.
11072 + * dip Disassemble_info structure pointer
11074 + * Length of instruction, -1 for error.
11078 + * Depends on 'IDMODE' environment variable.
11082 +kdba_id_printinsn(kdb_machreg_t pc, disassemble_info *dip)
11084 + kdba_printaddress(pc, dip, 1);
11085 + return print_insn_i386_att(pc, dip);
11091 + * Initialize the architecture dependent elements of
11092 + * the disassembly information structure
11093 + * for the GNU disassembler.
11107 +kdba_id_init(disassemble_info *dip)
11109 + dip->read_memory_func = kdba_dis_getmem;
11110 + dip->print_address_func = kdba_dis_printaddr;
11111 + dip->symbol_at_address_func = kdba_dis_getsym;
11113 + dip->flavour = bfd_target_elf_flavour;
11114 + dip->arch = bfd_arch_i386;
11115 + dip->mach = bfd_mach_x86_64;
11116 + dip->endian = BFD_ENDIAN_LITTLE;
11118 + dip->display_endian = BFD_ENDIAN_LITTLE;
11120 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/kdba_io.c linux-2.6.22-600/arch/x86_64/kdb/kdba_io.c
11121 --- linux-2.6.22-590/arch/x86_64/kdb/kdba_io.c 1970-01-01 01:00:00.000000000 +0100
11122 +++ linux-2.6.22-600/arch/x86_64/kdb/kdba_io.c 2008-04-09 18:16:24.000000000 +0200
11125 + * Kernel Debugger Architecture Dependent Console I/O handler
11127 + * This file is subject to the terms and conditions of the GNU General Public
11128 + * License. See the file "COPYING" in the main directory of this archive
11129 + * for more details.
11131 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
11134 +#include <linux/sched.h>
11135 +#include <linux/kernel.h>
11136 +#include <asm/io.h>
11137 +#include <linux/delay.h>
11138 +#include <linux/console.h>
11139 +#include <linux/ctype.h>
11140 +#include <linux/keyboard.h>
11141 +#include <linux/serial.h>
11142 +#include <linux/serial_reg.h>
11144 +#include <linux/kdb.h>
11145 +#include <linux/kdbprivate.h>
11146 +#include <pc_keyb.h>
11148 +#ifdef CONFIG_VT_CONSOLE
11149 +#define KDB_BLINK_LED 1
11151 +#undef KDB_BLINK_LED
11154 +#ifdef CONFIG_KDB_USB
11155 +struct kdb_usb_exchange kdb_usb_infos;
11157 +EXPORT_SYMBOL(kdb_usb_infos);
11159 +static unsigned char kdb_usb_keycode[256] = {
11160 + 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
11161 + 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
11162 + 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
11163 + 27, 43, 84, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
11164 + 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
11165 + 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
11166 + 72, 73, 82, 83, 86,127,116,117, 85, 89, 90, 91, 92, 93, 94, 95,
11167 + 120,121,122,123,134,138,130,132,128,129,131,137,133,135,136,113,
11168 + 115,114, 0, 0, 0,124, 0,181,182,183,184,185,186,187,188,189,
11169 + 190,191,192,193,194,195,196,197,198, 0, 0, 0, 0, 0, 0, 0,
11170 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11171 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11172 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11173 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11174 + 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
11175 + 150,158,159,128,136,177,178,176,142,152,173,140
11179 + * This function drives the UHCI controller,
11180 + * fetch the USB scancode and decode it
11182 +static int get_usb_char(void)
11184 + static int usb_lock;
11185 + unsigned char keycode, spec;
11186 + extern u_short plain_map[], shift_map[], ctrl_map[];
11188 + /* Is USB initialized ? */
11189 + if(!kdb_usb_infos.poll_func || !kdb_usb_infos.urb)
11192 + /* Transfer char if they are present */
11193 + (*kdb_usb_infos.poll_func)(kdb_usb_infos.uhci, (struct urb *)kdb_usb_infos.urb);
11195 + spec = kdb_usb_infos.buffer[0];
11196 + keycode = kdb_usb_infos.buffer[2];
11197 + kdb_usb_infos.buffer[0] = (char)0;
11198 + kdb_usb_infos.buffer[2] = (char)0;
11200 + if(kdb_usb_infos.buffer[3])
11203 + /* A normal key is pressed, decode it */
11205 + keycode = kdb_usb_keycode[keycode];
11207 + /* 2 Keys pressed at one time ? */
11208 + if (spec && keycode) {
11212 + case 0x20: /* Shift */
11213 + return shift_map[keycode];
11215 + case 0x10: /* Ctrl */
11216 + return ctrl_map[keycode];
11218 + case 0x40: /* Alt */
11223 + if(keycode) { /* If only one key pressed */
11226 + case 0x1C: /* Enter */
11229 + case 0x3A: /* Capslock */
11230 + usb_lock ? (usb_lock = 0) : (usb_lock = 1);
11232 + case 0x0E: /* Backspace */
11234 + case 0x0F: /* TAB */
11236 + case 0x77: /* Pause */
11240 + return plain_map[keycode];
11243 + return shift_map[keycode];
11250 +#endif /* CONFIG_KDB_USB */
11253 + * This module contains code to read characters from the keyboard or a serial
11256 + * It is used by the kernel debugger, and is polled, not interrupt driven.
11260 +#ifdef KDB_BLINK_LED
11262 + * send: Send a byte to the keyboard controller. Used primarily to
11263 + * alter LED settings.
11267 +kdb_kbdsend(unsigned char byte)
11270 + for (timeout = 200 * 1000; timeout && (inb(KBD_STATUS_REG) & KBD_STAT_IBF); timeout--);
11271 + outb(byte, KBD_DATA_REG);
11273 + for (timeout = 200 * 1000; timeout && (~inb(KBD_STATUS_REG) & KBD_STAT_OBF); timeout--);
11274 + inb(KBD_DATA_REG);
11279 +kdb_toggleled(int led)
11285 + kdb_kbdsend(KBD_CMD_SET_LEDS);
11286 + kdb_kbdsend((unsigned char)leds);
11288 +#endif /* KDB_BLINK_LED */
11290 +#if defined(CONFIG_SERIAL_8250_CONSOLE) || defined(CONFIG_SERIAL_CORE_CONSOLE)
11291 +#define CONFIG_SERIAL_CONSOLE
11294 +#if defined(CONFIG_SERIAL_CONSOLE)
11296 +struct kdb_serial kdb_serial;
11298 +static unsigned int
11299 +serial_inp(struct kdb_serial *kdb_serial, unsigned long offset)
11301 + offset <<= kdb_serial->ioreg_shift;
11303 + switch (kdb_serial->io_type) {
11304 + case SERIAL_IO_MEM:
11305 + return readb((void __iomem *)(kdb_serial->iobase + offset));
11308 + return inb(kdb_serial->iobase + offset);
11313 +/* Check if there is a byte ready at the serial port */
11314 +static int get_serial_char(void)
11316 + unsigned char ch;
11318 + if (kdb_serial.iobase == 0)
11321 + if (serial_inp(&kdb_serial, UART_LSR) & UART_LSR_DR) {
11322 + ch = serial_inp(&kdb_serial, UART_RX);
11329 +#endif /* CONFIG_SERIAL_CONSOLE */
11331 +#ifdef CONFIG_VT_CONSOLE
11333 +static int kbd_exists;
11336 + * Check if the keyboard controller has a keypress for us.
11337 + * Some parts (Enter Release, LED change) are still blocking polled here,
11338 + * but hopefully they are all short.
11340 +static int get_kbd_char(void)
11342 + int scancode, scanstatus;
11343 + static int shift_lock; /* CAPS LOCK state (0-off, 1-on) */
11344 + static int shift_key; /* Shift next keypress */
11345 + static int ctrl_key;
11347 + extern u_short plain_map[], shift_map[], ctrl_map[];
11349 + if (KDB_FLAG(NO_I8042) || KDB_FLAG(NO_VT_CONSOLE) ||
11350 + (inb(KBD_STATUS_REG) == 0xff && inb(KBD_DATA_REG) == 0xff)) {
11356 + if ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0)
11360 + * Fetch the scancode
11362 + scancode = inb(KBD_DATA_REG);
11363 + scanstatus = inb(KBD_STATUS_REG);
11366 + * Ignore mouse events.
11368 + if (scanstatus & KBD_STAT_MOUSE_OBF)
11372 + * Ignore release, trigger on make
11373 + * (except for shift keys, where we want to
11374 + * keep the shift state so long as the key is
11378 + if (((scancode&0x7f) == 0x2a) || ((scancode&0x7f) == 0x36)) {
11380 + * Next key may use shift table
11382 + if ((scancode & 0x80) == 0) {
11390 + if ((scancode&0x7f) == 0x1d) {
11394 + if ((scancode & 0x80) == 0) {
11402 + if ((scancode & 0x80) != 0)
11405 + scancode &= 0x7f;
11408 + * Translate scancode
11411 + if (scancode == 0x3a) {
11413 + * Toggle caps lock
11417 +#ifdef KDB_BLINK_LED
11418 + kdb_toggleled(0x4);
11423 + if (scancode == 0x0e) {
11430 + /* Special Key */
11431 + switch (scancode) {
11432 + case 0xF: /* Tab */
11434 + case 0x53: /* Del */
11436 + case 0x47: /* Home */
11438 + case 0x4F: /* End */
11440 + case 0x4B: /* Left */
11442 + case 0x48: /* Up */
11444 + case 0x50: /* Down */
11446 + case 0x4D: /* Right */
11450 + if (scancode == 0xe0) {
11455 + * For Japanese 86/106 keyboards
11456 + * See comment in drivers/char/pc_keyb.c.
11457 + * - Masahiro Adegawa
11459 + if (scancode == 0x73) {
11461 + } else if (scancode == 0x7d) {
11465 + if (!shift_lock && !shift_key && !ctrl_key) {
11466 + keychar = plain_map[scancode];
11467 + } else if (shift_lock || shift_key) {
11468 + keychar = shift_map[scancode];
11469 + } else if (ctrl_key) {
11470 + keychar = ctrl_map[scancode];
11472 + keychar = 0x0020;
11473 + kdb_printf("Unknown state/scancode (%d)\n", scancode);
11475 + keychar &= 0x0fff;
11476 + if (keychar == '\t')
11478 + switch (KTYP(keychar)) {
11481 + if (isprint(keychar))
11482 + break; /* printable characters */
11483 + /* drop through */
11485 + if (keychar == K_ENTER)
11487 + /* drop through */
11489 + return(-1); /* ignore unprintables */
11492 + if ((scancode & 0x7f) == 0x1c) {
11494 + * enter key. All done. Absorb the release scancode.
11496 + while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0)
11500 + * Fetch the scancode
11502 + scancode = inb(KBD_DATA_REG);
11503 + scanstatus = inb(KBD_STATUS_REG);
11505 + while (scanstatus & KBD_STAT_MOUSE_OBF) {
11506 + scancode = inb(KBD_DATA_REG);
11507 + scanstatus = inb(KBD_STATUS_REG);
11510 + if (scancode != 0x9c) {
11512 + * Wasn't an enter-release, why not?
11514 + kdb_printf("kdb: expected enter got 0x%x status 0x%x\n",
11515 + scancode, scanstatus);
11518 + kdb_printf("\n");
11522 + return keychar & 0xff;
11524 +#endif /* CONFIG_VT_CONSOLE */
11526 +#ifdef KDB_BLINK_LED
11528 +/* Leave numlock alone, setting it messes up laptop keyboards with the keypad
11529 + * mapped over normal keys.
11531 +static int kdba_blink_mask = 0x1 | 0x4;
11533 +#define BOGOMIPS (boot_cpu_data.loops_per_jiffy/(500000/HZ))
11534 +static int blink_led(void)
11536 + static long delay;
11538 + if (kbd_exists == 0)
11541 + if (--delay < 0) {
11542 + if (BOGOMIPS == 0) /* early kdb */
11543 + delay = 150000000/1000; /* arbitrary bogomips */
11545 + delay = 150000000/BOGOMIPS; /* Roughly 1 second when polling */
11546 + kdb_toggleled(kdba_blink_mask);
11552 +get_char_func poll_funcs[] = {
11553 +#if defined(CONFIG_VT_CONSOLE)
11556 +#if defined(CONFIG_SERIAL_CONSOLE)
11559 +#ifdef KDB_BLINK_LED
11562 +#ifdef CONFIG_KDB_USB
11569 + * On some Compaq Deskpro's, there is a keyboard freeze many times after
11570 + * exiting from the kdb. As kdb's keyboard handler is not interrupt-driven and
11571 + * uses a polled interface, it makes more sense to disable motherboard keyboard
11572 + * controller's OBF interrupts during kdb's polling.In case, of interrupts
11573 + * remaining enabled during kdb's polling, it may cause un-necessary
11574 + * interrupts being signalled during keypresses, which are also sometimes seen
11575 + * as spurious interrupts after exiting from kdb. This hack to disable OBF
11576 + * interrupts before entry to kdb and re-enabling them at kdb exit point also
11577 + * solves the keyboard freeze issue. These functions are called from
11578 + * kdb_local(), hence these are arch. specific setup and cleanup functions
11579 + * executing only on the local processor - ashishk@sco.com
11582 +void kdba_local_arch_setup(void)
11584 +#ifdef CONFIG_VT_CONSOLE
11587 + while (kbd_read_status() & KBD_STAT_IBF);
11588 + kbd_write_command(KBD_CCMD_READ_MODE);
11590 + while (kbd_read_status() & KBD_STAT_IBF);
11591 + while ( !(kbd_read_status() & KBD_STAT_OBF) );
11592 + c = kbd_read_input();
11593 + c &= ~KBD_MODE_KBD_INT;
11594 + while (kbd_read_status() & KBD_STAT_IBF);
11595 + kbd_write_command(KBD_CCMD_WRITE_MODE);
11597 + while (kbd_read_status() & KBD_STAT_IBF);
11598 + kbd_write_output(c);
11600 + while (kbd_read_status() & KBD_STAT_IBF);
11602 +#endif /* CONFIG_VT_CONSOLE */
11605 +void kdba_local_arch_cleanup(void)
11607 +#ifdef CONFIG_VT_CONSOLE
11610 + while (kbd_read_status() & KBD_STAT_IBF);
11611 + kbd_write_command(KBD_CCMD_READ_MODE);
11613 + while (kbd_read_status() & KBD_STAT_IBF);
11614 + while ( !(kbd_read_status() & KBD_STAT_OBF) );
11615 + c = kbd_read_input();
11616 + c |= KBD_MODE_KBD_INT;
11617 + while (kbd_read_status() & KBD_STAT_IBF);
11618 + kbd_write_command(KBD_CCMD_WRITE_MODE);
11620 + while (kbd_read_status() & KBD_STAT_IBF);
11621 + kbd_write_output(c);
11623 + while (kbd_read_status() & KBD_STAT_IBF);
11625 +#endif /* CONFIG_VT_CONSOLE */
11627 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/kdbasupport.c linux-2.6.22-600/arch/x86_64/kdb/kdbasupport.c
11628 --- linux-2.6.22-590/arch/x86_64/kdb/kdbasupport.c 1970-01-01 01:00:00.000000000 +0100
11629 +++ linux-2.6.22-600/arch/x86_64/kdb/kdbasupport.c 2008-04-09 18:16:24.000000000 +0200
11632 + * Kernel Debugger Architecture Independent Support Functions
11634 + * This file is subject to the terms and conditions of the GNU General Public
11635 + * License. See the file "COPYING" in the main directory of this archive
11636 + * for more details.
11638 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
11641 +#include <linux/string.h>
11642 +#include <linux/stddef.h>
11643 +#include <linux/kernel.h>
11644 +#include <linux/init.h>
11645 +#include <linux/ptrace.h>
11646 +#include <linux/mm.h>
11647 +#include <linux/sched.h>
11648 +#include <linux/hardirq.h>
11649 +#include <linux/kdb.h>
11650 +#include <linux/kdbprivate.h>
11651 +#include <linux/interrupt.h>
11652 +#include <linux/module.h>
11653 +#include <linux/kdebug.h>
11654 +#include <asm/processor.h>
11655 +#include <asm/msr.h>
11656 +#include <asm/uaccess.h>
11657 +#include <asm/mach_apic.h>
11658 +#include <asm/hw_irq.h>
11659 +#include <asm/desc.h>
11664 + return kdba_getdr(6);
11670 + return kdba_getdr(7);
11674 +kdba_putdr6(kdb_machreg_t contents)
11676 + kdba_putdr(6, contents);
11680 +kdba_putdr7(kdb_machreg_t contents)
11682 + kdba_putdr(7, contents);
11686 +kdba_installdbreg(kdb_bp_t *bp)
11688 + kdb_machreg_t dr7;
11690 + dr7 = kdba_getdr7();
11692 + kdba_putdr(bp->bp_hard->bph_reg, bp->bp_addr);
11696 + set_in_cr4(X86_CR4_DE);
11698 + switch (bp->bp_hard->bph_reg){
11700 + DR7_RW0SET(dr7,bp->bp_hard->bph_mode);
11701 + DR7_LEN0SET(dr7,bp->bp_hard->bph_length);
11705 + DR7_RW1SET(dr7,bp->bp_hard->bph_mode);
11706 + DR7_LEN1SET(dr7,bp->bp_hard->bph_length);
11710 + DR7_RW2SET(dr7,bp->bp_hard->bph_mode);
11711 + DR7_LEN2SET(dr7,bp->bp_hard->bph_length);
11715 + DR7_RW3SET(dr7,bp->bp_hard->bph_mode);
11716 + DR7_LEN3SET(dr7,bp->bp_hard->bph_length);
11720 + kdb_printf("kdb: Bad debug register!! %ld\n",
11721 + bp->bp_hard->bph_reg);
11725 + kdba_putdr7(dr7);
11730 +kdba_removedbreg(kdb_bp_t *bp)
11733 + kdb_machreg_t dr7;
11735 + if (!bp->bp_hard)
11738 + regnum = bp->bp_hard->bph_reg;
11740 + dr7 = kdba_getdr7();
11742 + kdba_putdr(regnum, 0);
11744 + switch (regnum) {
11762 + kdb_printf("kdb: Bad debug register!! %d\n", regnum);
11766 + kdba_putdr7(dr7);
11770 +kdba_getdr(int regnum)
11772 + kdb_machreg_t contents = 0;
11775 + __asm__ ("movq %%db0,%0\n\t":"=r"(contents));
11778 + __asm__ ("movq %%db1,%0\n\t":"=r"(contents));
11781 + __asm__ ("movq %%db2,%0\n\t":"=r"(contents));
11784 + __asm__ ("movq %%db3,%0\n\t":"=r"(contents));
11790 + __asm__ ("movq %%db6,%0\n\t":"=r"(contents));
11793 + __asm__ ("movq %%db7,%0\n\t":"=r"(contents));
11804 +kdb_getcr(int regnum)
11806 + kdb_machreg_t contents = 0;
11809 + __asm__ ("movq %%cr0,%0\n\t":"=r"(contents));
11814 + __asm__ ("movq %%cr2,%0\n\t":"=r"(contents));
11817 + __asm__ ("movq %%cr3,%0\n\t":"=r"(contents));
11820 + __asm__ ("movq %%cr4,%0\n\t":"=r"(contents));
11830 +kdba_putdr(int regnum, kdb_machreg_t contents)
11834 + __asm__ ("movq %0,%%db0\n\t"::"r"(contents));
11837 + __asm__ ("movq %0,%%db1\n\t"::"r"(contents));
11840 + __asm__ ("movq %0,%%db2\n\t"::"r"(contents));
11843 + __asm__ ("movq %0,%%db3\n\t"::"r"(contents));
11849 + __asm__ ("movq %0,%%db6\n\t"::"r"(contents));
11852 + __asm__ ("movq %0,%%db7\n\t"::"r"(contents));
11860 + * kdba_getregcontents
11862 + * Return the contents of the register specified by the
11863 + * input string argument. Return an error if the string
11864 + * does not match a machine register.
11866 + * The following pseudo register names are supported:
11867 + * ®s - Prints address of exception frame
11868 + * krsp - Prints kernel stack pointer at time of fault
11869 + * crsp - Prints current kernel stack pointer, inside kdb
11870 + * ceflags - Prints current flags, inside kdb
11871 + * %<regname> - Uses the value of the registers at the
11872 + * last time the user process entered kernel
11873 + * mode, instead of the registers at the time
11874 + * kdb was entered.
11877 + * regname Pointer to string naming register
11878 + * regs Pointer to structure containing registers.
11880 + * *contents Pointer to unsigned long to recieve register contents
11883 + * KDB_BADREG Invalid register name
11887 + * If kdb was entered via an interrupt from the kernel itself then
11888 + * ss and rsp are *not* on the stack.
11891 +static struct kdbregs {
11893 + size_t reg_offset;
11894 +} kdbreglist[] = {
11895 + { "r15", offsetof(struct pt_regs, r15) },
11896 + { "r14", offsetof(struct pt_regs, r14) },
11897 + { "r13", offsetof(struct pt_regs, r13) },
11898 + { "r12", offsetof(struct pt_regs, r12) },
11899 + { "rbp", offsetof(struct pt_regs, rbp) },
11900 + { "rbx", offsetof(struct pt_regs, rbx) },
11901 + { "r11", offsetof(struct pt_regs, r11) },
11902 + { "r10", offsetof(struct pt_regs, r10) },
11903 + { "r9", offsetof(struct pt_regs, r9) },
11904 + { "r8", offsetof(struct pt_regs, r8) },
11905 + { "rax", offsetof(struct pt_regs, rax) },
11906 + { "rcx", offsetof(struct pt_regs, rcx) },
11907 + { "rdx", offsetof(struct pt_regs, rdx) },
11908 + { "rsi", offsetof(struct pt_regs, rsi) },
11909 + { "rdi", offsetof(struct pt_regs, rdi) },
11910 + { "orig_rax", offsetof(struct pt_regs, orig_rax) },
11911 + { "rip", offsetof(struct pt_regs, rip) },
11912 + { "cs", offsetof(struct pt_regs, cs) },
11913 + { "eflags", offsetof(struct pt_regs, eflags) },
11914 + { "rsp", offsetof(struct pt_regs, rsp) },
11915 + { "ss", offsetof(struct pt_regs, ss) },
11918 +static const int nkdbreglist = sizeof(kdbreglist) / sizeof(struct kdbregs);
11920 +static struct kdbregs dbreglist[] = {
11929 +static const int ndbreglist = sizeof(dbreglist) / sizeof(struct kdbregs);
11932 +kdba_getregcontents(const char *regname,
11933 + struct pt_regs *regs,
11934 + kdb_machreg_t *contents)
11938 + if (strcmp(regname, "®s") == 0) {
11939 + *contents = (unsigned long)regs;
11943 + if (strcmp(regname, "krsp") == 0) {
11944 + *contents = (unsigned long)regs + sizeof(struct pt_regs);
11945 + if ((regs->cs & 0xffff) == __KERNEL_CS) {
11946 + /* rsp and ss are not on stack */
11947 + *contents -= 2*4;
11952 + if (strcmp(regname, "crsp") == 0) {
11953 + asm volatile("movq %%rsp,%0":"=m" (*contents));
11957 + if (strcmp(regname, "ceflags") == 0) {
11958 + unsigned long flags;
11959 + local_save_flags(flags);
11960 + *contents = flags;
11964 + if (regname[0] == '%') {
11965 + /* User registers: %%r[a-c]x, etc */
11967 + regs = (struct pt_regs *)
11968 + (current->thread.rsp0 - sizeof(struct pt_regs));
11971 + for (i=0; i<nkdbreglist; i++) {
11972 + if (strnicmp(kdbreglist[i].reg_name,
11974 + strlen(regname)) == 0)
11978 + if ((i < nkdbreglist)
11979 + && (strlen(kdbreglist[i].reg_name) == strlen(regname))) {
11980 + if ((regs->cs & 0xffff) == __KERNEL_CS) {
11981 + /* No cpl switch, rsp is not on stack */
11982 + if (strcmp(kdbreglist[i].reg_name, "rsp") == 0) {
11983 + *contents = (kdb_machreg_t)regs +
11984 + sizeof(struct pt_regs) - 2*8;
11988 + if (strcmp(kdbreglist[i].reg_name, "ss") == 0) {
11991 + r = (kdb_machreg_t)regs +
11992 + sizeof(struct pt_regs) - 2*8;
11993 + *contents = (kdb_machreg_t)SS(r); /* XXX */
11998 + *contents = *(unsigned long *)((unsigned long)regs +
11999 + kdbreglist[i].reg_offset);
12003 + for (i=0; i<ndbreglist; i++) {
12004 + if (strnicmp(dbreglist[i].reg_name,
12006 + strlen(regname)) == 0)
12010 + if ((i < ndbreglist)
12011 + && (strlen(dbreglist[i].reg_name) == strlen(regname))) {
12012 + *contents = kdba_getdr(dbreglist[i].reg_offset);
12015 + return KDB_BADREG;
12019 + * kdba_setregcontents
12021 + * Set the contents of the register specified by the
12022 + * input string argument. Return an error if the string
12023 + * does not match a machine register.
12025 + * Supports modification of user-mode registers via
12026 + * %<register-name>
12029 + * regname Pointer to string naming register
12030 + * regs Pointer to structure containing registers.
12031 + * contents Unsigned long containing new register contents
12035 + * KDB_BADREG Invalid register name
12042 +kdba_setregcontents(const char *regname,
12043 + struct pt_regs *regs,
12044 + unsigned long contents)
12048 + if (regname[0] == '%') {
12050 + regs = (struct pt_regs *)
12051 + (current->thread.rsp0 - sizeof(struct pt_regs));
12054 + for (i=0; i<nkdbreglist; i++) {
12055 + if (strnicmp(kdbreglist[i].reg_name,
12057 + strlen(regname)) == 0)
12061 + if ((i < nkdbreglist)
12062 + && (strlen(kdbreglist[i].reg_name) == strlen(regname))) {
12063 + *(unsigned long *)((unsigned long)regs
12064 + + kdbreglist[i].reg_offset) = contents;
12068 + for (i=0; i<ndbreglist; i++) {
12069 + if (strnicmp(dbreglist[i].reg_name,
12071 + strlen(regname)) == 0)
12075 + if ((i < ndbreglist)
12076 + && (strlen(dbreglist[i].reg_name) == strlen(regname))) {
12077 + kdba_putdr(dbreglist[i].reg_offset, contents);
12081 + return KDB_BADREG;
12087 + * Dump the specified register set to the display.
12090 + * regs Pointer to structure containing registers.
12091 + * type Character string identifying register set to dump
12092 + * extra string further identifying register (optional)
12099 + * This function will dump the general register set if the type
12100 + * argument is NULL (struct pt_regs). The alternate register
12101 + * set types supported by this function:
12103 + * d Debug registers
12104 + * c Control registers
12105 + * u User registers at most recent entry to kernel
12106 + * Following not yet implemented:
12107 + * r Memory Type Range Registers (extra defines register)
12109 + * MSR on i386/x86_64 are handled by rdmsr/wrmsr commands.
12113 +kdba_dumpregs(struct pt_regs *regs,
12114 + const char *type,
12115 + const char *extra)
12121 + && (type[0] == 'u')) {
12123 + regs = (struct pt_regs *)
12124 + (current->thread.rsp0 - sizeof(struct pt_regs));
12127 + if (type == NULL) {
12128 + struct kdbregs *rlp;
12129 + kdb_machreg_t contents;
12131 + for (i=0, rlp=kdbreglist; i<nkdbreglist; i++,rlp++) {
12132 + kdb_printf("%8s = ", rlp->reg_name);
12133 + kdba_getregcontents(rlp->reg_name, regs, &contents);
12134 + kdb_printf("0x%016lx ", contents);
12135 + if ((++count % 2) == 0)
12136 + kdb_printf("\n");
12139 + kdb_printf("®s = 0x%p\n", regs);
12144 + switch (type[0]) {
12147 + unsigned long dr[8];
12149 + for(i=0; i<8; i++) {
12150 + if ((i == 4) || (i == 5)) continue;
12151 + dr[i] = kdba_getdr(i);
12153 + kdb_printf("dr0 = 0x%08lx dr1 = 0x%08lx dr2 = 0x%08lx dr3 = 0x%08lx\n",
12154 + dr[0], dr[1], dr[2], dr[3]);
12155 + kdb_printf("dr6 = 0x%08lx dr7 = 0x%08lx\n",
12161 + unsigned long cr[5];
12163 + for (i=0; i<5; i++) {
12164 + cr[i] = kdb_getcr(i);
12166 + kdb_printf("cr0 = 0x%08lx cr1 = 0x%08lx cr2 = 0x%08lx cr3 = 0x%08lx\ncr4 = 0x%08lx\n",
12167 + cr[0], cr[1], cr[2], cr[3], cr[4]);
12173 + return KDB_BADREG;
12179 +EXPORT_SYMBOL(kdba_dumpregs);
12182 +kdba_getpc(struct pt_regs *regs)
12184 + return regs->rip;
12188 +kdba_setpc(struct pt_regs *regs, kdb_machreg_t newpc)
12190 + if (KDB_NULL_REGS(regs))
12191 + return KDB_BADREG;
12192 + regs->rip = newpc;
12193 + KDB_STATE_SET(IP_ADJUSTED);
12200 + * Do any architecture specific set up before entering the main kdb loop.
12201 + * The primary function of this routine is to make all processes look the
12202 + * same to kdb, kdb must be able to list a process without worrying if the
12203 + * process is running or blocked, so make all process look as though they
12207 + * reason The reason KDB was invoked
12208 + * error The hardware-defined error code
12209 + * error2 kdb's current reason code. Initially error but can change
12210 + * acording to kdb state.
12211 + * db_result Result from break or debug point.
12212 + * ef The exception frame at time of fault/breakpoint. If reason
12213 + * is SILENT or CPU_UP then regs is NULL, otherwise it should
12214 + * always be valid.
12216 + * 0 KDB was invoked for an event which it wasn't responsible
12217 + * 1 KDB handled the event for which it was invoked.
12219 + * Sets rip and rsp in current->thread.
12227 +kdba_main_loop(kdb_reason_t reason, kdb_reason_t reason2, int error,
12228 + kdb_dbtrap_t db_result, struct pt_regs *regs)
12233 + kdba_getregcontents("rsp", regs, &(current->thread.rsp));
12234 + kdb_save_running(regs);
12235 + ret = kdb_main_loop(reason, reason2, error, db_result, regs);
12236 + kdb_unsave_running(regs);
12241 +kdba_disableint(kdb_intstate_t *state)
12243 + unsigned long *fp = (unsigned long *)state;
12244 + unsigned long flags;
12246 + local_irq_save(flags);
12251 +kdba_restoreint(kdb_intstate_t *state)
12253 + unsigned long flags = *(unsigned long *)state;
12254 + local_irq_restore(flags);
12258 +kdba_setsinglestep(struct pt_regs *regs)
12260 + if (KDB_NULL_REGS(regs))
12262 + if (regs->eflags & EF_IE)
12263 + KDB_STATE_SET(A_IF);
12265 + KDB_STATE_CLEAR(A_IF);
12266 + regs->eflags = (regs->eflags | EF_TF) & ~EF_IE;
12270 +kdba_clearsinglestep(struct pt_regs *regs)
12272 + if (KDB_NULL_REGS(regs))
12274 + if (KDB_STATE(A_IF))
12275 + regs->eflags |= EF_IE;
12277 + regs->eflags &= ~EF_IE;
12281 +kdba_setjmp(kdb_jmp_buf *jb)
12283 +#ifdef CONFIG_FRAME_POINTER
12284 + __asm__ __volatile__
12285 + ("movq %%rbx, (0*8)(%%rdi);"
12286 + "movq %%rcx, (1*8)(%%rdi);"
12287 + "movq %%r12, (2*8)(%%rdi);"
12288 + "movq %%r13, (3*8)(%%rdi);"
12289 + "movq %%r14, (4*8)(%%rdi);"
12290 + "movq %%r15, (5*8)(%%rdi);"
12291 + "leaq 16(%%rsp), %%rdx;"
12292 + "movq %%rdx, (6*8)(%%rdi);"
12293 + "movq %%rax, (7*8)(%%rdi)"
12295 + : "a" (__builtin_return_address(0)),
12296 + "c" (__builtin_frame_address(1))
12298 +#else /* !CONFIG_FRAME_POINTER */
12299 + __asm__ __volatile__
12300 + ("movq %%rbx, (0*8)(%%rdi);"
12301 + "movq %%rbp, (1*8)(%%rdi);"
12302 + "movq %%r12, (2*8)(%%rdi);"
12303 + "movq %%r13, (3*8)(%%rdi);"
12304 + "movq %%r14, (4*8)(%%rdi);"
12305 + "movq %%r15, (5*8)(%%rdi);"
12306 + "leaq 8(%%rsp), %%rdx;"
12307 + "movq %%rdx, (6*8)(%%rdi);"
12308 + "movq %%rax, (7*8)(%%rdi)"
12310 + : "a" (__builtin_return_address(0))
12312 +#endif /* CONFIG_FRAME_POINTER */
12317 +kdba_longjmp(kdb_jmp_buf *jb, int reason)
12319 + __asm__("movq (0*8)(%rdi),%rbx;"
12320 + "movq (1*8)(%rdi),%rbp;"
12321 + "movq (2*8)(%rdi),%r12;"
12322 + "movq (3*8)(%rdi),%r13;"
12323 + "movq (4*8)(%rdi),%r14;"
12324 + "movq (5*8)(%rdi),%r15;"
12325 + "movq (7*8)(%rdi),%rdx;"
12326 + "movq (6*8)(%rdi),%rsp;"
12327 + "mov %rsi, %rax;"
12334 + * Format a struct pt_regs
12337 + * argc argument count
12338 + * argv argument vector
12342 + * zero for success, a kdb diagnostic if error
12346 + * If no address is supplied, it uses the current irq pt_regs.
12350 +kdba_pt_regs(int argc, const char **argv)
12353 + kdb_machreg_t addr;
12356 + struct pt_regs *p;
12357 + static const char *fmt = " %-11.11s 0x%lx\n";
12358 + static int first_time = 1;
12361 + addr = (kdb_machreg_t) get_irq_regs();
12362 + } else if (argc == 1) {
12364 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
12368 + return KDB_ARGCOUNT;
12371 + p = (struct pt_regs *) addr;
12372 + if (first_time) {
12374 + kdb_printf("\n+++ Warning: x86_64 pt_regs are not always "
12375 + "completely defined, r15-rbx may be invalid\n\n");
12377 + kdb_printf("struct pt_regs 0x%p-0x%p\n", p, (unsigned char *)p + sizeof(*p) - 1);
12378 + kdb_print_nameval("r15", p->r15);
12379 + kdb_print_nameval("r14", p->r14);
12380 + kdb_print_nameval("r13", p->r13);
12381 + kdb_print_nameval("r12", p->r12);
12382 + kdb_print_nameval("rbp", p->rbp);
12383 + kdb_print_nameval("rbx", p->rbx);
12384 + kdb_print_nameval("r11", p->r11);
12385 + kdb_print_nameval("r10", p->r10);
12386 + kdb_print_nameval("r9", p->r9);
12387 + kdb_print_nameval("r8", p->r8);
12388 + kdb_print_nameval("rax", p->rax);
12389 + kdb_print_nameval("rcx", p->rcx);
12390 + kdb_print_nameval("rdx", p->rdx);
12391 + kdb_print_nameval("rsi", p->rsi);
12392 + kdb_print_nameval("rdi", p->rdi);
12393 + kdb_print_nameval("orig_rax", p->orig_rax);
12394 + kdb_print_nameval("rip", p->rip);
12395 + kdb_printf(fmt, "cs", p->cs);
12396 + kdb_printf(fmt, "eflags", p->eflags);
12397 + kdb_printf(fmt, "rsp", p->rsp);
12398 + kdb_printf(fmt, "ss", p->ss);
12405 + * Format a struct cpu_pda
12408 + * argc argument count
12409 + * argv argument vector
12413 + * zero for success, a kdb diagnostic if error
12417 + * If no cpu is supplied, it prints the current cpu. If the cpu is '*'
12418 + * then it prints all cpus.
12422 +kdba_cpu_pda(int argc, const char **argv)
12424 + int diag, nextarg, all_cpus = 0;
12426 + unsigned long cpu;
12427 + struct x8664_pda *c;
12428 + static const char *fmtl = " %-17.17s 0x%lx\n";
12429 + static const char *fmtd = " %-17.17s %d\n";
12430 + static const char *fmtp = " %-17.17s 0x%p\n";
12433 + cpu = smp_processor_id();
12434 + } else if (argc == 1) {
12435 + if (strcmp(argv[1], "*") == 0) {
12440 + diag = kdbgetaddrarg(argc, argv, &nextarg, &cpu, &offset, NULL);
12445 + return KDB_ARGCOUNT;
12448 + for (; cpu < NR_CPUS; ++cpu) {
12449 + if (cpu_online(cpu)) {
12450 + c = cpu_pda(cpu);
12451 + kdb_printf("struct cpu_pda 0x%p-0x%p\n", c, (unsigned char *)c + sizeof(*c) - 1);
12452 + kdb_printf(fmtp, "pcurrent", c->pcurrent);
12453 + kdb_printf(fmtl, "data_offset", c->data_offset);
12454 + kdb_printf(fmtl, "kernelstack", c->kernelstack);
12455 + kdb_printf(fmtl, "oldrsp", c->oldrsp);
12456 + kdb_printf(fmtd, "irqcount", c->irqcount);
12457 + kdb_printf(fmtd, "cpunumber", c->cpunumber);
12458 + kdb_printf(fmtp, "irqstackptr", c->irqstackptr);
12459 + kdb_printf(fmtd, "nodenumber", c->nodenumber);
12460 + kdb_printf(fmtd, "__softirq_pending", c->__softirq_pending);
12461 + kdb_printf(fmtd, "__nmi_count", c->__nmi_count);
12462 + kdb_printf(fmtd, "mmu_state", c->mmu_state);
12463 + kdb_printf(fmtp, "active_mm", c->active_mm);
12464 + kdb_printf(fmtd, "apic_timer_irqs", c->apic_timer_irqs);
12475 + * This is the interface routine between
12476 + * the notifier die_chain and kdb
12478 +static int kdba_entry( struct notifier_block *b, unsigned long val, void *v)
12480 + struct die_args *args = v;
12481 + int err, trap, ret = 0;
12482 + struct pt_regs *regs;
12484 + regs = args->regs;
12486 + trap = args->trapnr;
12489 + case DIE_NMI_IPI:
12490 + ret = kdb_ipi(regs, NULL);
12492 +#endif /* CONFIG_SMP */
12494 + ret = kdb(KDB_REASON_OOPS, err, regs);
12497 + ret = kdb(KDB_REASON_ENTER, err, regs);
12500 + ret = kdb(KDB_REASON_DEBUG, err, regs);
12502 + case DIE_NMIWATCHDOG:
12503 + ret = kdb(KDB_REASON_NMI, err, regs);
12506 + ret = kdb(KDB_REASON_BREAK, err, regs);
12511 + return (ret ? NOTIFY_STOP : NOTIFY_DONE);
12515 + * notifier block for kdb entry
12517 +static struct notifier_block kdba_notifier = {
12518 + .notifier_call = kdba_entry
12521 +asmlinkage int kdb_call(void);
12523 +/* Executed once on each cpu at startup. */
12530 +kdba_arch_init(void)
12533 + set_intr_gate(KDB_VECTOR, kdb_interrupt);
12535 + set_intr_gate(KDBENTER_VECTOR, kdb_call);
12539 +arch_initcall(kdba_arch_init);
12544 + * Architecture specific initialization.
12559 + kdba_arch_init(); /* Need to register KDBENTER_VECTOR early */
12560 + kdb_register("pt_regs", kdba_pt_regs, "address", "Format struct pt_regs", 0);
12561 + kdb_register("cpu_pda", kdba_cpu_pda, "<cpu>", "Format struct cpu_pda", 0);
12562 + register_die_notifier(&kdba_notifier);
12569 + * Architecture specific adjustment of instruction pointer before leaving
12573 + * reason The reason KDB was invoked
12574 + * error The hardware-defined error code
12575 + * ef The exception frame at time of fault/breakpoint. If reason
12576 + * is SILENT or CPU_UP then regs is NULL, otherwise it should
12577 + * always be valid.
12587 +kdba_adjust_ip(kdb_reason_t reason, int error, struct pt_regs *ef)
12593 +kdba_set_current_task(const struct task_struct *p)
12595 + kdb_current_task = p;
12596 + if (kdb_task_has_cpu(p)) {
12597 + struct kdb_running_process *krp = kdb_running_process + kdb_process_cpu(p);
12598 + kdb_current_regs = krp->regs;
12601 + kdb_current_regs = NULL;
12606 +/* When first entering KDB, try a normal IPI. That reduces backtrace problems
12607 + * on the other cpus.
12610 +smp_kdb_stop(void)
12612 + if (!KDB_FLAG(NOIPI))
12613 + send_IPI_allbutself(KDB_VECTOR);
12616 +/* The normal KDB IPI handler */
12617 +extern asmlinkage void smp_kdb_interrupt(struct pt_regs *regs); /* for sparse */
12619 +smp_kdb_interrupt(struct pt_regs *regs)
12621 + struct pt_regs *old_regs = set_irq_regs(regs);
12624 + kdb_ipi(regs, NULL);
12626 + set_irq_regs(old_regs);
12629 +/* Invoked once from kdb_wait_for_cpus when waiting for cpus. For those cpus
12630 + * that have not responded to the normal KDB interrupt yet, hit them with an
12634 +kdba_wait_for_cpus(void)
12637 + if (KDB_FLAG(CATASTROPHIC))
12639 + kdb_printf(" Sending NMI to cpus that have not responded yet\n");
12640 + for_each_online_cpu(c)
12641 + if (kdb_running_process[c].seqno < kdb_seqno - 1)
12642 + send_IPI_mask(cpumask_of_cpu(c), NMI_VECTOR);
12645 +#endif /* CONFIG_SMP */
12646 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/kdb_cmds linux-2.6.22-600/arch/x86_64/kdb/kdb_cmds
12647 --- linux-2.6.22-590/arch/x86_64/kdb/kdb_cmds 1970-01-01 01:00:00.000000000 +0100
12648 +++ linux-2.6.22-600/arch/x86_64/kdb/kdb_cmds 2008-04-09 18:16:24.000000000 +0200
12650 +# Standard architecture specific commands for kdb.
12651 +# These commands are appended to those in kdb/kdb_cmds, see that file for
12654 +# Standard debugging information for first level support, invoked from archkdb*
12655 +# commands that are defined in kdb/kdb_cmds.
12657 +defcmd archkdbcommon "" "Common arch debugging"
12658 + set LINES 2000000
12668 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/Makefile linux-2.6.22-600/arch/x86_64/kdb/Makefile
12669 --- linux-2.6.22-590/arch/x86_64/kdb/Makefile 1970-01-01 01:00:00.000000000 +0100
12670 +++ linux-2.6.22-600/arch/x86_64/kdb/Makefile 2008-04-09 18:16:24.000000000 +0200
12673 +# This file is subject to the terms and conditions of the GNU General Public
12674 +# License. See the file "COPYING" in the main directory of this archive
12675 +# for more details.
12677 +# Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
12680 +obj-$(CONFIG_KDB) := kdba_bp.o kdba_id.o kdba_io.o kdbasupport.o x86_64-dis.o
12682 +override CFLAGS := $(CFLAGS:%-pg=% )
12684 +CFLAGS_kdba_io.o += -I $(TOPDIR)/arch/$(ARCH)/kdb
12685 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/pc_keyb.h linux-2.6.22-600/arch/x86_64/kdb/pc_keyb.h
12686 --- linux-2.6.22-590/arch/x86_64/kdb/pc_keyb.h 1970-01-01 01:00:00.000000000 +0100
12687 +++ linux-2.6.22-600/arch/x86_64/kdb/pc_keyb.h 2008-04-09 18:16:24.000000000 +0200
12690 + * include/linux/pc_keyb.h
12692 + * PC Keyboard And Keyboard Controller
12694 + * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
12698 + * Configuration Switches
12701 +#undef KBD_REPORT_ERR /* Report keyboard errors */
12702 +#define KBD_REPORT_UNKN /* Report unknown scan codes */
12703 +#define KBD_REPORT_TIMEOUTS /* Report keyboard timeouts */
12704 +#undef KBD_IS_FOCUS_9000 /* We have the brain-damaged FOCUS-9000 keyboard */
12705 +#undef INITIALIZE_MOUSE /* Define if your PS/2 mouse needs initialization. */
12709 +#define KBD_INIT_TIMEOUT 1000 /* Timeout in ms for initializing the keyboard */
12710 +#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */
12711 +#define KBD_TIMEOUT 1000 /* Timeout in ms for keyboard command acknowledge */
12714 + * Internal variables of the driver
12717 +extern unsigned char pckbd_read_mask;
12718 +extern unsigned char aux_device_present;
12721 + * Keyboard Controller Registers on normal PCs.
12724 +#define KBD_STATUS_REG 0x64 /* Status register (R) */
12725 +#define KBD_CNTL_REG 0x64 /* Controller command register (W) */
12726 +#define KBD_DATA_REG 0x60 /* Keyboard data register (R/W) */
12729 + * Keyboard Controller Commands
12732 +#define KBD_CCMD_READ_MODE 0x20 /* Read mode bits */
12733 +#define KBD_CCMD_WRITE_MODE 0x60 /* Write mode bits */
12734 +#define KBD_CCMD_GET_VERSION 0xA1 /* Get controller version */
12735 +#define KBD_CCMD_MOUSE_DISABLE 0xA7 /* Disable mouse interface */
12736 +#define KBD_CCMD_MOUSE_ENABLE 0xA8 /* Enable mouse interface */
12737 +#define KBD_CCMD_TEST_MOUSE 0xA9 /* Mouse interface test */
12738 +#define KBD_CCMD_SELF_TEST 0xAA /* Controller self test */
12739 +#define KBD_CCMD_KBD_TEST 0xAB /* Keyboard interface test */
12740 +#define KBD_CCMD_KBD_DISABLE 0xAD /* Keyboard interface disable */
12741 +#define KBD_CCMD_KBD_ENABLE 0xAE /* Keyboard interface enable */
12742 +#define KBD_CCMD_WRITE_AUX_OBUF 0xD3 /* Write to output buffer as if
12743 + initiated by the auxiliary device */
12744 +#define KBD_CCMD_WRITE_MOUSE 0xD4 /* Write the following byte to the mouse */
12747 + * Keyboard Commands
12750 +#define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */
12751 +#define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */
12752 +#define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
12753 +#define KBD_CMD_DISABLE 0xF5 /* Disable scanning */
12754 +#define KBD_CMD_RESET 0xFF /* Reset */
12757 + * Keyboard Replies
12760 +#define KBD_REPLY_POR 0xAA /* Power on reset */
12761 +#define KBD_REPLY_ACK 0xFA /* Command ACK */
12762 +#define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */
12765 + * Status Register Bits
12768 +#define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */
12769 +#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
12770 +#define KBD_STAT_SELFTEST 0x04 /* Self test successful */
12771 +#define KBD_STAT_CMD 0x08 /* Last write was a command write (0=data) */
12772 +#define KBD_STAT_UNLOCKED 0x10 /* Zero if keyboard locked */
12773 +#define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */
12774 +#define KBD_STAT_GTO 0x40 /* General receive/xmit timeout */
12775 +#define KBD_STAT_PERR 0x80 /* Parity error */
12777 +#define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
12780 + * Controller Mode Register Bits
12783 +#define KBD_MODE_KBD_INT 0x01 /* Keyboard data generate IRQ1 */
12784 +#define KBD_MODE_MOUSE_INT 0x02 /* Mouse data generate IRQ12 */
12785 +#define KBD_MODE_SYS 0x04 /* The system flag (?) */
12786 +#define KBD_MODE_NO_KEYLOCK 0x08 /* The keylock doesn't affect the keyboard if set */
12787 +#define KBD_MODE_DISABLE_KBD 0x10 /* Disable keyboard interface */
12788 +#define KBD_MODE_DISABLE_MOUSE 0x20 /* Disable mouse interface */
12789 +#define KBD_MODE_KCC 0x40 /* Scan code conversion to PC format */
12790 +#define KBD_MODE_RFU 0x80
12796 +#define AUX_SET_RES 0xE8 /* Set resolution */
12797 +#define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */
12798 +#define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */
12799 +#define AUX_GET_SCALE 0xE9 /* Get scaling factor */
12800 +#define AUX_SET_STREAM 0xEA /* Set stream mode */
12801 +#define AUX_SET_SAMPLE 0xF3 /* Set sample rate */
12802 +#define AUX_ENABLE_DEV 0xF4 /* Enable aux device */
12803 +#define AUX_DISABLE_DEV 0xF5 /* Disable aux device */
12804 +#define AUX_RESET 0xFF /* Reset aux device */
12805 +#define AUX_ACK 0xFA /* Command byte ACK. */
12807 +#define AUX_BUF_SIZE 2048 /* This might be better divisible by
12808 + three to make overruns stay in sync
12809 + but then the read function would need
12810 + a lock etc - ick */
12812 +struct aux_queue {
12813 + unsigned long head;
12814 + unsigned long tail;
12815 + wait_queue_head_t proc_list;
12816 + struct fasync_struct *fasync;
12817 + unsigned char buf[AUX_BUF_SIZE];
12821 +/* How to access the keyboard macros on this platform. */
12822 +#define kbd_read_input() inb(KBD_DATA_REG)
12823 +#define kbd_read_status() inb(KBD_STATUS_REG)
12824 +#define kbd_write_output(val) outb(val, KBD_DATA_REG)
12825 +#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
12826 diff -Nurp linux-2.6.22-590/arch/x86_64/kdb/x86_64-dis.c linux-2.6.22-600/arch/x86_64/kdb/x86_64-dis.c
12827 --- linux-2.6.22-590/arch/x86_64/kdb/x86_64-dis.c 1970-01-01 01:00:00.000000000 +0100
12828 +++ linux-2.6.22-600/arch/x86_64/kdb/x86_64-dis.c 2008-04-09 18:16:24.000000000 +0200
12830 +/* Print i386 instructions for GDB, the GNU debugger.
12831 + Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
12832 + 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
12834 + This file is part of GDB.
12836 + This program is free software; you can redistribute it and/or modify
12837 + it under the terms of the GNU General Public License as published by
12838 + the Free Software Foundation; either version 2 of the License, or
12839 + (at your option) any later version.
12841 + This program is distributed in the hope that it will be useful,
12842 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12843 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12844 + GNU General Public License for more details.
12846 + You should have received a copy of the GNU General Public License
12847 + along with this program; if not, write to the Free Software
12848 + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
12850 +/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
12851 + * Run through col -b to remove trailing whitespace and various #ifdef/ifndef
12852 + * __KERNEL__ added.
12853 + * Keith Owens <kaos@sgi.com> 15 May 2006
12856 +/* 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
12858 + modified by John Hassey (hassey@dg-rtp.dg.com)
12859 + x86-64 support added by Jan Hubicka (jh@suse.cz)
12860 + VIA PadLock support by Michal Ludvig (mludvig@suse.cz). */
12862 +/* The main tables describing the instructions is essentially a copy
12863 + of the "Opcode Map" chapter (Appendix A) of the Intel 80386
12864 + Programmers Manual. Usually, there is a capital letter, followed
12865 + by a small letter. The capital letter tell the addressing mode,
12866 + and the small letter tells about the operand size. Refer to
12867 + the Intel manual for details. */
12870 +#include <linux/kernel.h>
12871 +#include <linux/string.h>
12872 +#include <linux/dis-asm.h>
12873 +#include <linux/kdb.h>
12874 +#define abort() BUG()
12875 +#else /* __KERNEL__ */
12876 +#include "dis-asm.h"
12877 +#include "sysdep.h"
12878 +#include "opintl.h"
12879 +#endif /* __KERNEL__ */
12883 +#ifndef __KERNEL__
12884 +#include <setjmp.h>
12885 +#endif /* __KERNEL__ */
12887 +#ifndef UNIXWARE_COMPAT
12888 +/* Set non-zero for broken, compatible instructions. Set to zero for
12889 + non-broken opcodes. */
12890 +#define UNIXWARE_COMPAT 1
12893 +static int fetch_data (struct disassemble_info *, bfd_byte *);
12894 +static void ckprefix (void);
12895 +static const char *prefix_name (int, int);
12896 +static int print_insn (bfd_vma, disassemble_info *);
12897 +static void dofloat (int);
12898 +static void OP_ST (int, int);
12899 +static void OP_STi (int, int);
12900 +static int putop (const char *, int);
12901 +static void oappend (const char *);
12902 +static void append_seg (void);
12903 +static void OP_indirE (int, int);
12904 +static void print_operand_value (char *, int, bfd_vma);
12905 +static void OP_E (int, int);
12906 +static void OP_G (int, int);
12907 +static bfd_vma get64 (void);
12908 +static bfd_signed_vma get32 (void);
12909 +static bfd_signed_vma get32s (void);
12910 +static int get16 (void);
12911 +static void set_op (bfd_vma, int);
12912 +static void OP_REG (int, int);
12913 +static void OP_IMREG (int, int);
12914 +static void OP_I (int, int);
12915 +static void OP_I64 (int, int);
12916 +static void OP_sI (int, int);
12917 +static void OP_J (int, int);
12918 +static void OP_SEG (int, int);
12919 +static void OP_DIR (int, int);
12920 +static void OP_OFF (int, int);
12921 +static void OP_OFF64 (int, int);
12922 +static void ptr_reg (int, int);
12923 +static void OP_ESreg (int, int);
12924 +static void OP_DSreg (int, int);
12925 +static void OP_C (int, int);
12926 +static void OP_D (int, int);
12927 +static void OP_T (int, int);
12928 +static void OP_Rd (int, int);
12929 +static void OP_MMX (int, int);
12930 +static void OP_XMM (int, int);
12931 +static void OP_EM (int, int);
12932 +static void OP_EX (int, int);
12933 +static void OP_MS (int, int);
12934 +static void OP_XS (int, int);
12935 +static void OP_M (int, int);
12936 +static void OP_VMX (int, int);
12937 +static void OP_0fae (int, int);
12938 +static void OP_0f07 (int, int);
12939 +static void NOP_Fixup (int, int);
12940 +static void OP_3DNowSuffix (int, int);
12941 +static void OP_SIMD_Suffix (int, int);
12942 +static void SIMD_Fixup (int, int);
12943 +static void PNI_Fixup (int, int);
12944 +static void SVME_Fixup (int, int);
12945 +static void INVLPG_Fixup (int, int);
12946 +static void BadOp (void);
12947 +static void SEG_Fixup (int, int);
12948 +static void VMX_Fixup (int, int);
12950 +struct dis_private {
12951 + /* Points to first byte not fetched. */
12952 + bfd_byte *max_fetched;
12953 + bfd_byte the_buffer[MAXLEN];
12954 + bfd_vma insn_start;
12955 + int orig_sizeflag;
12956 +#ifndef __KERNEL__
12958 +#endif /* __KERNEL__ */
12961 +/* The opcode for the fwait instruction, which we treat as a prefix
12963 +#define FWAIT_OPCODE (0x9b)
12965 +/* Set to 1 for 64bit mode disassembly. */
12966 +static int mode_64bit;
12968 +/* Flags for the prefixes for the current instruction. See below. */
12969 +static int prefixes;
12971 +/* REX prefix the current instruction. See below. */
12973 +/* Bits of REX we've already used. */
12974 +static int rex_used;
12975 +#define REX_MODE64 8
12976 +#define REX_EXTX 4
12977 +#define REX_EXTY 2
12978 +#define REX_EXTZ 1
12979 +/* Mark parts used in the REX prefix. When we are testing for
12980 + empty prefix (for 8bit register REX extension), just mask it
12981 + out. Otherwise test for REX bit is excuse for existence of REX
12982 + only in case value is nonzero. */
12983 +#define USED_REX(value) \
12986 + rex_used |= (rex & value) ? (value) | 0x40 : 0; \
12988 + rex_used |= 0x40; \
12991 +/* Flags for prefixes which we somehow handled when printing the
12992 + current instruction. */
12993 +static int used_prefixes;
12995 +/* Flags stored in PREFIXES. */
12996 +#define PREFIX_REPZ 1
12997 +#define PREFIX_REPNZ 2
12998 +#define PREFIX_LOCK 4
12999 +#define PREFIX_CS 8
13000 +#define PREFIX_SS 0x10
13001 +#define PREFIX_DS 0x20
13002 +#define PREFIX_ES 0x40
13003 +#define PREFIX_FS 0x80
13004 +#define PREFIX_GS 0x100
13005 +#define PREFIX_DATA 0x200
13006 +#define PREFIX_ADDR 0x400
13007 +#define PREFIX_FWAIT 0x800
13009 +/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
13010 + to ADDR (exclusive) are valid. Returns 1 for success, longjmps
13012 +#define FETCH_DATA(info, addr) \
13013 + ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \
13014 + ? 1 : fetch_data ((info), (addr)))
13017 +fetch_data (struct disassemble_info *info, bfd_byte *addr)
13020 + struct dis_private *priv = (struct dis_private *) info->private_data;
13021 + bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
13023 + status = (*info->read_memory_func) (start,
13024 + priv->max_fetched,
13025 + addr - priv->max_fetched,
13029 + /* If we did manage to read at least one byte, then
13030 + print_insn_i386 will do something sensible. Otherwise, print
13031 + an error. We do that here because this is where we know
13033 + if (priv->max_fetched == priv->the_buffer)
13034 + (*info->memory_error_func) (status, start, info);
13035 +#ifndef __KERNEL__
13036 + longjmp (priv->bailout, 1);
13037 +#else /* __KERNEL__ */
13038 + /* XXX - what to do? */
13039 + kdb_printf("Hmm. longjmp.\n");
13040 +#endif /* __KERNEL__ */
13043 + priv->max_fetched = addr;
13047 +#define XX NULL, 0
13049 +#define Eb OP_E, b_mode
13050 +#define Ev OP_E, v_mode
13051 +#define Ed OP_E, d_mode
13052 +#define Eq OP_E, q_mode
13053 +#define Edq OP_E, dq_mode
13054 +#define Edqw OP_E, dqw_mode
13055 +#define indirEv OP_indirE, branch_v_mode
13056 +#define indirEp OP_indirE, f_mode
13057 +#define Em OP_E, m_mode
13058 +#define Ew OP_E, w_mode
13059 +#define Ma OP_E, v_mode
13060 +#define M OP_M, 0 /* lea, lgdt, etc. */
13061 +#define Mp OP_M, f_mode /* 32 or 48 bit memory operand for LDS, LES etc */
13062 +#define Gb OP_G, b_mode
13063 +#define Gv OP_G, v_mode
13064 +#define Gd OP_G, d_mode
13065 +#define Gdq OP_G, dq_mode
13066 +#define Gm OP_G, m_mode
13067 +#define Gw OP_G, w_mode
13068 +#define Rd OP_Rd, d_mode
13069 +#define Rm OP_Rd, m_mode
13070 +#define Ib OP_I, b_mode
13071 +#define sIb OP_sI, b_mode /* sign extened byte */
13072 +#define Iv OP_I, v_mode
13073 +#define Iq OP_I, q_mode
13074 +#define Iv64 OP_I64, v_mode
13075 +#define Iw OP_I, w_mode
13076 +#define I1 OP_I, const_1_mode
13077 +#define Jb OP_J, b_mode
13078 +#define Jv OP_J, v_mode
13079 +#define Cm OP_C, m_mode
13080 +#define Dm OP_D, m_mode
13081 +#define Td OP_T, d_mode
13082 +#define Sv SEG_Fixup, v_mode
13084 +#define RMeAX OP_REG, eAX_reg
13085 +#define RMeBX OP_REG, eBX_reg
13086 +#define RMeCX OP_REG, eCX_reg
13087 +#define RMeDX OP_REG, eDX_reg
13088 +#define RMeSP OP_REG, eSP_reg
13089 +#define RMeBP OP_REG, eBP_reg
13090 +#define RMeSI OP_REG, eSI_reg
13091 +#define RMeDI OP_REG, eDI_reg
13092 +#define RMrAX OP_REG, rAX_reg
13093 +#define RMrBX OP_REG, rBX_reg
13094 +#define RMrCX OP_REG, rCX_reg
13095 +#define RMrDX OP_REG, rDX_reg
13096 +#define RMrSP OP_REG, rSP_reg
13097 +#define RMrBP OP_REG, rBP_reg
13098 +#define RMrSI OP_REG, rSI_reg
13099 +#define RMrDI OP_REG, rDI_reg
13100 +#define RMAL OP_REG, al_reg
13101 +#define RMAL OP_REG, al_reg
13102 +#define RMCL OP_REG, cl_reg
13103 +#define RMDL OP_REG, dl_reg
13104 +#define RMBL OP_REG, bl_reg
13105 +#define RMAH OP_REG, ah_reg
13106 +#define RMCH OP_REG, ch_reg
13107 +#define RMDH OP_REG, dh_reg
13108 +#define RMBH OP_REG, bh_reg
13109 +#define RMAX OP_REG, ax_reg
13110 +#define RMDX OP_REG, dx_reg
13112 +#define eAX OP_IMREG, eAX_reg
13113 +#define eBX OP_IMREG, eBX_reg
13114 +#define eCX OP_IMREG, eCX_reg
13115 +#define eDX OP_IMREG, eDX_reg
13116 +#define eSP OP_IMREG, eSP_reg
13117 +#define eBP OP_IMREG, eBP_reg
13118 +#define eSI OP_IMREG, eSI_reg
13119 +#define eDI OP_IMREG, eDI_reg
13120 +#define AL OP_IMREG, al_reg
13121 +#define AL OP_IMREG, al_reg
13122 +#define CL OP_IMREG, cl_reg
13123 +#define DL OP_IMREG, dl_reg
13124 +#define BL OP_IMREG, bl_reg
13125 +#define AH OP_IMREG, ah_reg
13126 +#define CH OP_IMREG, ch_reg
13127 +#define DH OP_IMREG, dh_reg
13128 +#define BH OP_IMREG, bh_reg
13129 +#define AX OP_IMREG, ax_reg
13130 +#define DX OP_IMREG, dx_reg
13131 +#define indirDX OP_IMREG, indir_dx_reg
13133 +#define Sw OP_SEG, w_mode
13134 +#define Ap OP_DIR, 0
13135 +#define Ob OP_OFF, b_mode
13136 +#define Ob64 OP_OFF64, b_mode
13137 +#define Ov OP_OFF, v_mode
13138 +#define Ov64 OP_OFF64, v_mode
13139 +#define Xb OP_DSreg, eSI_reg
13140 +#define Xv OP_DSreg, eSI_reg
13141 +#define Yb OP_ESreg, eDI_reg
13142 +#define Yv OP_ESreg, eDI_reg
13143 +#define DSBX OP_DSreg, eBX_reg
13145 +#define es OP_REG, es_reg
13146 +#define ss OP_REG, ss_reg
13147 +#define cs OP_REG, cs_reg
13148 +#define ds OP_REG, ds_reg
13149 +#define fs OP_REG, fs_reg
13150 +#define gs OP_REG, gs_reg
13152 +#define MX OP_MMX, 0
13153 +#define XM OP_XMM, 0
13154 +#define EM OP_EM, v_mode
13155 +#define EX OP_EX, v_mode
13156 +#define MS OP_MS, v_mode
13157 +#define XS OP_XS, v_mode
13158 +#define VM OP_VMX, q_mode
13159 +#define OPSUF OP_3DNowSuffix, 0
13160 +#define OPSIMD OP_SIMD_Suffix, 0
13162 +#define cond_jump_flag NULL, cond_jump_mode
13163 +#define loop_jcxz_flag NULL, loop_jcxz_mode
13165 +/* bits in sizeflag */
13166 +#define SUFFIX_ALWAYS 4
13170 +#define b_mode 1 /* byte operand */
13171 +#define v_mode 2 /* operand size depends on prefixes */
13172 +#define w_mode 3 /* word operand */
13173 +#define d_mode 4 /* double word operand */
13174 +#define q_mode 5 /* quad word operand */
13175 +#define t_mode 6 /* ten-byte operand */
13176 +#define x_mode 7 /* 16-byte XMM operand */
13177 +#define m_mode 8 /* d_mode in 32bit, q_mode in 64bit mode. */
13178 +#define cond_jump_mode 9
13179 +#define loop_jcxz_mode 10
13180 +#define dq_mode 11 /* operand size depends on REX prefixes. */
13181 +#define dqw_mode 12 /* registers like dq_mode, memory like w_mode. */
13182 +#define f_mode 13 /* 4- or 6-byte pointer operand */
13183 +#define const_1_mode 14
13184 +#define branch_v_mode 15 /* v_mode for branch. */
13186 +#define es_reg 100
13187 +#define cs_reg 101
13188 +#define ss_reg 102
13189 +#define ds_reg 103
13190 +#define fs_reg 104
13191 +#define gs_reg 105
13193 +#define eAX_reg 108
13194 +#define eCX_reg 109
13195 +#define eDX_reg 110
13196 +#define eBX_reg 111
13197 +#define eSP_reg 112
13198 +#define eBP_reg 113
13199 +#define eSI_reg 114
13200 +#define eDI_reg 115
13202 +#define al_reg 116
13203 +#define cl_reg 117
13204 +#define dl_reg 118
13205 +#define bl_reg 119
13206 +#define ah_reg 120
13207 +#define ch_reg 121
13208 +#define dh_reg 122
13209 +#define bh_reg 123
13211 +#define ax_reg 124
13212 +#define cx_reg 125
13213 +#define dx_reg 126
13214 +#define bx_reg 127
13215 +#define sp_reg 128
13216 +#define bp_reg 129
13217 +#define si_reg 130
13218 +#define di_reg 131
13220 +#define rAX_reg 132
13221 +#define rCX_reg 133
13222 +#define rDX_reg 134
13223 +#define rBX_reg 135
13224 +#define rSP_reg 136
13225 +#define rBP_reg 137
13226 +#define rSI_reg 138
13227 +#define rDI_reg 139
13229 +#define indir_dx_reg 150
13231 +#define FLOATCODE 1
13232 +#define USE_GROUPS 2
13233 +#define USE_PREFIX_USER_TABLE 3
13234 +#define X86_64_SPECIAL 4
13236 +#define FLOAT NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
13238 +#define GRP1b NULL, NULL, USE_GROUPS, NULL, 0, NULL, 0
13239 +#define GRP1S NULL, NULL, USE_GROUPS, NULL, 1, NULL, 0
13240 +#define GRP1Ss NULL, NULL, USE_GROUPS, NULL, 2, NULL, 0
13241 +#define GRP2b NULL, NULL, USE_GROUPS, NULL, 3, NULL, 0
13242 +#define GRP2S NULL, NULL, USE_GROUPS, NULL, 4, NULL, 0
13243 +#define GRP2b_one NULL, NULL, USE_GROUPS, NULL, 5, NULL, 0
13244 +#define GRP2S_one NULL, NULL, USE_GROUPS, NULL, 6, NULL, 0
13245 +#define GRP2b_cl NULL, NULL, USE_GROUPS, NULL, 7, NULL, 0
13246 +#define GRP2S_cl NULL, NULL, USE_GROUPS, NULL, 8, NULL, 0
13247 +#define GRP3b NULL, NULL, USE_GROUPS, NULL, 9, NULL, 0
13248 +#define GRP3S NULL, NULL, USE_GROUPS, NULL, 10, NULL, 0
13249 +#define GRP4 NULL, NULL, USE_GROUPS, NULL, 11, NULL, 0
13250 +#define GRP5 NULL, NULL, USE_GROUPS, NULL, 12, NULL, 0
13251 +#define GRP6 NULL, NULL, USE_GROUPS, NULL, 13, NULL, 0
13252 +#define GRP7 NULL, NULL, USE_GROUPS, NULL, 14, NULL, 0
13253 +#define GRP8 NULL, NULL, USE_GROUPS, NULL, 15, NULL, 0
13254 +#define GRP9 NULL, NULL, USE_GROUPS, NULL, 16, NULL, 0
13255 +#define GRP10 NULL, NULL, USE_GROUPS, NULL, 17, NULL, 0
13256 +#define GRP11 NULL, NULL, USE_GROUPS, NULL, 18, NULL, 0
13257 +#define GRP12 NULL, NULL, USE_GROUPS, NULL, 19, NULL, 0
13258 +#define GRP13 NULL, NULL, USE_GROUPS, NULL, 20, NULL, 0
13259 +#define GRP14 NULL, NULL, USE_GROUPS, NULL, 21, NULL, 0
13260 +#define GRPAMD NULL, NULL, USE_GROUPS, NULL, 22, NULL, 0
13261 +#define GRPPADLCK1 NULL, NULL, USE_GROUPS, NULL, 23, NULL, 0
13262 +#define GRPPADLCK2 NULL, NULL, USE_GROUPS, NULL, 24, NULL, 0
13264 +#define PREGRP0 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 0, NULL, 0
13265 +#define PREGRP1 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 1, NULL, 0
13266 +#define PREGRP2 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 2, NULL, 0
13267 +#define PREGRP3 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 3, NULL, 0
13268 +#define PREGRP4 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 4, NULL, 0
13269 +#define PREGRP5 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 5, NULL, 0
13270 +#define PREGRP6 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 6, NULL, 0
13271 +#define PREGRP7 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 7, NULL, 0
13272 +#define PREGRP8 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 8, NULL, 0
13273 +#define PREGRP9 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 9, NULL, 0
13274 +#define PREGRP10 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 10, NULL, 0
13275 +#define PREGRP11 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 11, NULL, 0
13276 +#define PREGRP12 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 12, NULL, 0
13277 +#define PREGRP13 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 13, NULL, 0
13278 +#define PREGRP14 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 14, NULL, 0
13279 +#define PREGRP15 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 15, NULL, 0
13280 +#define PREGRP16 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 16, NULL, 0
13281 +#define PREGRP17 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 17, NULL, 0
13282 +#define PREGRP18 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 18, NULL, 0
13283 +#define PREGRP19 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 19, NULL, 0
13284 +#define PREGRP20 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 20, NULL, 0
13285 +#define PREGRP21 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 21, NULL, 0
13286 +#define PREGRP22 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 22, NULL, 0
13287 +#define PREGRP23 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 23, NULL, 0
13288 +#define PREGRP24 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 24, NULL, 0
13289 +#define PREGRP25 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 25, NULL, 0
13290 +#define PREGRP26 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 26, NULL, 0
13291 +#define PREGRP27 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 27, NULL, 0
13292 +#define PREGRP28 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 28, NULL, 0
13293 +#define PREGRP29 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 29, NULL, 0
13294 +#define PREGRP30 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 30, NULL, 0
13295 +#define PREGRP31 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 31, NULL, 0
13296 +#define PREGRP32 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 32, NULL, 0
13298 +#define X86_64_0 NULL, NULL, X86_64_SPECIAL, NULL, 0, NULL, 0
13300 +typedef void (*op_rtn) (int bytemode, int sizeflag);
13303 + const char *name;
13312 +/* Upper case letters in the instruction names here are macros.
13313 + 'A' => print 'b' if no register operands or suffix_always is true
13314 + 'B' => print 'b' if suffix_always is true
13315 + 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
13317 + 'E' => print 'e' if 32-bit form of jcxz
13318 + 'F' => print 'w' or 'l' depending on address size prefix (loop insns)
13319 + 'H' => print ",pt" or ",pn" branch hint
13320 + 'I' => honor following macro letter even in Intel mode (implemented only
13321 + . for some of the macro letters)
13323 + 'L' => print 'l' if suffix_always is true
13324 + 'N' => print 'n' if instruction has no wait "prefix"
13325 + 'O' => print 'd', or 'o'
13326 + 'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
13327 + . or suffix_always is true. print 'q' if rex prefix is present.
13328 + 'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
13330 + 'R' => print 'w', 'l' or 'q' ("wd" or "dq" in intel mode)
13331 + 'S' => print 'w', 'l' or 'q' if suffix_always is true
13332 + 'T' => print 'q' in 64bit mode and behave as 'P' otherwise
13333 + 'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
13334 + 'W' => print 'b' or 'w' ("w" or "de" in intel mode)
13335 + 'X' => print 's', 'd' depending on data16 prefix (for XMM)
13336 + 'Y' => 'q' if instruction has an REX 64bit overwrite prefix
13338 + Many of the above letters print nothing in Intel mode. See "putop"
13341 + Braces '{' and '}', and vertical bars '|', indicate alternative
13342 + mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
13343 + modes. In cases where there are only two alternatives, the X86_64
13344 + instruction is reserved, and "(bad)" is printed.
13347 +static const struct dis386 dis386[] = {
13349 + { "addB", Eb, Gb, XX },
13350 + { "addS", Ev, Gv, XX },
13351 + { "addB", Gb, Eb, XX },
13352 + { "addS", Gv, Ev, XX },
13353 + { "addB", AL, Ib, XX },
13354 + { "addS", eAX, Iv, XX },
13355 + { "push{T|}", es, XX, XX },
13356 + { "pop{T|}", es, XX, XX },
13358 + { "orB", Eb, Gb, XX },
13359 + { "orS", Ev, Gv, XX },
13360 + { "orB", Gb, Eb, XX },
13361 + { "orS", Gv, Ev, XX },
13362 + { "orB", AL, Ib, XX },
13363 + { "orS", eAX, Iv, XX },
13364 + { "push{T|}", cs, XX, XX },
13365 + { "(bad)", XX, XX, XX }, /* 0x0f extended opcode escape */
13367 + { "adcB", Eb, Gb, XX },
13368 + { "adcS", Ev, Gv, XX },
13369 + { "adcB", Gb, Eb, XX },
13370 + { "adcS", Gv, Ev, XX },
13371 + { "adcB", AL, Ib, XX },
13372 + { "adcS", eAX, Iv, XX },
13373 + { "push{T|}", ss, XX, XX },
13374 + { "popT|}", ss, XX, XX },
13376 + { "sbbB", Eb, Gb, XX },
13377 + { "sbbS", Ev, Gv, XX },
13378 + { "sbbB", Gb, Eb, XX },
13379 + { "sbbS", Gv, Ev, XX },
13380 + { "sbbB", AL, Ib, XX },
13381 + { "sbbS", eAX, Iv, XX },
13382 + { "push{T|}", ds, XX, XX },
13383 + { "pop{T|}", ds, XX, XX },
13385 + { "andB", Eb, Gb, XX },
13386 + { "andS", Ev, Gv, XX },
13387 + { "andB", Gb, Eb, XX },
13388 + { "andS", Gv, Ev, XX },
13389 + { "andB", AL, Ib, XX },
13390 + { "andS", eAX, Iv, XX },
13391 + { "(bad)", XX, XX, XX }, /* SEG ES prefix */
13392 + { "daa{|}", XX, XX, XX },
13394 + { "subB", Eb, Gb, XX },
13395 + { "subS", Ev, Gv, XX },
13396 + { "subB", Gb, Eb, XX },
13397 + { "subS", Gv, Ev, XX },
13398 + { "subB", AL, Ib, XX },
13399 + { "subS", eAX, Iv, XX },
13400 + { "(bad)", XX, XX, XX }, /* SEG CS prefix */
13401 + { "das{|}", XX, XX, XX },
13403 + { "xorB", Eb, Gb, XX },
13404 + { "xorS", Ev, Gv, XX },
13405 + { "xorB", Gb, Eb, XX },
13406 + { "xorS", Gv, Ev, XX },
13407 + { "xorB", AL, Ib, XX },
13408 + { "xorS", eAX, Iv, XX },
13409 + { "(bad)", XX, XX, XX }, /* SEG SS prefix */
13410 + { "aaa{|}", XX, XX, XX },
13412 + { "cmpB", Eb, Gb, XX },
13413 + { "cmpS", Ev, Gv, XX },
13414 + { "cmpB", Gb, Eb, XX },
13415 + { "cmpS", Gv, Ev, XX },
13416 + { "cmpB", AL, Ib, XX },
13417 + { "cmpS", eAX, Iv, XX },
13418 + { "(bad)", XX, XX, XX }, /* SEG DS prefix */
13419 + { "aas{|}", XX, XX, XX },
13421 + { "inc{S|}", RMeAX, XX, XX },
13422 + { "inc{S|}", RMeCX, XX, XX },
13423 + { "inc{S|}", RMeDX, XX, XX },
13424 + { "inc{S|}", RMeBX, XX, XX },
13425 + { "inc{S|}", RMeSP, XX, XX },
13426 + { "inc{S|}", RMeBP, XX, XX },
13427 + { "inc{S|}", RMeSI, XX, XX },
13428 + { "inc{S|}", RMeDI, XX, XX },
13430 + { "dec{S|}", RMeAX, XX, XX },
13431 + { "dec{S|}", RMeCX, XX, XX },
13432 + { "dec{S|}", RMeDX, XX, XX },
13433 + { "dec{S|}", RMeBX, XX, XX },
13434 + { "dec{S|}", RMeSP, XX, XX },
13435 + { "dec{S|}", RMeBP, XX, XX },
13436 + { "dec{S|}", RMeSI, XX, XX },
13437 + { "dec{S|}", RMeDI, XX, XX },
13439 + { "pushS", RMrAX, XX, XX },
13440 + { "pushS", RMrCX, XX, XX },
13441 + { "pushS", RMrDX, XX, XX },
13442 + { "pushS", RMrBX, XX, XX },
13443 + { "pushS", RMrSP, XX, XX },
13444 + { "pushS", RMrBP, XX, XX },
13445 + { "pushS", RMrSI, XX, XX },
13446 + { "pushS", RMrDI, XX, XX },
13448 + { "popS", RMrAX, XX, XX },
13449 + { "popS", RMrCX, XX, XX },
13450 + { "popS", RMrDX, XX, XX },
13451 + { "popS", RMrBX, XX, XX },
13452 + { "popS", RMrSP, XX, XX },
13453 + { "popS", RMrBP, XX, XX },
13454 + { "popS", RMrSI, XX, XX },
13455 + { "popS", RMrDI, XX, XX },
13457 + { "pusha{P|}", XX, XX, XX },
13458 + { "popa{P|}", XX, XX, XX },
13459 + { "bound{S|}", Gv, Ma, XX },
13461 + { "(bad)", XX, XX, XX }, /* seg fs */
13462 + { "(bad)", XX, XX, XX }, /* seg gs */
13463 + { "(bad)", XX, XX, XX }, /* op size prefix */
13464 + { "(bad)", XX, XX, XX }, /* adr size prefix */
13466 + { "pushT", Iq, XX, XX },
13467 + { "imulS", Gv, Ev, Iv },
13468 + { "pushT", sIb, XX, XX },
13469 + { "imulS", Gv, Ev, sIb },
13470 + { "ins{b||b|}", Yb, indirDX, XX },
13471 + { "ins{R||R|}", Yv, indirDX, XX },
13472 + { "outs{b||b|}", indirDX, Xb, XX },
13473 + { "outs{R||R|}", indirDX, Xv, XX },
13475 + { "joH", Jb, XX, cond_jump_flag },
13476 + { "jnoH", Jb, XX, cond_jump_flag },
13477 + { "jbH", Jb, XX, cond_jump_flag },
13478 + { "jaeH", Jb, XX, cond_jump_flag },
13479 + { "jeH", Jb, XX, cond_jump_flag },
13480 + { "jneH", Jb, XX, cond_jump_flag },
13481 + { "jbeH", Jb, XX, cond_jump_flag },
13482 + { "jaH", Jb, XX, cond_jump_flag },
13484 + { "jsH", Jb, XX, cond_jump_flag },
13485 + { "jnsH", Jb, XX, cond_jump_flag },
13486 + { "jpH", Jb, XX, cond_jump_flag },
13487 + { "jnpH", Jb, XX, cond_jump_flag },
13488 + { "jlH", Jb, XX, cond_jump_flag },
13489 + { "jgeH", Jb, XX, cond_jump_flag },
13490 + { "jleH", Jb, XX, cond_jump_flag },
13491 + { "jgH", Jb, XX, cond_jump_flag },
13495 + { "(bad)", XX, XX, XX },
13497 + { "testB", Eb, Gb, XX },
13498 + { "testS", Ev, Gv, XX },
13499 + { "xchgB", Eb, Gb, XX },
13500 + { "xchgS", Ev, Gv, XX },
13502 + { "movB", Eb, Gb, XX },
13503 + { "movS", Ev, Gv, XX },
13504 + { "movB", Gb, Eb, XX },
13505 + { "movS", Gv, Ev, XX },
13506 + { "movQ", Sv, Sw, XX },
13507 + { "leaS", Gv, M, XX },
13508 + { "movQ", Sw, Sv, XX },
13509 + { "popU", Ev, XX, XX },
13511 + { "nop", NOP_Fixup, 0, XX, XX },
13512 + { "xchgS", RMeCX, eAX, XX },
13513 + { "xchgS", RMeDX, eAX, XX },
13514 + { "xchgS", RMeBX, eAX, XX },
13515 + { "xchgS", RMeSP, eAX, XX },
13516 + { "xchgS", RMeBP, eAX, XX },
13517 + { "xchgS", RMeSI, eAX, XX },
13518 + { "xchgS", RMeDI, eAX, XX },
13520 + { "cW{tR||tR|}", XX, XX, XX },
13521 + { "cR{tO||tO|}", XX, XX, XX },
13522 + { "Jcall{T|}", Ap, XX, XX },
13523 + { "(bad)", XX, XX, XX }, /* fwait */
13524 + { "pushfT", XX, XX, XX },
13525 + { "popfT", XX, XX, XX },
13526 + { "sahf{|}", XX, XX, XX },
13527 + { "lahf{|}", XX, XX, XX },
13529 + { "movB", AL, Ob64, XX },
13530 + { "movS", eAX, Ov64, XX },
13531 + { "movB", Ob64, AL, XX },
13532 + { "movS", Ov64, eAX, XX },
13533 + { "movs{b||b|}", Yb, Xb, XX },
13534 + { "movs{R||R|}", Yv, Xv, XX },
13535 + { "cmps{b||b|}", Xb, Yb, XX },
13536 + { "cmps{R||R|}", Xv, Yv, XX },
13538 + { "testB", AL, Ib, XX },
13539 + { "testS", eAX, Iv, XX },
13540 + { "stosB", Yb, AL, XX },
13541 + { "stosS", Yv, eAX, XX },
13542 + { "lodsB", AL, Xb, XX },
13543 + { "lodsS", eAX, Xv, XX },
13544 + { "scasB", AL, Yb, XX },
13545 + { "scasS", eAX, Yv, XX },
13547 + { "movB", RMAL, Ib, XX },
13548 + { "movB", RMCL, Ib, XX },
13549 + { "movB", RMDL, Ib, XX },
13550 + { "movB", RMBL, Ib, XX },
13551 + { "movB", RMAH, Ib, XX },
13552 + { "movB", RMCH, Ib, XX },
13553 + { "movB", RMDH, Ib, XX },
13554 + { "movB", RMBH, Ib, XX },
13556 + { "movS", RMeAX, Iv64, XX },
13557 + { "movS", RMeCX, Iv64, XX },
13558 + { "movS", RMeDX, Iv64, XX },
13559 + { "movS", RMeBX, Iv64, XX },
13560 + { "movS", RMeSP, Iv64, XX },
13561 + { "movS", RMeBP, Iv64, XX },
13562 + { "movS", RMeSI, Iv64, XX },
13563 + { "movS", RMeDI, Iv64, XX },
13567 + { "retT", Iw, XX, XX },
13568 + { "retT", XX, XX, XX },
13569 + { "les{S|}", Gv, Mp, XX },
13570 + { "ldsS", Gv, Mp, XX },
13571 + { "movA", Eb, Ib, XX },
13572 + { "movQ", Ev, Iv, XX },
13574 + { "enterT", Iw, Ib, XX },
13575 + { "leaveT", XX, XX, XX },
13576 + { "lretP", Iw, XX, XX },
13577 + { "lretP", XX, XX, XX },
13578 + { "int3", XX, XX, XX },
13579 + { "int", Ib, XX, XX },
13580 + { "into{|}", XX, XX, XX },
13581 + { "iretP", XX, XX, XX },
13587 + { "aam{|}", sIb, XX, XX },
13588 + { "aad{|}", sIb, XX, XX },
13589 + { "(bad)", XX, XX, XX },
13590 + { "xlat", DSBX, XX, XX },
13601 + { "loopneFH", Jb, XX, loop_jcxz_flag },
13602 + { "loopeFH", Jb, XX, loop_jcxz_flag },
13603 + { "loopFH", Jb, XX, loop_jcxz_flag },
13604 + { "jEcxzH", Jb, XX, loop_jcxz_flag },
13605 + { "inB", AL, Ib, XX },
13606 + { "inS", eAX, Ib, XX },
13607 + { "outB", Ib, AL, XX },
13608 + { "outS", Ib, eAX, XX },
13610 + { "callT", Jv, XX, XX },
13611 + { "jmpT", Jv, XX, XX },
13612 + { "Jjmp{T|}", Ap, XX, XX },
13613 + { "jmp", Jb, XX, XX },
13614 + { "inB", AL, indirDX, XX },
13615 + { "inS", eAX, indirDX, XX },
13616 + { "outB", indirDX, AL, XX },
13617 + { "outS", indirDX, eAX, XX },
13619 + { "(bad)", XX, XX, XX }, /* lock prefix */
13620 + { "icebp", XX, XX, XX },
13621 + { "(bad)", XX, XX, XX }, /* repne */
13622 + { "(bad)", XX, XX, XX }, /* repz */
13623 + { "hlt", XX, XX, XX },
13624 + { "cmc", XX, XX, XX },
13628 + { "clc", XX, XX, XX },
13629 + { "stc", XX, XX, XX },
13630 + { "cli", XX, XX, XX },
13631 + { "sti", XX, XX, XX },
13632 + { "cld", XX, XX, XX },
13633 + { "std", XX, XX, XX },
13638 +static const struct dis386 dis386_twobyte[] = {
13642 + { "larS", Gv, Ew, XX },
13643 + { "lslS", Gv, Ew, XX },
13644 + { "(bad)", XX, XX, XX },
13645 + { "syscall", XX, XX, XX },
13646 + { "clts", XX, XX, XX },
13647 + { "sysretP", XX, XX, XX },
13649 + { "invd", XX, XX, XX },
13650 + { "wbinvd", XX, XX, XX },
13651 + { "(bad)", XX, XX, XX },
13652 + { "ud2a", XX, XX, XX },
13653 + { "(bad)", XX, XX, XX },
13655 + { "femms", XX, XX, XX },
13656 + { "", MX, EM, OPSUF }, /* See OP_3DNowSuffix. */
13661 + { "movlpX", EX, XM, SIMD_Fixup, 'h' },
13662 + { "unpcklpX", XM, EX, XX },
13663 + { "unpckhpX", XM, EX, XX },
13665 + { "movhpX", EX, XM, SIMD_Fixup, 'l' },
13668 + { "(bad)", XX, XX, XX },
13669 + { "(bad)", XX, XX, XX },
13670 + { "(bad)", XX, XX, XX },
13671 + { "(bad)", XX, XX, XX },
13672 + { "(bad)", XX, XX, XX },
13673 + { "(bad)", XX, XX, XX },
13674 + { "(bad)", XX, XX, XX },
13676 + { "movL", Rm, Cm, XX },
13677 + { "movL", Rm, Dm, XX },
13678 + { "movL", Cm, Rm, XX },
13679 + { "movL", Dm, Rm, XX },
13680 + { "movL", Rd, Td, XX },
13681 + { "(bad)", XX, XX, XX },
13682 + { "movL", Td, Rd, XX },
13683 + { "(bad)", XX, XX, XX },
13685 + { "movapX", XM, EX, XX },
13686 + { "movapX", EX, XM, XX },
13688 + { "movntpX", Ev, XM, XX },
13691 + { "ucomisX", XM,EX, XX },
13692 + { "comisX", XM,EX, XX },
13694 + { "wrmsr", XX, XX, XX },
13695 + { "rdtsc", XX, XX, XX },
13696 + { "rdmsr", XX, XX, XX },
13697 + { "rdpmc", XX, XX, XX },
13698 + { "sysenter", XX, XX, XX },
13699 + { "sysexit", XX, XX, XX },
13700 + { "(bad)", XX, XX, XX },
13701 + { "(bad)", XX, XX, XX },
13703 + { "(bad)", XX, XX, XX },
13704 + { "(bad)", XX, XX, XX },
13705 + { "(bad)", XX, XX, XX },
13706 + { "(bad)", XX, XX, XX },
13707 + { "(bad)", XX, XX, XX },
13708 + { "(bad)", XX, XX, XX },
13709 + { "(bad)", XX, XX, XX },
13710 + { "(bad)", XX, XX, XX },
13712 + { "cmovo", Gv, Ev, XX },
13713 + { "cmovno", Gv, Ev, XX },
13714 + { "cmovb", Gv, Ev, XX },
13715 + { "cmovae", Gv, Ev, XX },
13716 + { "cmove", Gv, Ev, XX },
13717 + { "cmovne", Gv, Ev, XX },
13718 + { "cmovbe", Gv, Ev, XX },
13719 + { "cmova", Gv, Ev, XX },
13721 + { "cmovs", Gv, Ev, XX },
13722 + { "cmovns", Gv, Ev, XX },
13723 + { "cmovp", Gv, Ev, XX },
13724 + { "cmovnp", Gv, Ev, XX },
13725 + { "cmovl", Gv, Ev, XX },
13726 + { "cmovge", Gv, Ev, XX },
13727 + { "cmovle", Gv, Ev, XX },
13728 + { "cmovg", Gv, Ev, XX },
13730 + { "movmskpX", Gdq, XS, XX },
13734 + { "andpX", XM, EX, XX },
13735 + { "andnpX", XM, EX, XX },
13736 + { "orpX", XM, EX, XX },
13737 + { "xorpX", XM, EX, XX },
13748 + { "punpcklbw", MX, EM, XX },
13749 + { "punpcklwd", MX, EM, XX },
13750 + { "punpckldq", MX, EM, XX },
13751 + { "packsswb", MX, EM, XX },
13752 + { "pcmpgtb", MX, EM, XX },
13753 + { "pcmpgtw", MX, EM, XX },
13754 + { "pcmpgtd", MX, EM, XX },
13755 + { "packuswb", MX, EM, XX },
13757 + { "punpckhbw", MX, EM, XX },
13758 + { "punpckhwd", MX, EM, XX },
13759 + { "punpckhdq", MX, EM, XX },
13760 + { "packssdw", MX, EM, XX },
13763 + { "movd", MX, Edq, XX },
13770 + { "pcmpeqb", MX, EM, XX },
13771 + { "pcmpeqw", MX, EM, XX },
13772 + { "pcmpeqd", MX, EM, XX },
13773 + { "emms", XX, XX, XX },
13775 + { "vmread", Em, Gm, XX },
13776 + { "vmwrite", Gm, Em, XX },
13777 + { "(bad)", XX, XX, XX },
13778 + { "(bad)", XX, XX, XX },
13784 + { "joH", Jv, XX, cond_jump_flag },
13785 + { "jnoH", Jv, XX, cond_jump_flag },
13786 + { "jbH", Jv, XX, cond_jump_flag },
13787 + { "jaeH", Jv, XX, cond_jump_flag },
13788 + { "jeH", Jv, XX, cond_jump_flag },
13789 + { "jneH", Jv, XX, cond_jump_flag },
13790 + { "jbeH", Jv, XX, cond_jump_flag },
13791 + { "jaH", Jv, XX, cond_jump_flag },
13793 + { "jsH", Jv, XX, cond_jump_flag },
13794 + { "jnsH", Jv, XX, cond_jump_flag },
13795 + { "jpH", Jv, XX, cond_jump_flag },
13796 + { "jnpH", Jv, XX, cond_jump_flag },
13797 + { "jlH", Jv, XX, cond_jump_flag },
13798 + { "jgeH", Jv, XX, cond_jump_flag },
13799 + { "jleH", Jv, XX, cond_jump_flag },
13800 + { "jgH", Jv, XX, cond_jump_flag },
13802 + { "seto", Eb, XX, XX },
13803 + { "setno", Eb, XX, XX },
13804 + { "setb", Eb, XX, XX },
13805 + { "setae", Eb, XX, XX },
13806 + { "sete", Eb, XX, XX },
13807 + { "setne", Eb, XX, XX },
13808 + { "setbe", Eb, XX, XX },
13809 + { "seta", Eb, XX, XX },
13811 + { "sets", Eb, XX, XX },
13812 + { "setns", Eb, XX, XX },
13813 + { "setp", Eb, XX, XX },
13814 + { "setnp", Eb, XX, XX },
13815 + { "setl", Eb, XX, XX },
13816 + { "setge", Eb, XX, XX },
13817 + { "setle", Eb, XX, XX },
13818 + { "setg", Eb, XX, XX },
13820 + { "pushT", fs, XX, XX },
13821 + { "popT", fs, XX, XX },
13822 + { "cpuid", XX, XX, XX },
13823 + { "btS", Ev, Gv, XX },
13824 + { "shldS", Ev, Gv, Ib },
13825 + { "shldS", Ev, Gv, CL },
13829 + { "pushT", gs, XX, XX },
13830 + { "popT", gs, XX, XX },
13831 + { "rsm", XX, XX, XX },
13832 + { "btsS", Ev, Gv, XX },
13833 + { "shrdS", Ev, Gv, Ib },
13834 + { "shrdS", Ev, Gv, CL },
13836 + { "imulS", Gv, Ev, XX },
13838 + { "cmpxchgB", Eb, Gb, XX },
13839 + { "cmpxchgS", Ev, Gv, XX },
13840 + { "lssS", Gv, Mp, XX },
13841 + { "btrS", Ev, Gv, XX },
13842 + { "lfsS", Gv, Mp, XX },
13843 + { "lgsS", Gv, Mp, XX },
13844 + { "movz{bR|x|bR|x}", Gv, Eb, XX },
13845 + { "movz{wR|x|wR|x}", Gv, Ew, XX }, /* yes, there really is movzww ! */
13847 + { "(bad)", XX, XX, XX },
13848 + { "ud2b", XX, XX, XX },
13850 + { "btcS", Ev, Gv, XX },
13851 + { "bsfS", Gv, Ev, XX },
13852 + { "bsrS", Gv, Ev, XX },
13853 + { "movs{bR|x|bR|x}", Gv, Eb, XX },
13854 + { "movs{wR|x|wR|x}", Gv, Ew, XX }, /* yes, there really is movsww ! */
13856 + { "xaddB", Eb, Gb, XX },
13857 + { "xaddS", Ev, Gv, XX },
13859 + { "movntiS", Ev, Gv, XX },
13860 + { "pinsrw", MX, Edqw, Ib },
13861 + { "pextrw", Gdq, MS, Ib },
13862 + { "shufpX", XM, EX, Ib },
13865 + { "bswap", RMeAX, XX, XX },
13866 + { "bswap", RMeCX, XX, XX },
13867 + { "bswap", RMeDX, XX, XX },
13868 + { "bswap", RMeBX, XX, XX },
13869 + { "bswap", RMeSP, XX, XX },
13870 + { "bswap", RMeBP, XX, XX },
13871 + { "bswap", RMeSI, XX, XX },
13872 + { "bswap", RMeDI, XX, XX },
13875 + { "psrlw", MX, EM, XX },
13876 + { "psrld", MX, EM, XX },
13877 + { "psrlq", MX, EM, XX },
13878 + { "paddq", MX, EM, XX },
13879 + { "pmullw", MX, EM, XX },
13881 + { "pmovmskb", Gdq, MS, XX },
13883 + { "psubusb", MX, EM, XX },
13884 + { "psubusw", MX, EM, XX },
13885 + { "pminub", MX, EM, XX },
13886 + { "pand", MX, EM, XX },
13887 + { "paddusb", MX, EM, XX },
13888 + { "paddusw", MX, EM, XX },
13889 + { "pmaxub", MX, EM, XX },
13890 + { "pandn", MX, EM, XX },
13892 + { "pavgb", MX, EM, XX },
13893 + { "psraw", MX, EM, XX },
13894 + { "psrad", MX, EM, XX },
13895 + { "pavgw", MX, EM, XX },
13896 + { "pmulhuw", MX, EM, XX },
13897 + { "pmulhw", MX, EM, XX },
13901 + { "psubsb", MX, EM, XX },
13902 + { "psubsw", MX, EM, XX },
13903 + { "pminsw", MX, EM, XX },
13904 + { "por", MX, EM, XX },
13905 + { "paddsb", MX, EM, XX },
13906 + { "paddsw", MX, EM, XX },
13907 + { "pmaxsw", MX, EM, XX },
13908 + { "pxor", MX, EM, XX },
13911 + { "psllw", MX, EM, XX },
13912 + { "pslld", MX, EM, XX },
13913 + { "psllq", MX, EM, XX },
13914 + { "pmuludq", MX, EM, XX },
13915 + { "pmaddwd", MX, EM, XX },
13916 + { "psadbw", MX, EM, XX },
13919 + { "psubb", MX, EM, XX },
13920 + { "psubw", MX, EM, XX },
13921 + { "psubd", MX, EM, XX },
13922 + { "psubq", MX, EM, XX },
13923 + { "paddb", MX, EM, XX },
13924 + { "paddw", MX, EM, XX },
13925 + { "paddd", MX, EM, XX },
13926 + { "(bad)", XX, XX, XX }
13929 +static const unsigned char onebyte_has_modrm[256] = {
13930 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
13931 + /* ------------------------------- */
13932 + /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
13933 + /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
13934 + /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
13935 + /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
13936 + /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
13937 + /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
13938 + /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
13939 + /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
13940 + /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
13941 + /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
13942 + /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
13943 + /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
13944 + /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
13945 + /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
13946 + /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
13947 + /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
13948 + /* ------------------------------- */
13949 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
13952 +static const unsigned char twobyte_has_modrm[256] = {
13953 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
13954 + /* ------------------------------- */
13955 + /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
13956 + /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0, /* 1f */
13957 + /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
13958 + /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
13959 + /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
13960 + /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
13961 + /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
13962 + /* 70 */ 1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1, /* 7f */
13963 + /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
13964 + /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
13965 + /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
13966 + /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
13967 + /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
13968 + /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
13969 + /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
13970 + /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 /* ff */
13971 + /* ------------------------------- */
13972 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
13975 +static const unsigned char twobyte_uses_SSE_prefix[256] = {
13976 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
13977 + /* ------------------------------- */
13978 + /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
13979 + /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
13980 + /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0, /* 2f */
13981 + /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
13982 + /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
13983 + /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
13984 + /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
13985 + /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1, /* 7f */
13986 + /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
13987 + /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
13988 + /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
13989 + /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
13990 + /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
13991 + /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
13992 + /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
13993 + /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 /* ff */
13994 + /* ------------------------------- */
13995 + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
13998 +static char obuf[100];
13999 +static char *obufp;
14000 +static char scratchbuf[100];
14001 +static unsigned char *start_codep;
14002 +static unsigned char *insn_codep;
14003 +static unsigned char *codep;
14004 +static disassemble_info *the_info;
14008 +static unsigned char need_modrm;
14010 +/* If we are accessing mod/rm/reg without need_modrm set, then the
14011 + values are stale. Hitting this abort likely indicates that you
14012 + need to update onebyte_has_modrm or twobyte_has_modrm. */
14013 +#define MODRM_CHECK if (!need_modrm) abort ()
14015 +static const char **names64;
14016 +static const char **names32;
14017 +static const char **names16;
14018 +static const char **names8;
14019 +static const char **names8rex;
14020 +static const char **names_seg;
14021 +static const char **index16;
14023 +static const char *intel_names64[] = {
14024 + "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
14025 + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
14027 +static const char *intel_names32[] = {
14028 + "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
14029 + "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
14031 +static const char *intel_names16[] = {
14032 + "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
14033 + "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
14035 +static const char *intel_names8[] = {
14036 + "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
14038 +static const char *intel_names8rex[] = {
14039 + "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
14040 + "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
14042 +static const char *intel_names_seg[] = {
14043 + "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
14045 +static const char *intel_index16[] = {
14046 + "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
14049 +static const char *att_names64[] = {
14050 + "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
14051 + "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
14053 +static const char *att_names32[] = {
14054 + "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
14055 + "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
14057 +static const char *att_names16[] = {
14058 + "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
14059 + "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
14061 +static const char *att_names8[] = {
14062 + "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
14064 +static const char *att_names8rex[] = {
14065 + "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
14066 + "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
14068 +static const char *att_names_seg[] = {
14069 + "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
14071 +static const char *att_index16[] = {
14072 + "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
14075 +static const struct dis386 grps[][8] = {
14078 + { "addA", Eb, Ib, XX },
14079 + { "orA", Eb, Ib, XX },
14080 + { "adcA", Eb, Ib, XX },
14081 + { "sbbA", Eb, Ib, XX },
14082 + { "andA", Eb, Ib, XX },
14083 + { "subA", Eb, Ib, XX },
14084 + { "xorA", Eb, Ib, XX },
14085 + { "cmpA", Eb, Ib, XX }
14089 + { "addQ", Ev, Iv, XX },
14090 + { "orQ", Ev, Iv, XX },
14091 + { "adcQ", Ev, Iv, XX },
14092 + { "sbbQ", Ev, Iv, XX },
14093 + { "andQ", Ev, Iv, XX },
14094 + { "subQ", Ev, Iv, XX },
14095 + { "xorQ", Ev, Iv, XX },
14096 + { "cmpQ", Ev, Iv, XX }
14100 + { "addQ", Ev, sIb, XX },
14101 + { "orQ", Ev, sIb, XX },
14102 + { "adcQ", Ev, sIb, XX },
14103 + { "sbbQ", Ev, sIb, XX },
14104 + { "andQ", Ev, sIb, XX },
14105 + { "subQ", Ev, sIb, XX },
14106 + { "xorQ", Ev, sIb, XX },
14107 + { "cmpQ", Ev, sIb, XX }
14111 + { "rolA", Eb, Ib, XX },
14112 + { "rorA", Eb, Ib, XX },
14113 + { "rclA", Eb, Ib, XX },
14114 + { "rcrA", Eb, Ib, XX },
14115 + { "shlA", Eb, Ib, XX },
14116 + { "shrA", Eb, Ib, XX },
14117 + { "(bad)", XX, XX, XX },
14118 + { "sarA", Eb, Ib, XX },
14122 + { "rolQ", Ev, Ib, XX },
14123 + { "rorQ", Ev, Ib, XX },
14124 + { "rclQ", Ev, Ib, XX },
14125 + { "rcrQ", Ev, Ib, XX },
14126 + { "shlQ", Ev, Ib, XX },
14127 + { "shrQ", Ev, Ib, XX },
14128 + { "(bad)", XX, XX, XX },
14129 + { "sarQ", Ev, Ib, XX },
14133 + { "rolA", Eb, I1, XX },
14134 + { "rorA", Eb, I1, XX },
14135 + { "rclA", Eb, I1, XX },
14136 + { "rcrA", Eb, I1, XX },
14137 + { "shlA", Eb, I1, XX },
14138 + { "shrA", Eb, I1, XX },
14139 + { "(bad)", XX, XX, XX },
14140 + { "sarA", Eb, I1, XX },
14144 + { "rolQ", Ev, I1, XX },
14145 + { "rorQ", Ev, I1, XX },
14146 + { "rclQ", Ev, I1, XX },
14147 + { "rcrQ", Ev, I1, XX },
14148 + { "shlQ", Ev, I1, XX },
14149 + { "shrQ", Ev, I1, XX },
14150 + { "(bad)", XX, XX, XX},
14151 + { "sarQ", Ev, I1, XX },
14155 + { "rolA", Eb, CL, XX },
14156 + { "rorA", Eb, CL, XX },
14157 + { "rclA", Eb, CL, XX },
14158 + { "rcrA", Eb, CL, XX },
14159 + { "shlA", Eb, CL, XX },
14160 + { "shrA", Eb, CL, XX },
14161 + { "(bad)", XX, XX, XX },
14162 + { "sarA", Eb, CL, XX },
14166 + { "rolQ", Ev, CL, XX },
14167 + { "rorQ", Ev, CL, XX },
14168 + { "rclQ", Ev, CL, XX },
14169 + { "rcrQ", Ev, CL, XX },
14170 + { "shlQ", Ev, CL, XX },
14171 + { "shrQ", Ev, CL, XX },
14172 + { "(bad)", XX, XX, XX },
14173 + { "sarQ", Ev, CL, XX }
14177 + { "testA", Eb, Ib, XX },
14178 + { "(bad)", Eb, XX, XX },
14179 + { "notA", Eb, XX, XX },
14180 + { "negA", Eb, XX, XX },
14181 + { "mulA", Eb, XX, XX }, /* Don't print the implicit %al register, */
14182 + { "imulA", Eb, XX, XX }, /* to distinguish these opcodes from other */
14183 + { "divA", Eb, XX, XX }, /* mul/imul opcodes. Do the same for div */
14184 + { "idivA", Eb, XX, XX } /* and idiv for consistency. */
14188 + { "testQ", Ev, Iv, XX },
14189 + { "(bad)", XX, XX, XX },
14190 + { "notQ", Ev, XX, XX },
14191 + { "negQ", Ev, XX, XX },
14192 + { "mulQ", Ev, XX, XX }, /* Don't print the implicit register. */
14193 + { "imulQ", Ev, XX, XX },
14194 + { "divQ", Ev, XX, XX },
14195 + { "idivQ", Ev, XX, XX },
14199 + { "incA", Eb, XX, XX },
14200 + { "decA", Eb, XX, XX },
14201 + { "(bad)", XX, XX, XX },
14202 + { "(bad)", XX, XX, XX },
14203 + { "(bad)", XX, XX, XX },
14204 + { "(bad)", XX, XX, XX },
14205 + { "(bad)", XX, XX, XX },
14206 + { "(bad)", XX, XX, XX },
14210 + { "incQ", Ev, XX, XX },
14211 + { "decQ", Ev, XX, XX },
14212 + { "callT", indirEv, XX, XX },
14213 + { "JcallT", indirEp, XX, XX },
14214 + { "jmpT", indirEv, XX, XX },
14215 + { "JjmpT", indirEp, XX, XX },
14216 + { "pushU", Ev, XX, XX },
14217 + { "(bad)", XX, XX, XX },
14221 + { "sldtQ", Ev, XX, XX },
14222 + { "strQ", Ev, XX, XX },
14223 + { "lldt", Ew, XX, XX },
14224 + { "ltr", Ew, XX, XX },
14225 + { "verr", Ew, XX, XX },
14226 + { "verw", Ew, XX, XX },
14227 + { "(bad)", XX, XX, XX },
14228 + { "(bad)", XX, XX, XX }
14232 + { "sgdtIQ", VMX_Fixup, 0, XX, XX },
14233 + { "sidtIQ", PNI_Fixup, 0, XX, XX },
14234 + { "lgdt{Q|Q||}", M, XX, XX },
14235 + { "lidt{Q|Q||}", SVME_Fixup, 0, XX, XX },
14236 + { "smswQ", Ev, XX, XX },
14237 + { "(bad)", XX, XX, XX },
14238 + { "lmsw", Ew, XX, XX },
14239 + { "invlpg", INVLPG_Fixup, w_mode, XX, XX },
14243 + { "(bad)", XX, XX, XX },
14244 + { "(bad)", XX, XX, XX },
14245 + { "(bad)", XX, XX, XX },
14246 + { "(bad)", XX, XX, XX },
14247 + { "btQ", Ev, Ib, XX },
14248 + { "btsQ", Ev, Ib, XX },
14249 + { "btrQ", Ev, Ib, XX },
14250 + { "btcQ", Ev, Ib, XX },
14254 + { "(bad)", XX, XX, XX },
14255 + { "cmpxchg8b", Eq, XX, XX },
14256 + { "(bad)", XX, XX, XX },
14257 + { "(bad)", XX, XX, XX },
14258 + { "(bad)", XX, XX, XX },
14259 + { "(bad)", XX, XX, XX },
14260 + { "", VM, XX, XX }, /* See OP_VMX. */
14261 + { "vmptrst", Eq, XX, XX },
14265 + { "(bad)", XX, XX, XX },
14266 + { "(bad)", XX, XX, XX },
14267 + { "psrlw", MS, Ib, XX },
14268 + { "(bad)", XX, XX, XX },
14269 + { "psraw", MS, Ib, XX },
14270 + { "(bad)", XX, XX, XX },
14271 + { "psllw", MS, Ib, XX },
14272 + { "(bad)", XX, XX, XX },
14276 + { "(bad)", XX, XX, XX },
14277 + { "(bad)", XX, XX, XX },
14278 + { "psrld", MS, Ib, XX },
14279 + { "(bad)", XX, XX, XX },
14280 + { "psrad", MS, Ib, XX },
14281 + { "(bad)", XX, XX, XX },
14282 + { "pslld", MS, Ib, XX },
14283 + { "(bad)", XX, XX, XX },
14287 + { "(bad)", XX, XX, XX },
14288 + { "(bad)", XX, XX, XX },
14289 + { "psrlq", MS, Ib, XX },
14290 + { "psrldq", MS, Ib, XX },
14291 + { "(bad)", XX, XX, XX },
14292 + { "(bad)", XX, XX, XX },
14293 + { "psllq", MS, Ib, XX },
14294 + { "pslldq", MS, Ib, XX },
14298 + { "fxsave", Ev, XX, XX },
14299 + { "fxrstor", Ev, XX, XX },
14300 + { "ldmxcsr", Ev, XX, XX },
14301 + { "stmxcsr", Ev, XX, XX },
14302 + { "(bad)", XX, XX, XX },
14303 + { "lfence", OP_0fae, 0, XX, XX },
14304 + { "mfence", OP_0fae, 0, XX, XX },
14305 + { "clflush", OP_0fae, 0, XX, XX },
14309 + { "prefetchnta", Ev, XX, XX },
14310 + { "prefetcht0", Ev, XX, XX },
14311 + { "prefetcht1", Ev, XX, XX },
14312 + { "prefetcht2", Ev, XX, XX },
14313 + { "(bad)", XX, XX, XX },
14314 + { "(bad)", XX, XX, XX },
14315 + { "(bad)", XX, XX, XX },
14316 + { "(bad)", XX, XX, XX },
14320 + { "prefetch", Eb, XX, XX },
14321 + { "prefetchw", Eb, XX, XX },
14322 + { "(bad)", XX, XX, XX },
14323 + { "(bad)", XX, XX, XX },
14324 + { "(bad)", XX, XX, XX },
14325 + { "(bad)", XX, XX, XX },
14326 + { "(bad)", XX, XX, XX },
14327 + { "(bad)", XX, XX, XX },
14331 + { "xstore-rng", OP_0f07, 0, XX, XX },
14332 + { "xcrypt-ecb", OP_0f07, 0, XX, XX },
14333 + { "xcrypt-cbc", OP_0f07, 0, XX, XX },
14334 + { "xcrypt-ctr", OP_0f07, 0, XX, XX },
14335 + { "xcrypt-cfb", OP_0f07, 0, XX, XX },
14336 + { "xcrypt-ofb", OP_0f07, 0, XX, XX },
14337 + { "(bad)", OP_0f07, 0, XX, XX },
14338 + { "(bad)", OP_0f07, 0, XX, XX },
14342 + { "montmul", OP_0f07, 0, XX, XX },
14343 + { "xsha1", OP_0f07, 0, XX, XX },
14344 + { "xsha256", OP_0f07, 0, XX, XX },
14345 + { "(bad)", OP_0f07, 0, XX, XX },
14346 + { "(bad)", OP_0f07, 0, XX, XX },
14347 + { "(bad)", OP_0f07, 0, XX, XX },
14348 + { "(bad)", OP_0f07, 0, XX, XX },
14349 + { "(bad)", OP_0f07, 0, XX, XX },
14353 +static const struct dis386 prefix_user_table[][4] = {
14356 + { "addps", XM, EX, XX },
14357 + { "addss", XM, EX, XX },
14358 + { "addpd", XM, EX, XX },
14359 + { "addsd", XM, EX, XX },
14363 + { "", XM, EX, OPSIMD }, /* See OP_SIMD_SUFFIX. */
14364 + { "", XM, EX, OPSIMD },
14365 + { "", XM, EX, OPSIMD },
14366 + { "", XM, EX, OPSIMD },
14370 + { "cvtpi2ps", XM, EM, XX },
14371 + { "cvtsi2ssY", XM, Ev, XX },
14372 + { "cvtpi2pd", XM, EM, XX },
14373 + { "cvtsi2sdY", XM, Ev, XX },
14377 + { "cvtps2pi", MX, EX, XX },
14378 + { "cvtss2siY", Gv, EX, XX },
14379 + { "cvtpd2pi", MX, EX, XX },
14380 + { "cvtsd2siY", Gv, EX, XX },
14384 + { "cvttps2pi", MX, EX, XX },
14385 + { "cvttss2siY", Gv, EX, XX },
14386 + { "cvttpd2pi", MX, EX, XX },
14387 + { "cvttsd2siY", Gv, EX, XX },
14391 + { "divps", XM, EX, XX },
14392 + { "divss", XM, EX, XX },
14393 + { "divpd", XM, EX, XX },
14394 + { "divsd", XM, EX, XX },
14398 + { "maxps", XM, EX, XX },
14399 + { "maxss", XM, EX, XX },
14400 + { "maxpd", XM, EX, XX },
14401 + { "maxsd", XM, EX, XX },
14405 + { "minps", XM, EX, XX },
14406 + { "minss", XM, EX, XX },
14407 + { "minpd", XM, EX, XX },
14408 + { "minsd", XM, EX, XX },
14412 + { "movups", XM, EX, XX },
14413 + { "movss", XM, EX, XX },
14414 + { "movupd", XM, EX, XX },
14415 + { "movsd", XM, EX, XX },
14419 + { "movups", EX, XM, XX },
14420 + { "movss", EX, XM, XX },
14421 + { "movupd", EX, XM, XX },
14422 + { "movsd", EX, XM, XX },
14426 + { "mulps", XM, EX, XX },
14427 + { "mulss", XM, EX, XX },
14428 + { "mulpd", XM, EX, XX },
14429 + { "mulsd", XM, EX, XX },
14433 + { "rcpps", XM, EX, XX },
14434 + { "rcpss", XM, EX, XX },
14435 + { "(bad)", XM, EX, XX },
14436 + { "(bad)", XM, EX, XX },
14440 + { "rsqrtps", XM, EX, XX },
14441 + { "rsqrtss", XM, EX, XX },
14442 + { "(bad)", XM, EX, XX },
14443 + { "(bad)", XM, EX, XX },
14447 + { "sqrtps", XM, EX, XX },
14448 + { "sqrtss", XM, EX, XX },
14449 + { "sqrtpd", XM, EX, XX },
14450 + { "sqrtsd", XM, EX, XX },
14454 + { "subps", XM, EX, XX },
14455 + { "subss", XM, EX, XX },
14456 + { "subpd", XM, EX, XX },
14457 + { "subsd", XM, EX, XX },
14461 + { "(bad)", XM, EX, XX },
14462 + { "cvtdq2pd", XM, EX, XX },
14463 + { "cvttpd2dq", XM, EX, XX },
14464 + { "cvtpd2dq", XM, EX, XX },
14468 + { "cvtdq2ps", XM, EX, XX },
14469 + { "cvttps2dq",XM, EX, XX },
14470 + { "cvtps2dq",XM, EX, XX },
14471 + { "(bad)", XM, EX, XX },
14475 + { "cvtps2pd", XM, EX, XX },
14476 + { "cvtss2sd", XM, EX, XX },
14477 + { "cvtpd2ps", XM, EX, XX },
14478 + { "cvtsd2ss", XM, EX, XX },
14482 + { "maskmovq", MX, MS, XX },
14483 + { "(bad)", XM, EX, XX },
14484 + { "maskmovdqu", XM, EX, XX },
14485 + { "(bad)", XM, EX, XX },
14489 + { "movq", MX, EM, XX },
14490 + { "movdqu", XM, EX, XX },
14491 + { "movdqa", XM, EX, XX },
14492 + { "(bad)", XM, EX, XX },
14496 + { "movq", EM, MX, XX },
14497 + { "movdqu", EX, XM, XX },
14498 + { "movdqa", EX, XM, XX },
14499 + { "(bad)", EX, XM, XX },
14503 + { "(bad)", EX, XM, XX },
14504 + { "movq2dq", XM, MS, XX },
14505 + { "movq", EX, XM, XX },
14506 + { "movdq2q", MX, XS, XX },
14510 + { "pshufw", MX, EM, Ib },
14511 + { "pshufhw", XM, EX, Ib },
14512 + { "pshufd", XM, EX, Ib },
14513 + { "pshuflw", XM, EX, Ib },
14517 + { "movd", Edq, MX, XX },
14518 + { "movq", XM, EX, XX },
14519 + { "movd", Edq, XM, XX },
14520 + { "(bad)", Ed, XM, XX },
14524 + { "(bad)", MX, EX, XX },
14525 + { "(bad)", XM, EX, XX },
14526 + { "punpckhqdq", XM, EX, XX },
14527 + { "(bad)", XM, EX, XX },
14531 + { "movntq", EM, MX, XX },
14532 + { "(bad)", EM, XM, XX },
14533 + { "movntdq", EM, XM, XX },
14534 + { "(bad)", EM, XM, XX },
14538 + { "(bad)", MX, EX, XX },
14539 + { "(bad)", XM, EX, XX },
14540 + { "punpcklqdq", XM, EX, XX },
14541 + { "(bad)", XM, EX, XX },
14545 + { "(bad)", MX, EX, XX },
14546 + { "(bad)", XM, EX, XX },
14547 + { "addsubpd", XM, EX, XX },
14548 + { "addsubps", XM, EX, XX },
14552 + { "(bad)", MX, EX, XX },
14553 + { "(bad)", XM, EX, XX },
14554 + { "haddpd", XM, EX, XX },
14555 + { "haddps", XM, EX, XX },
14559 + { "(bad)", MX, EX, XX },
14560 + { "(bad)", XM, EX, XX },
14561 + { "hsubpd", XM, EX, XX },
14562 + { "hsubps", XM, EX, XX },
14566 + { "movlpX", XM, EX, SIMD_Fixup, 'h' }, /* really only 2 operands */
14567 + { "movsldup", XM, EX, XX },
14568 + { "movlpd", XM, EX, XX },
14569 + { "movddup", XM, EX, XX },
14573 + { "movhpX", XM, EX, SIMD_Fixup, 'l' },
14574 + { "movshdup", XM, EX, XX },
14575 + { "movhpd", XM, EX, XX },
14576 + { "(bad)", XM, EX, XX },
14580 + { "(bad)", XM, EX, XX },
14581 + { "(bad)", XM, EX, XX },
14582 + { "(bad)", XM, EX, XX },
14583 + { "lddqu", XM, M, XX },
14587 +static const struct dis386 x86_64_table[][2] = {
14589 + { "arpl", Ew, Gw, XX },
14590 + { "movs{||lq|xd}", Gv, Ed, XX },
14595 +#define INTERNAL_DISASSEMBLER_ERROR "<internal disassembler error>"
14596 +#else /* __KERNEL__ */
14597 +#define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
14598 +#endif /* __KERNEL__ */
14606 + used_prefixes = 0;
14610 + FETCH_DATA (the_info, codep + 1);
14614 + /* REX prefixes family. */
14637 + prefixes |= PREFIX_REPZ;
14640 + prefixes |= PREFIX_REPNZ;
14643 + prefixes |= PREFIX_LOCK;
14646 + prefixes |= PREFIX_CS;
14649 + prefixes |= PREFIX_SS;
14652 + prefixes |= PREFIX_DS;
14655 + prefixes |= PREFIX_ES;
14658 + prefixes |= PREFIX_FS;
14661 + prefixes |= PREFIX_GS;
14664 + prefixes |= PREFIX_DATA;
14667 + prefixes |= PREFIX_ADDR;
14669 + case FWAIT_OPCODE:
14670 + /* fwait is really an instruction. If there are prefixes
14671 + before the fwait, they belong to the fwait, *not* to the
14672 + following instruction. */
14675 + prefixes |= PREFIX_FWAIT;
14679 + prefixes = PREFIX_FWAIT;
14684 + /* Rex is ignored when followed by another prefix. */
14687 + oappend (prefix_name (rex, 0));
14695 +/* Return the name of the prefix byte PREF, or NULL if PREF is not a
14698 +static const char *
14699 +prefix_name (int pref, int sizeflag)
14703 + /* REX prefixes family. */
14727 + return "rex64YZ";
14731 + return "rex64XZ";
14733 + return "rex64XY";
14735 + return "rex64XYZ";
14755 + return (sizeflag & DFLAG) ? "data16" : "data32";
14758 + return (sizeflag & AFLAG) ? "addr32" : "addr64";
14760 + return (sizeflag & AFLAG) ? "addr16" : "addr32";
14761 + case FWAIT_OPCODE:
14768 +static char op1out[100], op2out[100], op3out[100];
14769 +static int op_ad, op_index[3];
14770 +static int two_source_ops;
14771 +static bfd_vma op_address[3];
14772 +static bfd_vma op_riprel[3];
14773 +static bfd_vma start_pc;
14776 + * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
14777 + * (see topic "Redundant prefixes" in the "Differences from 8086"
14778 + * section of the "Virtual 8086 Mode" chapter.)
14779 + * 'pc' should be the address of this instruction, it will
14780 + * be used to print the target address if this is a relative jump or call
14781 + * The function returns the length of this instruction in bytes.
14784 +static char intel_syntax;
14785 +static char open_char;
14786 +static char close_char;
14787 +static char separator_char;
14788 +static char scale_char;
14790 +/* Here for backwards compatibility. When gdb stops using
14791 + print_insn_i386_att and print_insn_i386_intel these functions can
14792 + disappear, and print_insn_i386 be merged into print_insn. */
14794 +print_insn_i386_att (bfd_vma pc, disassemble_info *info)
14796 + intel_syntax = 0;
14798 + return print_insn (pc, info);
14802 +print_insn_i386_intel (bfd_vma pc, disassemble_info *info)
14804 + intel_syntax = 1;
14806 + return print_insn (pc, info);
14810 +print_insn_i386 (bfd_vma pc, disassemble_info *info)
14812 + intel_syntax = -1;
14814 + return print_insn (pc, info);
14818 +print_insn (bfd_vma pc, disassemble_info *info)
14820 + const struct dis386 *dp;
14822 + char *first, *second, *third;
14824 + unsigned char uses_SSE_prefix, uses_LOCK_prefix;
14827 + struct dis_private priv;
14829 + mode_64bit = (info->mach == bfd_mach_x86_64_intel_syntax
14830 + || info->mach == bfd_mach_x86_64);
14832 + if (intel_syntax == (char) -1)
14833 + intel_syntax = (info->mach == bfd_mach_i386_i386_intel_syntax
14834 + || info->mach == bfd_mach_x86_64_intel_syntax);
14836 + if (info->mach == bfd_mach_i386_i386
14837 + || info->mach == bfd_mach_x86_64
14838 + || info->mach == bfd_mach_i386_i386_intel_syntax
14839 + || info->mach == bfd_mach_x86_64_intel_syntax)
14840 + priv.orig_sizeflag = AFLAG | DFLAG;
14841 + else if (info->mach == bfd_mach_i386_i8086)
14842 + priv.orig_sizeflag = 0;
14846 + for (p = info->disassembler_options; p != NULL; )
14848 + if (strncmp (p, "x86-64", 6) == 0)
14851 + priv.orig_sizeflag = AFLAG | DFLAG;
14853 + else if (strncmp (p, "i386", 4) == 0)
14856 + priv.orig_sizeflag = AFLAG | DFLAG;
14858 + else if (strncmp (p, "i8086", 5) == 0)
14861 + priv.orig_sizeflag = 0;
14863 + else if (strncmp (p, "intel", 5) == 0)
14865 + intel_syntax = 1;
14867 + else if (strncmp (p, "att", 3) == 0)
14869 + intel_syntax = 0;
14871 + else if (strncmp (p, "addr", 4) == 0)
14873 + if (p[4] == '1' && p[5] == '6')
14874 + priv.orig_sizeflag &= ~AFLAG;
14875 + else if (p[4] == '3' && p[5] == '2')
14876 + priv.orig_sizeflag |= AFLAG;
14878 + else if (strncmp (p, "data", 4) == 0)
14880 + if (p[4] == '1' && p[5] == '6')
14881 + priv.orig_sizeflag &= ~DFLAG;
14882 + else if (p[4] == '3' && p[5] == '2')
14883 + priv.orig_sizeflag |= DFLAG;
14885 + else if (strncmp (p, "suffix", 6) == 0)
14886 + priv.orig_sizeflag |= SUFFIX_ALWAYS;
14888 + p = strchr (p, ',');
14893 + if (intel_syntax)
14895 + names64 = intel_names64;
14896 + names32 = intel_names32;
14897 + names16 = intel_names16;
14898 + names8 = intel_names8;
14899 + names8rex = intel_names8rex;
14900 + names_seg = intel_names_seg;
14901 + index16 = intel_index16;
14903 + close_char = ']';
14904 + separator_char = '+';
14905 + scale_char = '*';
14909 + names64 = att_names64;
14910 + names32 = att_names32;
14911 + names16 = att_names16;
14912 + names8 = att_names8;
14913 + names8rex = att_names8rex;
14914 + names_seg = att_names_seg;
14915 + index16 = att_index16;
14917 + close_char = ')';
14918 + separator_char = ',';
14919 + scale_char = ',';
14922 + /* The output looks better if we put 7 bytes on a line, since that
14923 + puts most long word instructions on a single line. */
14924 + info->bytes_per_line = 7;
14926 + info->private_data = &priv;
14927 + priv.max_fetched = priv.the_buffer;
14928 + priv.insn_start = pc;
14935 + op_index[0] = op_index[1] = op_index[2] = -1;
14939 + start_codep = priv.the_buffer;
14940 + codep = priv.the_buffer;
14942 +#ifndef __KERNEL__
14943 + if (setjmp (priv.bailout) != 0)
14945 + const char *name;
14947 + /* Getting here means we tried for data but didn't get it. That
14948 + means we have an incomplete instruction of some sort. Just
14949 + print the first byte as a prefix or a .byte pseudo-op. */
14950 + if (codep > priv.the_buffer)
14952 + name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
14953 + if (name != NULL)
14954 + (*info->fprintf_func) (info->stream, "%s", name);
14957 + /* Just print the first byte as a .byte instruction. */
14958 + (*info->fprintf_func) (info->stream, ".byte 0x%x",
14959 + (unsigned int) priv.the_buffer[0]);
14967 +#endif /* __KERNEL__ */
14972 + insn_codep = codep;
14973 + sizeflag = priv.orig_sizeflag;
14975 + FETCH_DATA (info, codep + 1);
14976 + two_source_ops = (*codep == 0x62) || (*codep == 0xc8);
14978 + if ((prefixes & PREFIX_FWAIT)
14979 + && ((*codep < 0xd8) || (*codep > 0xdf)))
14981 + const char *name;
14983 + /* fwait not followed by floating point instruction. Print the
14984 + first prefix, which is probably fwait itself. */
14985 + name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
14986 + if (name == NULL)
14987 + name = INTERNAL_DISASSEMBLER_ERROR;
14988 + (*info->fprintf_func) (info->stream, "%s", name);
14992 + if (*codep == 0x0f)
14994 + FETCH_DATA (info, codep + 2);
14995 + dp = &dis386_twobyte[*++codep];
14996 + need_modrm = twobyte_has_modrm[*codep];
14997 + uses_SSE_prefix = twobyte_uses_SSE_prefix[*codep];
14998 + uses_LOCK_prefix = (*codep & ~0x02) == 0x20;
15002 + dp = &dis386[*codep];
15003 + need_modrm = onebyte_has_modrm[*codep];
15004 + uses_SSE_prefix = 0;
15005 + uses_LOCK_prefix = 0;
15009 + if (!uses_SSE_prefix && (prefixes & PREFIX_REPZ))
15011 + oappend ("repz ");
15012 + used_prefixes |= PREFIX_REPZ;
15014 + if (!uses_SSE_prefix && (prefixes & PREFIX_REPNZ))
15016 + oappend ("repnz ");
15017 + used_prefixes |= PREFIX_REPNZ;
15019 + if (!uses_LOCK_prefix && (prefixes & PREFIX_LOCK))
15021 + oappend ("lock ");
15022 + used_prefixes |= PREFIX_LOCK;
15025 + if (prefixes & PREFIX_ADDR)
15027 + sizeflag ^= AFLAG;
15028 + if (dp->bytemode3 != loop_jcxz_mode || intel_syntax)
15030 + if ((sizeflag & AFLAG) || mode_64bit)
15031 + oappend ("addr32 ");
15033 + oappend ("addr16 ");
15034 + used_prefixes |= PREFIX_ADDR;
15038 + if (!uses_SSE_prefix && (prefixes & PREFIX_DATA))
15040 + sizeflag ^= DFLAG;
15041 + if (dp->bytemode3 == cond_jump_mode
15042 + && dp->bytemode1 == v_mode
15043 + && !intel_syntax)
15045 + if (sizeflag & DFLAG)
15046 + oappend ("data32 ");
15048 + oappend ("data16 ");
15049 + used_prefixes |= PREFIX_DATA;
15055 + FETCH_DATA (info, codep + 1);
15056 + mod = (*codep >> 6) & 3;
15057 + reg = (*codep >> 3) & 7;
15061 + if (dp->name == NULL && dp->bytemode1 == FLOATCODE)
15063 + dofloat (sizeflag);
15068 + if (dp->name == NULL)
15070 + switch (dp->bytemode1)
15073 + dp = &grps[dp->bytemode2][reg];
15076 + case USE_PREFIX_USER_TABLE:
15078 + used_prefixes |= (prefixes & PREFIX_REPZ);
15079 + if (prefixes & PREFIX_REPZ)
15083 + used_prefixes |= (prefixes & PREFIX_DATA);
15084 + if (prefixes & PREFIX_DATA)
15088 + used_prefixes |= (prefixes & PREFIX_REPNZ);
15089 + if (prefixes & PREFIX_REPNZ)
15093 + dp = &prefix_user_table[dp->bytemode2][index];
15096 + case X86_64_SPECIAL:
15097 + dp = &x86_64_table[dp->bytemode2][mode_64bit];
15101 + oappend (INTERNAL_DISASSEMBLER_ERROR);
15106 + if (putop (dp->name, sizeflag) == 0)
15111 + (*dp->op1) (dp->bytemode1, sizeflag);
15116 + (*dp->op2) (dp->bytemode2, sizeflag);
15121 + (*dp->op3) (dp->bytemode3, sizeflag);
15125 + /* See if any prefixes were not used. If so, print the first one
15126 + separately. If we don't do this, we'll wind up printing an
15127 + instruction stream which does not precisely correspond to the
15128 + bytes we are disassembling. */
15129 + if ((prefixes & ~used_prefixes) != 0)
15131 + const char *name;
15133 + name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
15134 + if (name == NULL)
15135 + name = INTERNAL_DISASSEMBLER_ERROR;
15136 + (*info->fprintf_func) (info->stream, "%s", name);
15139 + if (rex & ~rex_used)
15141 + const char *name;
15142 + name = prefix_name (rex | 0x40, priv.orig_sizeflag);
15143 + if (name == NULL)
15144 + name = INTERNAL_DISASSEMBLER_ERROR;
15145 + (*info->fprintf_func) (info->stream, "%s ", name);
15148 + obufp = obuf + strlen (obuf);
15149 + for (i = strlen (obuf); i < 6; i++)
15152 + (*info->fprintf_func) (info->stream, "%s", obuf);
15154 + /* The enter and bound instructions are printed with operands in the same
15155 + order as the intel book; everything else is printed in reverse order. */
15156 + if (intel_syntax || two_source_ops)
15161 + op_ad = op_index[0];
15162 + op_index[0] = op_index[2];
15163 + op_index[2] = op_ad;
15174 + if (op_index[0] != -1 && !op_riprel[0])
15175 + (*info->print_address_func) ((bfd_vma) op_address[op_index[0]], info);
15177 + (*info->fprintf_func) (info->stream, "%s", first);
15183 + (*info->fprintf_func) (info->stream, ",");
15184 + if (op_index[1] != -1 && !op_riprel[1])
15185 + (*info->print_address_func) ((bfd_vma) op_address[op_index[1]], info);
15187 + (*info->fprintf_func) (info->stream, "%s", second);
15193 + (*info->fprintf_func) (info->stream, ",");
15194 + if (op_index[2] != -1 && !op_riprel[2])
15195 + (*info->print_address_func) ((bfd_vma) op_address[op_index[2]], info);
15197 + (*info->fprintf_func) (info->stream, "%s", third);
15199 + for (i = 0; i < 3; i++)
15200 + if (op_index[i] != -1 && op_riprel[i])
15202 + (*info->fprintf_func) (info->stream, " # ");
15203 + (*info->print_address_func) ((bfd_vma) (start_pc + codep - start_codep
15204 + + op_address[op_index[i]]), info);
15206 + return codep - priv.the_buffer;
15209 +static const char *float_mem[] = {
15257 + "fisttp{ll||ll|}",
15281 + "fistp{ll||ll|}",
15284 +static const unsigned char float_mem_mode[] = {
15359 +#define ST OP_ST, 0
15360 +#define STi OP_STi, 0
15362 +#define FGRPd9_2 NULL, NULL, 0, NULL, 0, NULL, 0
15363 +#define FGRPd9_4 NULL, NULL, 1, NULL, 0, NULL, 0
15364 +#define FGRPd9_5 NULL, NULL, 2, NULL, 0, NULL, 0
15365 +#define FGRPd9_6 NULL, NULL, 3, NULL, 0, NULL, 0
15366 +#define FGRPd9_7 NULL, NULL, 4, NULL, 0, NULL, 0
15367 +#define FGRPda_5 NULL, NULL, 5, NULL, 0, NULL, 0
15368 +#define FGRPdb_4 NULL, NULL, 6, NULL, 0, NULL, 0
15369 +#define FGRPde_3 NULL, NULL, 7, NULL, 0, NULL, 0
15370 +#define FGRPdf_4 NULL, NULL, 8, NULL, 0, NULL, 0
15372 +static const struct dis386 float_reg[][8] = {
15375 + { "fadd", ST, STi, XX },
15376 + { "fmul", ST, STi, XX },
15377 + { "fcom", STi, XX, XX },
15378 + { "fcomp", STi, XX, XX },
15379 + { "fsub", ST, STi, XX },
15380 + { "fsubr", ST, STi, XX },
15381 + { "fdiv", ST, STi, XX },
15382 + { "fdivr", ST, STi, XX },
15386 + { "fld", STi, XX, XX },
15387 + { "fxch", STi, XX, XX },
15389 + { "(bad)", XX, XX, XX },
15397 + { "fcmovb", ST, STi, XX },
15398 + { "fcmove", ST, STi, XX },
15399 + { "fcmovbe",ST, STi, XX },
15400 + { "fcmovu", ST, STi, XX },
15401 + { "(bad)", XX, XX, XX },
15403 + { "(bad)", XX, XX, XX },
15404 + { "(bad)", XX, XX, XX },
15408 + { "fcmovnb",ST, STi, XX },
15409 + { "fcmovne",ST, STi, XX },
15410 + { "fcmovnbe",ST, STi, XX },
15411 + { "fcmovnu",ST, STi, XX },
15413 + { "fucomi", ST, STi, XX },
15414 + { "fcomi", ST, STi, XX },
15415 + { "(bad)", XX, XX, XX },
15419 + { "fadd", STi, ST, XX },
15420 + { "fmul", STi, ST, XX },
15421 + { "(bad)", XX, XX, XX },
15422 + { "(bad)", XX, XX, XX },
15423 +#if UNIXWARE_COMPAT
15424 + { "fsub", STi, ST, XX },
15425 + { "fsubr", STi, ST, XX },
15426 + { "fdiv", STi, ST, XX },
15427 + { "fdivr", STi, ST, XX },
15429 + { "fsubr", STi, ST, XX },
15430 + { "fsub", STi, ST, XX },
15431 + { "fdivr", STi, ST, XX },
15432 + { "fdiv", STi, ST, XX },
15437 + { "ffree", STi, XX, XX },
15438 + { "(bad)", XX, XX, XX },
15439 + { "fst", STi, XX, XX },
15440 + { "fstp", STi, XX, XX },
15441 + { "fucom", STi, XX, XX },
15442 + { "fucomp", STi, XX, XX },
15443 + { "(bad)", XX, XX, XX },
15444 + { "(bad)", XX, XX, XX },
15448 + { "faddp", STi, ST, XX },
15449 + { "fmulp", STi, ST, XX },
15450 + { "(bad)", XX, XX, XX },
15452 +#if UNIXWARE_COMPAT
15453 + { "fsubp", STi, ST, XX },
15454 + { "fsubrp", STi, ST, XX },
15455 + { "fdivp", STi, ST, XX },
15456 + { "fdivrp", STi, ST, XX },
15458 + { "fsubrp", STi, ST, XX },
15459 + { "fsubp", STi, ST, XX },
15460 + { "fdivrp", STi, ST, XX },
15461 + { "fdivp", STi, ST, XX },
15466 + { "ffreep", STi, XX, XX },
15467 + { "(bad)", XX, XX, XX },
15468 + { "(bad)", XX, XX, XX },
15469 + { "(bad)", XX, XX, XX },
15471 + { "fucomip",ST, STi, XX },
15472 + { "fcomip", ST, STi, XX },
15473 + { "(bad)", XX, XX, XX },
15477 +static char *fgrps[][8] = {
15480 + "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
15485 + "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
15490 + "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
15495 + "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
15500 + "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
15505 + "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
15510 + "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
15511 + "fNsetpm(287 only)","(bad)","(bad)","(bad)",
15516 + "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
15521 + "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
15526 +dofloat (int sizeflag)
15528 + const struct dis386 *dp;
15529 + unsigned char floatop;
15531 + floatop = codep[-1];
15535 + int fp_indx = (floatop - 0xd8) * 8 + reg;
15537 + putop (float_mem[fp_indx], sizeflag);
15539 + OP_E (float_mem_mode[fp_indx], sizeflag);
15542 + /* Skip mod/rm byte. */
15546 + dp = &float_reg[floatop - 0xd8][reg];
15547 + if (dp->name == NULL)
15549 + putop (fgrps[dp->bytemode1][rm], sizeflag);
15551 + /* Instruction fnstsw is only one with strange arg. */
15552 + if (floatop == 0xdf && codep[-1] == 0xe0)
15553 + strcpy (op1out, names16[0]);
15557 + putop (dp->name, sizeflag);
15561 + (*dp->op1) (dp->bytemode1, sizeflag);
15564 + (*dp->op2) (dp->bytemode2, sizeflag);
15569 +OP_ST (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
15575 +OP_STi (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
15577 + sprintf (scratchbuf, "%%st(%d)", rm);
15578 + oappend (scratchbuf + intel_syntax);
15581 +/* Capital letters in template are macros. */
15583 +putop (const char *template, int sizeflag)
15588 + for (p = template; *p; p++)
15597 + if (intel_syntax)
15603 + while (*++p != '|')
15607 + /* Alternative not valid. */
15608 + strcpy (obuf, "(bad)");
15609 + obufp = obuf + 5;
15612 + else if (*p == '\0')
15617 + /* Fall through. */
15622 + while (*++p != '}')
15631 + if (intel_syntax)
15633 + if (mod != 3 || (sizeflag & SUFFIX_ALWAYS))
15637 + if (intel_syntax)
15639 + if (sizeflag & SUFFIX_ALWAYS)
15643 + if (intel_syntax && !alt)
15645 + if ((prefixes & PREFIX_DATA) || (sizeflag & SUFFIX_ALWAYS))
15647 + if (sizeflag & DFLAG)
15648 + *obufp++ = intel_syntax ? 'd' : 'l';
15650 + *obufp++ = intel_syntax ? 'w' : 's';
15651 + used_prefixes |= (prefixes & PREFIX_DATA);
15654 + case 'E': /* For jcxz/jecxz */
15657 + if (sizeflag & AFLAG)
15663 + if (sizeflag & AFLAG)
15665 + used_prefixes |= (prefixes & PREFIX_ADDR);
15668 + if (intel_syntax)
15670 + if ((prefixes & PREFIX_ADDR) || (sizeflag & SUFFIX_ALWAYS))
15672 + if (sizeflag & AFLAG)
15673 + *obufp++ = mode_64bit ? 'q' : 'l';
15675 + *obufp++ = mode_64bit ? 'l' : 'w';
15676 + used_prefixes |= (prefixes & PREFIX_ADDR);
15680 + if (intel_syntax)
15682 + if ((prefixes & (PREFIX_CS | PREFIX_DS)) == PREFIX_CS
15683 + || (prefixes & (PREFIX_CS | PREFIX_DS)) == PREFIX_DS)
15685 + used_prefixes |= prefixes & (PREFIX_CS | PREFIX_DS);
15688 + if (prefixes & PREFIX_DS)
15695 + if (intel_syntax)
15700 + if (intel_syntax)
15702 + if (sizeflag & SUFFIX_ALWAYS)
15706 + if ((prefixes & PREFIX_FWAIT) == 0)
15709 + used_prefixes |= PREFIX_FWAIT;
15712 + USED_REX (REX_MODE64);
15713 + if (rex & REX_MODE64)
15719 + if (intel_syntax)
15726 + /* Fall through. */
15728 + if (intel_syntax)
15730 + if ((prefixes & PREFIX_DATA)
15731 + || (rex & REX_MODE64)
15732 + || (sizeflag & SUFFIX_ALWAYS))
15734 + USED_REX (REX_MODE64);
15735 + if (rex & REX_MODE64)
15739 + if (sizeflag & DFLAG)
15743 + used_prefixes |= (prefixes & PREFIX_DATA);
15748 + if (intel_syntax)
15755 + /* Fall through. */
15757 + if (intel_syntax && !alt)
15759 + USED_REX (REX_MODE64);
15760 + if (mod != 3 || (sizeflag & SUFFIX_ALWAYS))
15762 + if (rex & REX_MODE64)
15766 + if (sizeflag & DFLAG)
15767 + *obufp++ = intel_syntax ? 'd' : 'l';
15770 + used_prefixes |= (prefixes & PREFIX_DATA);
15775 + USED_REX (REX_MODE64);
15776 + if (intel_syntax)
15778 + if (rex & REX_MODE64)
15783 + else if (sizeflag & DFLAG)
15796 + if (rex & REX_MODE64)
15798 + else if (sizeflag & DFLAG)
15803 + if (!(rex & REX_MODE64))
15804 + used_prefixes |= (prefixes & PREFIX_DATA);
15807 + if (intel_syntax)
15809 + if (sizeflag & SUFFIX_ALWAYS)
15811 + if (rex & REX_MODE64)
15815 + if (sizeflag & DFLAG)
15819 + used_prefixes |= (prefixes & PREFIX_DATA);
15824 + if (prefixes & PREFIX_DATA)
15828 + used_prefixes |= (prefixes & PREFIX_DATA);
15831 + if (intel_syntax)
15833 + if (rex & REX_MODE64)
15835 + USED_REX (REX_MODE64);
15839 + /* implicit operand size 'l' for i386 or 'q' for x86-64 */
15841 + /* operand size flag for cwtl, cbtw */
15845 + else if (sizeflag & DFLAG)
15849 + if (intel_syntax)
15856 + if (sizeflag & DFLAG)
15867 + used_prefixes |= (prefixes & PREFIX_DATA);
15877 +oappend (const char *s)
15879 + strcpy (obufp, s);
15880 + obufp += strlen (s);
15886 + if (prefixes & PREFIX_CS)
15888 + used_prefixes |= PREFIX_CS;
15889 + oappend ("%cs:" + intel_syntax);
15891 + if (prefixes & PREFIX_DS)
15893 + used_prefixes |= PREFIX_DS;
15894 + oappend ("%ds:" + intel_syntax);
15896 + if (prefixes & PREFIX_SS)
15898 + used_prefixes |= PREFIX_SS;
15899 + oappend ("%ss:" + intel_syntax);
15901 + if (prefixes & PREFIX_ES)
15903 + used_prefixes |= PREFIX_ES;
15904 + oappend ("%es:" + intel_syntax);
15906 + if (prefixes & PREFIX_FS)
15908 + used_prefixes |= PREFIX_FS;
15909 + oappend ("%fs:" + intel_syntax);
15911 + if (prefixes & PREFIX_GS)
15913 + used_prefixes |= PREFIX_GS;
15914 + oappend ("%gs:" + intel_syntax);
15919 +OP_indirE (int bytemode, int sizeflag)
15921 + if (!intel_syntax)
15923 + OP_E (bytemode, sizeflag);
15927 +print_operand_value (char *buf, int hex, bfd_vma disp)
15937 + sprintf_vma (tmp, disp);
15938 + for (i = 0; tmp[i] == '0' && tmp[i + 1]; i++);
15939 + strcpy (buf + 2, tmp + i);
15943 + bfd_signed_vma v = disp;
15950 + /* Check for possible overflow on 0x8000000000000000. */
15953 + strcpy (buf, "9223372036854775808");
15959 + strcpy (buf, "0");
15967 + tmp[28 - i] = (v % 10) + '0';
15971 + strcpy (buf, tmp + 29 - i);
15977 + sprintf (buf, "0x%x", (unsigned int) disp);
15979 + sprintf (buf, "%d", (int) disp);
15984 +OP_E (int bytemode, int sizeflag)
15989 + USED_REX (REX_EXTZ);
15990 + if (rex & REX_EXTZ)
15993 + /* Skip mod/rm byte. */
15999 + switch (bytemode)
16004 + oappend (names8rex[rm + add]);
16006 + oappend (names8[rm + add]);
16009 + oappend (names16[rm + add]);
16012 + oappend (names32[rm + add]);
16015 + oappend (names64[rm + add]);
16019 + oappend (names64[rm + add]);
16021 + oappend (names32[rm + add]);
16023 + case branch_v_mode:
16025 + oappend (names64[rm + add]);
16028 + if ((sizeflag & DFLAG) || bytemode != branch_v_mode)
16029 + oappend (names32[rm + add]);
16031 + oappend (names16[rm + add]);
16032 + used_prefixes |= (prefixes & PREFIX_DATA);
16038 + USED_REX (REX_MODE64);
16039 + if (rex & REX_MODE64)
16040 + oappend (names64[rm + add]);
16041 + else if ((sizeflag & DFLAG) || bytemode != v_mode)
16042 + oappend (names32[rm + add]);
16044 + oappend (names16[rm + add]);
16045 + used_prefixes |= (prefixes & PREFIX_DATA);
16050 + oappend (INTERNAL_DISASSEMBLER_ERROR);
16059 + if ((sizeflag & AFLAG) || mode_64bit) /* 32 bit address mode */
16074 + FETCH_DATA (the_info, codep + 1);
16075 + index = (*codep >> 3) & 7;
16076 + if (mode_64bit || index != 0x4)
16077 + /* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
16078 + scale = (*codep >> 6) & 3;
16079 + base = *codep & 7;
16080 + USED_REX (REX_EXTY);
16081 + if (rex & REX_EXTY)
16090 + if ((base & 7) == 5)
16093 + if (mode_64bit && !havesib)
16095 + disp = get32s ();
16099 + FETCH_DATA (the_info, codep + 1);
16101 + if ((disp & 0x80) != 0)
16105 + disp = get32s ();
16109 + if (!intel_syntax)
16110 + if (mod != 0 || (base & 7) == 5)
16112 + print_operand_value (scratchbuf, !riprel, disp);
16113 + oappend (scratchbuf);
16116 + set_op (disp, 1);
16117 + oappend ("(%rip)");
16121 + if (havebase || (havesib && (index != 4 || scale != 0)))
16123 + if (intel_syntax)
16125 + switch (bytemode)
16128 + oappend ("BYTE PTR ");
16132 + oappend ("WORD PTR ");
16134 + case branch_v_mode:
16137 + USED_REX (REX_MODE64);
16138 + if (rex & REX_MODE64)
16139 + oappend ("QWORD PTR ");
16140 + else if ((sizeflag & DFLAG) || bytemode == dq_mode)
16141 + oappend ("DWORD PTR ");
16143 + oappend ("WORD PTR ");
16144 + used_prefixes |= (prefixes & PREFIX_DATA);
16147 + oappend ("DWORD PTR ");
16150 + oappend ("QWORD PTR ");
16154 + oappend ("QWORD PTR ");
16156 + oappend ("DWORD PTR ");
16159 + if (sizeflag & DFLAG)
16161 + used_prefixes |= (prefixes & PREFIX_DATA);
16162 + oappend ("FWORD PTR ");
16165 + oappend ("DWORD PTR ");
16168 + oappend ("TBYTE PTR ");
16171 + oappend ("XMMWORD PTR ");
16177 + *obufp++ = open_char;
16178 + if (intel_syntax && riprel)
16179 + oappend ("rip + ");
16182 + oappend (mode_64bit && (sizeflag & AFLAG)
16183 + ? names64[base] : names32[base]);
16188 + if (!intel_syntax || havebase)
16190 + *obufp++ = separator_char;
16193 + oappend (mode_64bit && (sizeflag & AFLAG)
16194 + ? names64[index] : names32[index]);
16196 + if (scale != 0 || (!intel_syntax && index != 4))
16198 + *obufp++ = scale_char;
16200 + sprintf (scratchbuf, "%d", 1 << scale);
16201 + oappend (scratchbuf);
16204 + if (intel_syntax && disp)
16206 + if ((bfd_signed_vma) disp > 0)
16211 + else if (mod != 1)
16215 + disp = - (bfd_signed_vma) disp;
16218 + print_operand_value (scratchbuf, mod != 1, disp);
16219 + oappend (scratchbuf);
16222 + *obufp++ = close_char;
16225 + else if (intel_syntax)
16227 + if (mod != 0 || (base & 7) == 5)
16229 + if (prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
16230 + | PREFIX_ES | PREFIX_FS | PREFIX_GS))
16234 + oappend (names_seg[ds_reg - es_reg]);
16237 + print_operand_value (scratchbuf, 1, disp);
16238 + oappend (scratchbuf);
16243 + { /* 16 bit address mode */
16250 + if ((disp & 0x8000) != 0)
16255 + FETCH_DATA (the_info, codep + 1);
16257 + if ((disp & 0x80) != 0)
16262 + if ((disp & 0x8000) != 0)
16267 + if (!intel_syntax)
16268 + if (mod != 0 || rm == 6)
16270 + print_operand_value (scratchbuf, 0, disp);
16271 + oappend (scratchbuf);
16274 + if (mod != 0 || rm != 6)
16276 + *obufp++ = open_char;
16278 + oappend (index16[rm]);
16279 + if (intel_syntax && disp)
16281 + if ((bfd_signed_vma) disp > 0)
16286 + else if (mod != 1)
16290 + disp = - (bfd_signed_vma) disp;
16293 + print_operand_value (scratchbuf, mod != 1, disp);
16294 + oappend (scratchbuf);
16297 + *obufp++ = close_char;
16300 + else if (intel_syntax)
16302 + if (prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
16303 + | PREFIX_ES | PREFIX_FS | PREFIX_GS))
16307 + oappend (names_seg[ds_reg - es_reg]);
16310 + print_operand_value (scratchbuf, 1, disp & 0xffff);
16311 + oappend (scratchbuf);
16317 +OP_G (int bytemode, int sizeflag)
16320 + USED_REX (REX_EXTX);
16321 + if (rex & REX_EXTX)
16323 + switch (bytemode)
16328 + oappend (names8rex[reg + add]);
16330 + oappend (names8[reg + add]);
16333 + oappend (names16[reg + add]);
16336 + oappend (names32[reg + add]);
16339 + oappend (names64[reg + add]);
16344 + USED_REX (REX_MODE64);
16345 + if (rex & REX_MODE64)
16346 + oappend (names64[reg + add]);
16347 + else if ((sizeflag & DFLAG) || bytemode != v_mode)
16348 + oappend (names32[reg + add]);
16350 + oappend (names16[reg + add]);
16351 + used_prefixes |= (prefixes & PREFIX_DATA);
16355 + oappend (names64[reg + add]);
16357 + oappend (names32[reg + add]);
16360 + oappend (INTERNAL_DISASSEMBLER_ERROR);
16373 + FETCH_DATA (the_info, codep + 8);
16374 + a = *codep++ & 0xff;
16375 + a |= (*codep++ & 0xff) << 8;
16376 + a |= (*codep++ & 0xff) << 16;
16377 + a |= (*codep++ & 0xff) << 24;
16378 + b = *codep++ & 0xff;
16379 + b |= (*codep++ & 0xff) << 8;
16380 + b |= (*codep++ & 0xff) << 16;
16381 + b |= (*codep++ & 0xff) << 24;
16382 + x = a + ((bfd_vma) b << 32);
16390 +static bfd_signed_vma
16393 + bfd_signed_vma x = 0;
16395 + FETCH_DATA (the_info, codep + 4);
16396 + x = *codep++ & (bfd_signed_vma) 0xff;
16397 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 8;
16398 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 16;
16399 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 24;
16403 +static bfd_signed_vma
16406 + bfd_signed_vma x = 0;
16408 + FETCH_DATA (the_info, codep + 4);
16409 + x = *codep++ & (bfd_signed_vma) 0xff;
16410 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 8;
16411 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 16;
16412 + x |= (*codep++ & (bfd_signed_vma) 0xff) << 24;
16414 + x = (x ^ ((bfd_signed_vma) 1 << 31)) - ((bfd_signed_vma) 1 << 31);
16424 + FETCH_DATA (the_info, codep + 2);
16425 + x = *codep++ & 0xff;
16426 + x |= (*codep++ & 0xff) << 8;
16431 +set_op (bfd_vma op, int riprel)
16433 + op_index[op_ad] = op_ad;
16436 + op_address[op_ad] = op;
16437 + op_riprel[op_ad] = riprel;
16441 + /* Mask to get a 32-bit address. */
16442 + op_address[op_ad] = op & 0xffffffff;
16443 + op_riprel[op_ad] = riprel & 0xffffffff;
16448 +OP_REG (int code, int sizeflag)
16452 + USED_REX (REX_EXTZ);
16453 + if (rex & REX_EXTZ)
16458 + case indir_dx_reg:
16459 + if (intel_syntax)
16464 + case ax_reg: case cx_reg: case dx_reg: case bx_reg:
16465 + case sp_reg: case bp_reg: case si_reg: case di_reg:
16466 + s = names16[code - ax_reg + add];
16468 + case es_reg: case ss_reg: case cs_reg:
16469 + case ds_reg: case fs_reg: case gs_reg:
16470 + s = names_seg[code - es_reg + add];
16472 + case al_reg: case ah_reg: case cl_reg: case ch_reg:
16473 + case dl_reg: case dh_reg: case bl_reg: case bh_reg:
16476 + s = names8rex[code - al_reg + add];
16478 + s = names8[code - al_reg];
16480 + case rAX_reg: case rCX_reg: case rDX_reg: case rBX_reg:
16481 + case rSP_reg: case rBP_reg: case rSI_reg: case rDI_reg:
16484 + s = names64[code - rAX_reg + add];
16487 + code += eAX_reg - rAX_reg;
16488 + /* Fall through. */
16489 + case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
16490 + case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
16491 + USED_REX (REX_MODE64);
16492 + if (rex & REX_MODE64)
16493 + s = names64[code - eAX_reg + add];
16494 + else if (sizeflag & DFLAG)
16495 + s = names32[code - eAX_reg + add];
16497 + s = names16[code - eAX_reg + add];
16498 + used_prefixes |= (prefixes & PREFIX_DATA);
16501 + s = INTERNAL_DISASSEMBLER_ERROR;
16508 +OP_IMREG (int code, int sizeflag)
16514 + case indir_dx_reg:
16515 + if (intel_syntax)
16520 + case ax_reg: case cx_reg: case dx_reg: case bx_reg:
16521 + case sp_reg: case bp_reg: case si_reg: case di_reg:
16522 + s = names16[code - ax_reg];
16524 + case es_reg: case ss_reg: case cs_reg:
16525 + case ds_reg: case fs_reg: case gs_reg:
16526 + s = names_seg[code - es_reg];
16528 + case al_reg: case ah_reg: case cl_reg: case ch_reg:
16529 + case dl_reg: case dh_reg: case bl_reg: case bh_reg:
16532 + s = names8rex[code - al_reg];
16534 + s = names8[code - al_reg];
16536 + case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
16537 + case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
16538 + USED_REX (REX_MODE64);
16539 + if (rex & REX_MODE64)
16540 + s = names64[code - eAX_reg];
16541 + else if (sizeflag & DFLAG)
16542 + s = names32[code - eAX_reg];
16544 + s = names16[code - eAX_reg];
16545 + used_prefixes |= (prefixes & PREFIX_DATA);
16548 + s = INTERNAL_DISASSEMBLER_ERROR;
16555 +OP_I (int bytemode, int sizeflag)
16557 + bfd_signed_vma op;
16558 + bfd_signed_vma mask = -1;
16560 + switch (bytemode)
16563 + FETCH_DATA (the_info, codep + 1);
16573 + /* Fall through. */
16575 + USED_REX (REX_MODE64);
16576 + if (rex & REX_MODE64)
16578 + else if (sizeflag & DFLAG)
16581 + mask = 0xffffffff;
16588 + used_prefixes |= (prefixes & PREFIX_DATA);
16594 + case const_1_mode:
16595 + if (intel_syntax)
16599 + oappend (INTERNAL_DISASSEMBLER_ERROR);
16604 + scratchbuf[0] = '$';
16605 + print_operand_value (scratchbuf + 1, 1, op);
16606 + oappend (scratchbuf + intel_syntax);
16607 + scratchbuf[0] = '\0';
16611 +OP_I64 (int bytemode, int sizeflag)
16613 + bfd_signed_vma op;
16614 + bfd_signed_vma mask = -1;
16618 + OP_I (bytemode, sizeflag);
16622 + switch (bytemode)
16625 + FETCH_DATA (the_info, codep + 1);
16630 + USED_REX (REX_MODE64);
16631 + if (rex & REX_MODE64)
16633 + else if (sizeflag & DFLAG)
16636 + mask = 0xffffffff;
16643 + used_prefixes |= (prefixes & PREFIX_DATA);
16650 + oappend (INTERNAL_DISASSEMBLER_ERROR);
16655 + scratchbuf[0] = '$';
16656 + print_operand_value (scratchbuf + 1, 1, op);
16657 + oappend (scratchbuf + intel_syntax);
16658 + scratchbuf[0] = '\0';
16662 +OP_sI (int bytemode, int sizeflag)
16664 + bfd_signed_vma op;
16665 + bfd_signed_vma mask = -1;
16667 + switch (bytemode)
16670 + FETCH_DATA (the_info, codep + 1);
16672 + if ((op & 0x80) != 0)
16674 + mask = 0xffffffff;
16677 + USED_REX (REX_MODE64);
16678 + if (rex & REX_MODE64)
16680 + else if (sizeflag & DFLAG)
16683 + mask = 0xffffffff;
16687 + mask = 0xffffffff;
16689 + if ((op & 0x8000) != 0)
16692 + used_prefixes |= (prefixes & PREFIX_DATA);
16696 + mask = 0xffffffff;
16697 + if ((op & 0x8000) != 0)
16701 + oappend (INTERNAL_DISASSEMBLER_ERROR);
16705 + scratchbuf[0] = '$';
16706 + print_operand_value (scratchbuf + 1, 1, op);
16707 + oappend (scratchbuf + intel_syntax);
16711 +OP_J (int bytemode, int sizeflag)
16714 + bfd_vma mask = -1;
16716 + switch (bytemode)
16719 + FETCH_DATA (the_info, codep + 1);
16721 + if ((disp & 0x80) != 0)
16725 + if (sizeflag & DFLAG)
16726 + disp = get32s ();
16730 + /* For some reason, a data16 prefix on a jump instruction
16731 + means that the pc is masked to 16 bits after the
16732 + displacement is added! */
16737 + oappend (INTERNAL_DISASSEMBLER_ERROR);
16740 + disp = (start_pc + codep - start_codep + disp) & mask;
16741 + set_op (disp, 0);
16742 + print_operand_value (scratchbuf, 1, disp);
16743 + oappend (scratchbuf);
16747 +OP_SEG (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
16749 + oappend (names_seg[reg]);
16753 +OP_DIR (int dummy ATTRIBUTE_UNUSED, int sizeflag)
16757 + if (sizeflag & DFLAG)
16759 + offset = get32 ();
16764 + offset = get16 ();
16767 + used_prefixes |= (prefixes & PREFIX_DATA);
16768 + if (intel_syntax)
16769 + sprintf (scratchbuf, "0x%x,0x%x", seg, offset);
16771 + sprintf (scratchbuf, "$0x%x,$0x%x", seg, offset);
16772 + oappend (scratchbuf);
16776 +OP_OFF (int bytemode ATTRIBUTE_UNUSED, int sizeflag)
16782 + if ((sizeflag & AFLAG) || mode_64bit)
16787 + if (intel_syntax)
16789 + if (!(prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
16790 + | PREFIX_ES | PREFIX_FS | PREFIX_GS)))
16792 + oappend (names_seg[ds_reg - es_reg]);
16796 + print_operand_value (scratchbuf, 1, off);
16797 + oappend (scratchbuf);
16801 +OP_OFF64 (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
16807 + OP_OFF (bytemode, sizeflag);
16815 + if (intel_syntax)
16817 + if (!(prefixes & (PREFIX_CS | PREFIX_SS | PREFIX_DS
16818 + | PREFIX_ES | PREFIX_FS | PREFIX_GS)))
16820 + oappend (names_seg[ds_reg - es_reg]);
16824 + print_operand_value (scratchbuf, 1, off);
16825 + oappend (scratchbuf);
16829 +ptr_reg (int code, int sizeflag)
16833 + *obufp++ = open_char;
16834 + used_prefixes |= (prefixes & PREFIX_ADDR);
16837 + if (!(sizeflag & AFLAG))
16838 + s = names32[code - eAX_reg];
16840 + s = names64[code - eAX_reg];
16842 + else if (sizeflag & AFLAG)
16843 + s = names32[code - eAX_reg];
16845 + s = names16[code - eAX_reg];
16847 + *obufp++ = close_char;
16852 +OP_ESreg (int code, int sizeflag)
16854 + if (intel_syntax)
16856 + if (codep[-1] & 1)
16858 + USED_REX (REX_MODE64);
16859 + used_prefixes |= (prefixes & PREFIX_DATA);
16860 + if (rex & REX_MODE64)
16861 + oappend ("QWORD PTR ");
16862 + else if ((sizeflag & DFLAG))
16863 + oappend ("DWORD PTR ");
16865 + oappend ("WORD PTR ");
16868 + oappend ("BYTE PTR ");
16871 + oappend ("%es:" + intel_syntax);
16872 + ptr_reg (code, sizeflag);
16876 +OP_DSreg (int code, int sizeflag)
16878 + if (intel_syntax)
16880 + if (codep[-1] != 0xd7 && (codep[-1] & 1))
16882 + USED_REX (REX_MODE64);
16883 + used_prefixes |= (prefixes & PREFIX_DATA);
16884 + if (rex & REX_MODE64)
16885 + oappend ("QWORD PTR ");
16886 + else if ((sizeflag & DFLAG))
16887 + oappend ("DWORD PTR ");
16889 + oappend ("WORD PTR ");
16892 + oappend ("BYTE PTR ");
16901 + | PREFIX_GS)) == 0)
16902 + prefixes |= PREFIX_DS;
16904 + ptr_reg (code, sizeflag);
16908 +OP_C (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
16911 + if (rex & REX_EXTX)
16913 + USED_REX (REX_EXTX);
16916 + else if (!mode_64bit && (prefixes & PREFIX_LOCK))
16918 + used_prefixes |= PREFIX_LOCK;
16921 + sprintf (scratchbuf, "%%cr%d", reg + add);
16922 + oappend (scratchbuf + intel_syntax);
16926 +OP_D (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
16929 + USED_REX (REX_EXTX);
16930 + if (rex & REX_EXTX)
16932 + if (intel_syntax)
16933 + sprintf (scratchbuf, "db%d", reg + add);
16935 + sprintf (scratchbuf, "%%db%d", reg + add);
16936 + oappend (scratchbuf);
16940 +OP_T (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
16942 + sprintf (scratchbuf, "%%tr%d", reg);
16943 + oappend (scratchbuf + intel_syntax);
16947 +OP_Rd (int bytemode, int sizeflag)
16950 + OP_E (bytemode, sizeflag);
16956 +OP_MMX (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
16958 + used_prefixes |= (prefixes & PREFIX_DATA);
16959 + if (prefixes & PREFIX_DATA)
16962 + USED_REX (REX_EXTX);
16963 + if (rex & REX_EXTX)
16965 + sprintf (scratchbuf, "%%xmm%d", reg + add);
16968 + sprintf (scratchbuf, "%%mm%d", reg);
16969 + oappend (scratchbuf + intel_syntax);
16973 +OP_XMM (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
16976 + USED_REX (REX_EXTX);
16977 + if (rex & REX_EXTX)
16979 + sprintf (scratchbuf, "%%xmm%d", reg + add);
16980 + oappend (scratchbuf + intel_syntax);
16984 +OP_EM (int bytemode, int sizeflag)
16988 + if (intel_syntax && bytemode == v_mode)
16990 + bytemode = (prefixes & PREFIX_DATA) ? x_mode : q_mode;
16991 + used_prefixes |= (prefixes & PREFIX_DATA);
16993 + OP_E (bytemode, sizeflag);
16997 + /* Skip mod/rm byte. */
17000 + used_prefixes |= (prefixes & PREFIX_DATA);
17001 + if (prefixes & PREFIX_DATA)
17005 + USED_REX (REX_EXTZ);
17006 + if (rex & REX_EXTZ)
17008 + sprintf (scratchbuf, "%%xmm%d", rm + add);
17011 + sprintf (scratchbuf, "%%mm%d", rm);
17012 + oappend (scratchbuf + intel_syntax);
17016 +OP_EX (int bytemode, int sizeflag)
17021 + if (intel_syntax && bytemode == v_mode)
17023 + switch (prefixes & (PREFIX_DATA|PREFIX_REPZ|PREFIX_REPNZ))
17025 + case 0: bytemode = x_mode; break;
17026 + case PREFIX_REPZ: bytemode = d_mode; used_prefixes |= PREFIX_REPZ; break;
17027 + case PREFIX_DATA: bytemode = x_mode; used_prefixes |= PREFIX_DATA; break;
17028 + case PREFIX_REPNZ: bytemode = q_mode; used_prefixes |= PREFIX_REPNZ; break;
17029 + default: bytemode = 0; break;
17032 + OP_E (bytemode, sizeflag);
17035 + USED_REX (REX_EXTZ);
17036 + if (rex & REX_EXTZ)
17039 + /* Skip mod/rm byte. */
17042 + sprintf (scratchbuf, "%%xmm%d", rm + add);
17043 + oappend (scratchbuf + intel_syntax);
17047 +OP_MS (int bytemode, int sizeflag)
17050 + OP_EM (bytemode, sizeflag);
17056 +OP_XS (int bytemode, int sizeflag)
17059 + OP_EX (bytemode, sizeflag);
17065 +OP_M (int bytemode, int sizeflag)
17068 + BadOp (); /* bad lea,lds,les,lfs,lgs,lss modrm */
17070 + OP_E (bytemode, sizeflag);
17074 +OP_0f07 (int bytemode, int sizeflag)
17076 + if (mod != 3 || rm != 0)
17079 + OP_E (bytemode, sizeflag);
17083 +OP_0fae (int bytemode, int sizeflag)
17088 + strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
17090 + if (reg < 5 || rm != 0)
17092 + BadOp (); /* bad sfence, mfence, or lfence */
17096 + else if (reg != 7)
17098 + BadOp (); /* bad clflush */
17102 + OP_E (bytemode, sizeflag);
17106 +NOP_Fixup (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
17108 + /* NOP with REPZ prefix is called PAUSE. */
17109 + if (prefixes == PREFIX_REPZ)
17110 + strcpy (obuf, "pause");
17113 +static const char *const Suffix3DNow[] = {
17114 +/* 00 */ NULL, NULL, NULL, NULL,
17115 +/* 04 */ NULL, NULL, NULL, NULL,
17116 +/* 08 */ NULL, NULL, NULL, NULL,
17117 +/* 0C */ "pi2fw", "pi2fd", NULL, NULL,
17118 +/* 10 */ NULL, NULL, NULL, NULL,
17119 +/* 14 */ NULL, NULL, NULL, NULL,
17120 +/* 18 */ NULL, NULL, NULL, NULL,
17121 +/* 1C */ "pf2iw", "pf2id", NULL, NULL,
17122 +/* 20 */ NULL, NULL, NULL, NULL,
17123 +/* 24 */ NULL, NULL, NULL, NULL,
17124 +/* 28 */ NULL, NULL, NULL, NULL,
17125 +/* 2C */ NULL, NULL, NULL, NULL,
17126 +/* 30 */ NULL, NULL, NULL, NULL,
17127 +/* 34 */ NULL, NULL, NULL, NULL,
17128 +/* 38 */ NULL, NULL, NULL, NULL,
17129 +/* 3C */ NULL, NULL, NULL, NULL,
17130 +/* 40 */ NULL, NULL, NULL, NULL,
17131 +/* 44 */ NULL, NULL, NULL, NULL,
17132 +/* 48 */ NULL, NULL, NULL, NULL,
17133 +/* 4C */ NULL, NULL, NULL, NULL,
17134 +/* 50 */ NULL, NULL, NULL, NULL,
17135 +/* 54 */ NULL, NULL, NULL, NULL,
17136 +/* 58 */ NULL, NULL, NULL, NULL,
17137 +/* 5C */ NULL, NULL, NULL, NULL,
17138 +/* 60 */ NULL, NULL, NULL, NULL,
17139 +/* 64 */ NULL, NULL, NULL, NULL,
17140 +/* 68 */ NULL, NULL, NULL, NULL,
17141 +/* 6C */ NULL, NULL, NULL, NULL,
17142 +/* 70 */ NULL, NULL, NULL, NULL,
17143 +/* 74 */ NULL, NULL, NULL, NULL,
17144 +/* 78 */ NULL, NULL, NULL, NULL,
17145 +/* 7C */ NULL, NULL, NULL, NULL,
17146 +/* 80 */ NULL, NULL, NULL, NULL,
17147 +/* 84 */ NULL, NULL, NULL, NULL,
17148 +/* 88 */ NULL, NULL, "pfnacc", NULL,
17149 +/* 8C */ NULL, NULL, "pfpnacc", NULL,
17150 +/* 90 */ "pfcmpge", NULL, NULL, NULL,
17151 +/* 94 */ "pfmin", NULL, "pfrcp", "pfrsqrt",
17152 +/* 98 */ NULL, NULL, "pfsub", NULL,
17153 +/* 9C */ NULL, NULL, "pfadd", NULL,
17154 +/* A0 */ "pfcmpgt", NULL, NULL, NULL,
17155 +/* A4 */ "pfmax", NULL, "pfrcpit1", "pfrsqit1",
17156 +/* A8 */ NULL, NULL, "pfsubr", NULL,
17157 +/* AC */ NULL, NULL, "pfacc", NULL,
17158 +/* B0 */ "pfcmpeq", NULL, NULL, NULL,
17159 +/* B4 */ "pfmul", NULL, "pfrcpit2", "pfmulhrw",
17160 +/* B8 */ NULL, NULL, NULL, "pswapd",
17161 +/* BC */ NULL, NULL, NULL, "pavgusb",
17162 +/* C0 */ NULL, NULL, NULL, NULL,
17163 +/* C4 */ NULL, NULL, NULL, NULL,
17164 +/* C8 */ NULL, NULL, NULL, NULL,
17165 +/* CC */ NULL, NULL, NULL, NULL,
17166 +/* D0 */ NULL, NULL, NULL, NULL,
17167 +/* D4 */ NULL, NULL, NULL, NULL,
17168 +/* D8 */ NULL, NULL, NULL, NULL,
17169 +/* DC */ NULL, NULL, NULL, NULL,
17170 +/* E0 */ NULL, NULL, NULL, NULL,
17171 +/* E4 */ NULL, NULL, NULL, NULL,
17172 +/* E8 */ NULL, NULL, NULL, NULL,
17173 +/* EC */ NULL, NULL, NULL, NULL,
17174 +/* F0 */ NULL, NULL, NULL, NULL,
17175 +/* F4 */ NULL, NULL, NULL, NULL,
17176 +/* F8 */ NULL, NULL, NULL, NULL,
17177 +/* FC */ NULL, NULL, NULL, NULL,
17181 +OP_3DNowSuffix (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
17183 + const char *mnemonic;
17185 + FETCH_DATA (the_info, codep + 1);
17186 + /* AMD 3DNow! instructions are specified by an opcode suffix in the
17187 + place where an 8-bit immediate would normally go. ie. the last
17188 + byte of the instruction. */
17189 + obufp = obuf + strlen (obuf);
17190 + mnemonic = Suffix3DNow[*codep++ & 0xff];
17192 + oappend (mnemonic);
17195 + /* Since a variable sized modrm/sib chunk is between the start
17196 + of the opcode (0x0f0f) and the opcode suffix, we need to do
17197 + all the modrm processing first, and don't know until now that
17198 + we have a bad opcode. This necessitates some cleaning up. */
17199 + op1out[0] = '\0';
17200 + op2out[0] = '\0';
17205 +static const char *simd_cmp_op[] = {
17217 +OP_SIMD_Suffix (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
17219 + unsigned int cmp_type;
17221 + FETCH_DATA (the_info, codep + 1);
17222 + obufp = obuf + strlen (obuf);
17223 + cmp_type = *codep++ & 0xff;
17224 + if (cmp_type < 8)
17226 + char suffix1 = 'p', suffix2 = 's';
17227 + used_prefixes |= (prefixes & PREFIX_REPZ);
17228 + if (prefixes & PREFIX_REPZ)
17232 + used_prefixes |= (prefixes & PREFIX_DATA);
17233 + if (prefixes & PREFIX_DATA)
17237 + used_prefixes |= (prefixes & PREFIX_REPNZ);
17238 + if (prefixes & PREFIX_REPNZ)
17239 + suffix1 = 's', suffix2 = 'd';
17242 + sprintf (scratchbuf, "cmp%s%c%c",
17243 + simd_cmp_op[cmp_type], suffix1, suffix2);
17244 + used_prefixes |= (prefixes & PREFIX_REPZ);
17245 + oappend (scratchbuf);
17249 + /* We have a bad extension byte. Clean up. */
17250 + op1out[0] = '\0';
17251 + op2out[0] = '\0';
17257 +SIMD_Fixup (int extrachar, int sizeflag ATTRIBUTE_UNUSED)
17259 + /* Change movlps/movhps to movhlps/movlhps for 2 register operand
17260 + forms of these instructions. */
17263 + char *p = obuf + strlen (obuf);
17266 + *(p - 1) = *(p - 2);
17267 + *(p - 2) = *(p - 3);
17268 + *(p - 3) = extrachar;
17273 +PNI_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag)
17275 + if (mod == 3 && reg == 1 && rm <= 1)
17277 + /* Override "sidt". */
17278 + char *p = obuf + strlen (obuf) - 4;
17280 + /* We might have a suffix when disassembling with -Msuffix. */
17286 + /* mwait %eax,%ecx */
17287 + strcpy (p, "mwait");
17288 + if (!intel_syntax)
17289 + strcpy (op1out, names32[0]);
17293 + /* monitor %eax,%ecx,%edx" */
17294 + strcpy (p, "monitor");
17295 + if (!intel_syntax)
17298 + strcpy (op1out, names32[0]);
17299 + else if (!(prefixes & PREFIX_ADDR))
17300 + strcpy (op1out, names64[0]);
17303 + strcpy (op1out, names32[0]);
17304 + used_prefixes |= PREFIX_ADDR;
17306 + strcpy (op3out, names32[2]);
17309 + if (!intel_syntax)
17311 + strcpy (op2out, names32[1]);
17312 + two_source_ops = 1;
17318 + OP_M (0, sizeflag);
17322 +SVME_Fixup (int bytemode, int sizeflag)
17354 + OP_M (bytemode, sizeflag);
17357 + /* Override "lidt". */
17358 + p = obuf + strlen (obuf) - 4;
17359 + /* We might have a suffix. */
17363 + if (!(prefixes & PREFIX_ADDR))
17368 + used_prefixes |= PREFIX_ADDR;
17369 + switch (*codep++)
17372 + strcpy (op2out, names32[1]);
17373 + two_source_ops = 1;
17374 + /* Fall through. */
17378 + *obufp++ = open_char;
17379 + if (mode_64bit || (sizeflag & AFLAG))
17380 + alt = names32[0];
17382 + alt = names16[0];
17383 + strcpy (obufp, alt);
17384 + obufp += strlen (alt);
17385 + *obufp++ = close_char;
17392 +INVLPG_Fixup (int bytemode, int sizeflag)
17405 + OP_M (bytemode, sizeflag);
17408 + /* Override "invlpg". */
17409 + strcpy (obuf + strlen (obuf) - 6, alt);
17416 + /* Throw away prefixes and 1st. opcode byte. */
17417 + codep = insn_codep + 1;
17418 + oappend ("(bad)");
17422 +SEG_Fixup (int extrachar, int sizeflag)
17426 + /* We need to add a proper suffix with
17435 + const char *suffix;
17437 + if (prefixes & PREFIX_DATA)
17441 + USED_REX (REX_MODE64);
17442 + if (rex & REX_MODE64)
17447 + strcat (obuf, suffix);
17451 + /* We need to fix the suffix for
17458 + Override "mov[l|q]". */
17459 + char *p = obuf + strlen (obuf) - 1;
17461 + /* We might not have a suffix. */
17467 + OP_E (extrachar, sizeflag);
17471 +VMX_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag)
17473 + if (mod == 3 && reg == 0 && rm >=1 && rm <= 4)
17475 + /* Override "sgdt". */
17476 + char *p = obuf + strlen (obuf) - 4;
17478 + /* We might have a suffix when disassembling with -Msuffix. */
17485 + strcpy (p, "vmcall");
17488 + strcpy (p, "vmlaunch");
17491 + strcpy (p, "vmresume");
17494 + strcpy (p, "vmxoff");
17501 + OP_E (0, sizeflag);
17505 +OP_VMX (int bytemode, int sizeflag)
17507 + used_prefixes |= (prefixes & (PREFIX_DATA | PREFIX_REPZ));
17508 + if (prefixes & PREFIX_DATA)
17509 + strcpy (obuf, "vmclear");
17510 + else if (prefixes & PREFIX_REPZ)
17511 + strcpy (obuf, "vmxon");
17513 + strcpy (obuf, "vmptrld");
17514 + OP_E (bytemode, sizeflag);
17516 diff -Nurp linux-2.6.22-590/arch/x86_64/kernel/entry.S linux-2.6.22-600/arch/x86_64/kernel/entry.S
17517 --- linux-2.6.22-590/arch/x86_64/kernel/entry.S 2007-07-09 01:32:17.000000000 +0200
17518 +++ linux-2.6.22-600/arch/x86_64/kernel/entry.S 2008-04-09 18:16:24.000000000 +0200
17519 @@ -1170,3 +1170,30 @@ KPROBE_ENTRY(ignore_sysret)
17522 ENDPROC(ignore_sysret)
17527 +ENTRY(kdb_interrupt)
17528 + apicinterrupt KDB_VECTOR,smp_kdb_interrupt
17529 +END(kdb_interrupt)
17530 +#endif /* CONFIG_SMP */
17535 + pushq $-1 # orig_eax
17536 + CFI_ADJUST_CFA_OFFSET 8
17538 + movq $1,%rdi # KDB_REASON_ENTER
17539 + movq $0,%rsi # error_code
17540 + movq %rsp,%rdx # struct pt_regs
17543 + addq $8,%rsp # forget orig_eax
17544 + CFI_ADJUST_CFA_OFFSET -8
17549 +#endif /* CONFIG_KDB */
17550 diff -Nurp linux-2.6.22-590/arch/x86_64/kernel/io_apic.c linux-2.6.22-600/arch/x86_64/kernel/io_apic.c
17551 --- linux-2.6.22-590/arch/x86_64/kernel/io_apic.c 2008-04-09 18:10:46.000000000 +0200
17552 +++ linux-2.6.22-600/arch/x86_64/kernel/io_apic.c 2008-04-09 18:16:24.000000000 +0200
17554 #include <acpi/acpi_bus.h>
17558 +#include <linux/kdb.h>
17559 +#endif /* CONFIG_KDB */
17561 #include <asm/idle.h>
17562 #include <asm/io.h>
17563 #include <asm/smp.h>
17564 @@ -697,6 +701,10 @@ next:
17566 if (vector == IA32_SYSCALL_VECTOR)
17569 + if (vector == KDBENTER_VECTOR)
17571 +#endif /* CONFIG_KDB */
17572 for_each_cpu_mask(new_cpu, new_mask)
17573 if (per_cpu(vector_irq, new_cpu)[vector] != -1)
17575 diff -Nurp linux-2.6.22-590/arch/x86_64/kernel/traps.c linux-2.6.22-600/arch/x86_64/kernel/traps.c
17576 --- linux-2.6.22-590/arch/x86_64/kernel/traps.c 2008-04-09 18:10:53.000000000 +0200
17577 +++ linux-2.6.22-600/arch/x86_64/kernel/traps.c 2008-04-09 18:17:59.000000000 +0200
17578 @@ -555,6 +555,8 @@ void __kprobes die_nmi(char *str, struct
17579 printk(str, smp_processor_id());
17580 show_registers(regs);
17581 vxh_dump_history();
17582 + if (strncmp(str, "NMI Watchdog", 12) == 0)
17583 + notify_die(DIE_NMIWATCHDOG, "nmi_watchdog", regs, 0, 2, SIGINT);
17584 if (kexec_should_crash(current))
17586 if (do_panic || panic_on_oops)
17587 diff -Nurp linux-2.6.22-590/arch/x86_64/Makefile linux-2.6.22-600/arch/x86_64/Makefile
17588 --- linux-2.6.22-590/arch/x86_64/Makefile 2008-04-09 18:10:46.000000000 +0200
17589 +++ linux-2.6.22-600/arch/x86_64/Makefile 2008-04-09 18:16:24.000000000 +0200
17590 @@ -80,6 +80,7 @@ core-y += arch/x86_64/kernel/ \
17591 core-$(CONFIG_IA32_EMULATION) += arch/x86_64/ia32/
17592 drivers-$(CONFIG_PCI) += arch/x86_64/pci/
17593 drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/
17594 +drivers-$(CONFIG_KDB) += arch/x86_64/kdb/
17596 boot := arch/x86_64/boot
17598 diff -Nurp linux-2.6.22-590/Documentation/kdb/bt_x86 linux-2.6.22-600/Documentation/kdb/bt_x86
17599 --- linux-2.6.22-590/Documentation/kdb/bt_x86 1970-01-01 01:00:00.000000000 +0100
17600 +++ linux-2.6.22-600/Documentation/kdb/bt_x86 2008-04-09 18:14:28.000000000 +0200
17602 +Copyright Keith Owens, 2007.
17604 +How the KDB backtrace for x86 works, how to diagnose problems and submit a bug
17605 +==============================================================================
17607 +Unlike ia64, x86 architectures do not mandate unwind information in the kernel.
17608 +gcc will include some unwind information for C functions, but not for assembler
17609 +code. Attempts have been made to add unwind information to the assembler code
17610 +by hand, with little success. Eventually Linus rejected the x86 unwind code
17611 +because it was breaking too often and destroying useful debugging data.
17613 +Even if the x86 unwinder worked correctly, it would only give an accurate
17614 +backtrace, it would not give function arguments. Needless to say, function
17615 +arguments are what people really want. To get function arguments requires much
17616 +more support from the compiler than simple unwind data, the compiler has to
17617 +track line by line where each argument is held and make that data available to
17618 +the debugger. Compiling with gcc -g will provide that information, but the
17619 +resulting kernel is several times larger than normal.
17621 +Although the gcc -g data can be stored on another machine, there are constructs
17622 +in the kernel that cannot be tracked by this method. i386 builds with 4K stacks
17623 +and all x86_64 builds have multiple kernel stacks. The compiler knows nothing
17624 +about these extra stacks and cannot backtrace through them correctly. The
17625 +assembler code in arch/{i386,x86_64}/kernel/entry.S is a maze of twisty logic
17626 +paths, some of which eventually jump to common labels. Describing this twisty
17627 +logic to an unwinder is very difficult, expecially when you try to describe
17628 +where arguments and/or registers are held).
17630 +KDB gets an accurate x86 backtrace and extracts the arguments by performing code
17631 +decomposition and analysis at run time. This avoids the need to bloat the
17632 +running kernel to several times its normal size with gcc -g data. KDB (unlike
17633 +gdb) also knows about the additional kernel stacks and twisty assembler code
17636 +The x86 backtrace code for i386 is very similar to the x86_64 code, with 80%
17637 +common code and data. Most of the differences between the backtrace for the two
17638 +architectures is due to the assembler code and stack handling. To avoid code
17639 +duplication between KDB patches, the x86 backtrace code is actually stored in
17640 +the kdb common patch, in source kdb/kdba_bt_x86.c. kdb/Makefile only builds
17641 +kdba_bt_x86.o for i386 or x86_64. Most of the code reads as if the architecture
17642 +is x86_64, using register names like rsp and rip. i386 is treated as a subset
17643 +of x86_64, with fewer registers and printing the names as esp and eip. When
17644 +this documentation refers to rsp and rip, read it as esp and eip for i386. The
17645 +20% of code and data that is different in held in two large #ifdef sections,
17646 +scan kdba_bt_x86.c for CONFIG_X86_64. Be careful when changing anything in the
17647 +architecture specific sections, you will need to review the other architecture
17648 +to see if it needs changes as well.
17650 +The idea behind the x86 backtrace is to trace one function at a time, which
17651 +gives us the calling function. Then apply the same algorithm to the calling
17652 +function until you unwind to the first function in the process. The starting
17653 +point for tracing any process is to extract the current stack pointer and
17654 +current instruction pointer (rsp and rip). The way that these values are
17655 +extracted varies between running tasks and blocked tasks, the method is
17656 +described later (Process Starting Point) but ignore it for now, just assume that
17657 +we have a starting rsp and rip.
17659 +Given the instruction pointer (rip), we identify the start and end of the kernel
17660 +or module function it is in, using the kernel symbol table. This is easy for C
17661 +code, it is significantly harder for assembler code because of the twisty code
17662 +paths that branch to common labels. The method of identifying the current
17663 +function is described later (Identifying The Current Function) but ignore it for
17664 +now, just assumes that we have the start and end address of the function plus
17667 +After the rip has been mapped to a function name with sensible start and end
17668 +addresses, the next step is to analyse the code paths in that function. KDB
17669 +already has a built in disassembler (copied with slight modifications from
17670 +binutils) which knows how to decode each x86 instruction. Instead of
17671 +duplicating that logic in kdba_bt_x86, it takes advantage of the fact that you
17672 +can override the disassembler's print function, sending the output line to a
17673 +buffer instead of printing it. kdba_bt_x86 stills has to decode the buffer but
17674 +that is a lot easier than decoding the x86 instruction set.
17676 +The code analysis consists of two main passes. There are example below of the
17677 +analysis with basic block (bb) debugging activated (Examples of Basic Block
17678 +Debugging Output).
17680 +The first pass (bb_pass1) identifies all the basic blocks in the function. For
17681 +our purposes, a basic block has a single entry point and one or more exit
17682 +points. The start of the function is the start of basic block 0, all other
17683 +blocks are the target of jump instructions (conditional or unconditional) from
17684 +within the rest of the code. A block ends with an unconditional jump or with a
17685 +terminating instruction such as ret, iret, sysexit, sysret or ud2a (BUG). A
17686 +block can also end because the next instruction is the start of a new block
17687 +(target of jmp or jcc), in this case there is an implied drop through from one
17688 +block to the next.
17690 +Although a call instruction also transfers control, it returns to the next
17691 +instruction so call is not treated as a transfer. Instead call is treated as a
17692 +normal instruction with side effects, the scratch registers are cleared after a
17695 +At the end of the first pass over the function we have a directed graph that
17696 +starts at bb[0]. The nodes of the graph (bb_list[]) are the basic blocks with
17697 +their start and end address. The vertices are the jmp or jcc instructions
17698 +(bb_jmp_list[]) that transfer control between blocks, plus any implied drop
17699 +through transfers between consecutive blocks. This graph can have cycles, many
17700 +functions have loops in them which transfer control back to earlier in the code
17703 +The second pass (bb_pass2) runs over the directed graph analysing the effect of
17704 +each instruction on the register and memory state. It is important to
17705 +understand that the analysis in this pass is an abstract one, it does not use
17706 +actual hex values for the register contents, instead it uses symbolic values.
17707 +When the basic block code says that "register rsi contains value rax" it means
17708 +that whatever value was in rax on entry to the function has also been copied to
17709 +register rsi at this point in the logic flow.
17711 +At an abstract level, all C functions start with exactly the same state, each
17712 +register contains its own symbolic value (except for the stack pointer, see
17713 +later) with no local stack variables defined yet. Assembler functions tend to
17714 +have unusual starting points, with some registers and/or memory contents defined
17715 +differently on entry. For example, ret_from_intr on i386 already has a struct
17716 +pt_regs on its stack, ret_from_intr on x86_64 already has a partial struct
17717 +pt_regs plus another two words stacked on top of it. The special starting cases
17718 +are listed in the arch specific bb_special_cases[].
17720 +Once the input state of bb[0] has been defined (including any special cases),
17721 +bb_pass2_do_changed_blocks() runs over all the nodes in bb_list[]. Each
17722 +instruction in each block is analysed (Tracking the Effects of Instructions) to
17723 +see what effect it has on the abstract register state, the analysis of each
17724 +instruction is done in bb_usage(). An instruction can copy one register to
17725 +another, it can copy a register to stack, move from stack to a register or it
17726 +can invalidate the contents of a register or memory location. A general rule in
17727 +bb_usage() is that any operation whose results cannot be calculated in terms of
17728 +an original input value gives an undefined result. Remember that it is the
17729 +abstract value that becomes undefined, moving a constant to a register gives a
17730 +defined value for the view of the program but it is undefined as far as the
17731 +abstract state is concerned.
17733 +References to data on the stack are a little awkward because the stack pointer
17734 +frequently changes. To overcome this, kdba_bt_x86 defines a pseudo register
17735 +called the 'original stack pointer' (osp). This always represents the stack
17736 +pointer on entry to the function, so on entry rsp contains osp+0x0. As rsp is
17737 +modified, it still points at osp, but its offset from osp changes. Copying rsp
17738 +to another register (e.g. mov %rsp,%rbp) copies the osp offset as well. At the
17739 +point that this function calls the next function down the stack, kdba_bt_x86
17740 +knows the delta from osp to rsp. Applying that delta to the actual value of the
17741 +stack pointer gives the stack pointer value on input to the current function,
17742 +that location contains the return address so we can go up one stack frame and
17743 +repeat the process.
17745 +After doing basic block analysis on the current function, kdba_bt_x86 knows what
17746 +the abstract register and memory state is at the point this function was
17747 +interrupted or it called the next function down the stack, this is the exit
17748 +state. For an interrupt the actual register values are saved in a struct
17749 +pt_regs, for a call we have unwound from the KDB interrupt back to the called
17750 +function so we have some idea of what the register values are in the called
17751 +function. The abstract exit state is merged with the known actual register
17752 +values to derive the original stack pointer. That in turn gives us any
17753 +registers that were saved on stack. The original stack pointer gives the return
17754 +address from the calling function, go up one stack frame and repeat the
17758 +Process Starting Point
17759 +======================
17761 +All backtrace code needs a starting point which defines at least the stack
17762 +pointer and instruction pointer, it may define other registers as well. The
17763 +first part of kdba_bt_stack() extracts the starting point. Processes can be in
17764 +one of three states, running (currently on a cpu), blocked (sleeping or ready to
17765 +run but not currently on a cpu) or unknown.
17767 +For running processes, the current rsp and rip are dynamic. Because KDB stops
17768 +the entire machine by sending an interrupt to the other cpus, KDB can save the
17769 +rsp and rip for each cpu at the point where KDB is entered. This data is held
17770 +in array kdb_running_process and is stored by kdb_save_running() and the arch
17771 +specific kdba_save_running() functions. When backtracing a running process, KDB
17772 +uses the data in kdb_running_process as its starting point.
17774 +For blocked processes we always have the saved rsp, it is held in the process's
17775 +thread_info. For i386 blocked processes, thread_info also contains the saved
17776 +rip. For x86_64 blocked processes, rip is no longer saved in thread_info, it is
17777 +assumed that all blocked processes will resume at assembler label thread_return,
17778 +so that rip is used on x86_64. See arch specific kdba_bt_stack_rip().
17780 +Unknown process state only occurs when the user does 'bt <stack_address>'.
17781 +Unlike other bt commands, 'bt <stack_address>' does not identify any specific
17782 +process, instead it identifies a kernel stack. <stack_address> must be inside a
17783 +valid kernel stack and must point to a saved rip from a call instruction.
17784 +kdba_bt_x86.c uses the common kdba_get_stack_info() and arch specific
17785 +kdba_get_stack_info_alternate() functions to check that the address falls within
17786 +a valid kernel stack. If the user gives a stack address that does not point to
17787 +a saved rip from a call instruction then the backtrace will be garbage.
17790 +Identifying The Current Function
17791 +================================
17793 +Given a rip value, KDB uses the kallsyms data to find the start of the function
17794 +(first address <= rip) and the end of the function (next symbol in kallsyms).
17795 +This works for plain C code because gcc only generates one label per function.
17796 +It does not work for assembler code or for assembler code embedded in C
17797 +functions, because the assembler labels appear as global entries in kallsyms.
17798 +For example, arch/i386/kernel/entry.S has function ret_from_exception which
17799 +contains three global labels ret_from_intr, check_userspace and
17800 +resume_userspace. If rip points to any of those global labels, KDB wants the
17801 +start of the real function, i.e. ret_from_exception. In addition, if rip points
17802 +to ret_from_exception, KDB wants the end of the function to be after the last
17803 +global label in that function, i.e. after resume_userspace.
17805 +The simplest way to handle these unwanted global labels is to list the spurious
17806 +assembler labels, which is done in the arch specific array bb_spurious. After
17807 +mapping rip to the nearest start and end labels from kallsyms, kdb_bb() works
17808 +backwards until it finds a non-spurious label then works forwards to the next
17809 +non-spurious label. That gives a real start and end address and a real name for
17810 +the current function.
17812 +Note that this algorithm only applies in kdb_bb() when it maps rip to a suitable
17813 +start and end address. When disassembling the code, you will still see the
17814 +spurious label names, users need to see the extra labels. ret_from_exception on
17815 +i386 disassembles like this (2.6.22) :-
17817 +[0]kdb> id ret_from_exception
17818 +0xc0102554 ret_from_exception: cli
17819 +0xc0102555 ret_from_intr: mov $0xfffff000,%ebp
17820 +0xc010255a ret_from_intr+0x5: and %esp,%ebp
17821 +0xc010255c check_userspace: mov 0x34(%esp),%eax
17822 +0xc0102560 check_userspace+0x4: mov 0x30(%esp),%al
17823 +0xc0102564 check_userspace+0x8: and $0x20003,%eax
17824 +0xc0102569 check_userspace+0xd: cmp $0x3,%eax
17825 +0xc010256c check_userspace+0x10: jb 0xc010258c resume_kernel
17826 +0xc0102572 check_userspace+0x16: mov %esi,%esi
17827 +0xc0102574 resume_userspace: cli
17828 +0xc0102575 resume_userspace+0x1: mov 0x8(%ebp),%ecx
17829 +0xc0102578 resume_userspace+0x4: and $0xfe3e,%ecx
17830 +0xc010257e resume_userspace+0xa: jne 0xc01026f4 work_pending
17831 +0xc0102584 resume_userspace+0x10: jmp 0xc01026a7 restore_all
17832 +0xc0102589 resume_userspace+0x15: lea 0x0(%esi),%esi
17833 +0xc010258c resume_kernel: cli
17835 +For the purposes of kdba_bt_x86.c, any rip from 0xc0102554 to 0xc0102589 needs
17836 +to map to the range 0xc0102554 (start) to 0xc010258c (end) with function name
17837 +ret_from_exception. Therefore ret_from_intr, check_userspace and
17838 +resume_userspace are listed in bb_spurious[] for i386 so those symbols are
17839 +ignored. The comments in bb_spurious[] list the function that encloses each
17840 +spurious label, those comments are only for humans, they do not affect the code.
17842 +Once rip has been mapped to non-spurious labels, the module name, function name,
17843 +start and end address are stored in variables bb_mod_name, bb_func_name,
17844 +bb_func_start, bb_func_end. These variables are used throughout kdba_bt_x86.c
17845 +for processing each function in turn.
17847 +Watch for changes to assembler code, especially in arch/i386/kernel/entry.S,
17848 +arch/x86_64/kernel/entry.S and arch/x86_64/ia32/ia32entry.S. When new labels
17849 +are added you may need to adjust bb_spurious[] for that architecture. Running
17850 +bb_all can help identify assembler labels that have been added or deleted.
17853 +Tracking the Effects of Instructions
17854 +====================================
17856 +bb_pass2_do_changed_blocks() uses the KDB disassembler to decode the x86
17857 +instructions to something a human can read. bb_dis_pass2() is used as a print
17858 +routine to store data for a single instruction in a buffer then
17859 +bb_parse_buffer() starts the analysis. Any instruction prefixes like lock or
17860 +rep are stripped out. The opcode string is isolated then up to 3 operands are
17861 +extracted (imul can have 3 operands), these are src, dst and dst2. The operand
17862 +is matched against table bb_opcode_usage_all[] which lists all the instructions
17863 +that actually appear in i386 and x86_64 kernels. A lot of the x86 instrcution
17864 +set is not used by the kernel so instructions such as SSE do not appear in
17865 +bb_opcode_usage_all[].
17867 +Each operand is decoded by bb_parse_operand() to see whether it has a segment
17868 +prefix, displacement, base, index or scale. An indirect call or jmp is
17869 +identified. Operands consisting only of a register are classified as 'reg'
17870 +type, displacements starting with '$' are immediate values otherwise the operand
17871 +refers to a memory location. Any base or index register name is mapped to the
17872 +abstract register name that contains it, this takes care of mapping (say) %ah to
17875 +After decoding the opcode and all its operands, bb_usage() decides what effect
17876 +the instruction will have on the abstract state machine. Some x86 instructions
17877 +list all the affected registers in their operands and these can be handled as
17878 +generic cases. Alas many x86 instructions have side effects and change
17879 +registers that are not listed in the operands, these have to be handled as
17880 +special cases. enum bb_operand_usage lists the generic and special cases.
17882 +bb_usage() is basically one huge switch statement over the special values in
17883 +enum bb_operand_usage. For each special case it tracks the side effects of the
17884 +instruction. Once all the special cases have been handled and converted to
17885 +generic cases then bb_usage() handles the generic cases.
17887 +bb_usage() detects when a register is copied to another register, a register is
17888 +copied to stack or a known stack value is copied to a register and updates the
17889 +state data accordingly. It is particularly important that all stack pointer
17890 +updates and copies of the stack pointer are tracked, much of the saved state is
17891 +on stack and can be accessed via any register that points to the stack, not just
17894 +i386 built with 4K stacks and all x86_64 builds have multiple kernel stacks.
17895 +bb_usage() knows which instructions or locations are used to switch stacks and
17896 +pretends that these instructions have no effect on the contents of rsp. The
17897 +higher level backtrace code knows how to handle stack switching, it is too
17898 +complicated for basic block analysis.
17901 +Transfer of Control Outside the Current Function
17902 +================================================
17904 +Ignoring call instructions, most C code does not transfer control outside the
17905 +current function, IOW there are no jump instructions to instructions outside the
17906 +function. There are a few cases that this can occur for C code, inline
17907 +assembler and tail recursion.
17909 +Tail recursion occurs when a function ends by returning the value from a second
17910 +function and that second function has exactly the same arguments and return
17911 +value as the current function. For example,
17913 + int bar(int i, char *p)
17915 + ... do some work and return an int ...
17918 + int foo(int i, char *p)
17920 + return bar(i, p);
17923 +If tail recursion is active (gcc -foptimize-sibling-calls) then instead of foo
17924 +calling bar, bar returning to foo then foo returning to its caller, gcc will end
17925 +foo with a direct jmp to bar. The source code says that something called foo
17926 +but the stack trace will show bar is active, with no sign of foo on stack. When
17927 +bar returns it will use the return address from the code that called foo.
17929 +bb_transfer() detects an unconditional jmp to code outside the function body and
17930 +assumes that this represents tail recursion. For tail recursion to work
17931 +correctly, all the preserved registers must contain their original values,
17932 +bb_sanity_check() validates this. Any deviation from the expected state will
17933 +stop basic block analysis and fall back on the old unreliable backtrace code.
17935 +Besides tail recursion in C code, assembler code can jump to labels outside the
17936 +current function. Unfortunately this occurs all the time in the twisty
17937 +assembler code and, to make things worse, many of these transfers are done with
17938 +non-standard register or memory state. bb_special_case() and the arch specific
17939 +bb_special_cases[] handle all the known special cases, including what the
17940 +register and/or memory state should be. Any deviation from the expected state
17941 +will stop basic block analysis and fall back on the old unreliable backtrace
17945 +Locating Arguments
17946 +==================
17948 +Function arguments can be passed in registers or on stack. The full ABI for
17949 +passing arguments is described in
17951 + http://www.caldera.com/developers/devspecs/abi386-4.pdf
17952 + http://www.x86-64.org/documentation/abi.pdf
17954 +The short description, ignoring special cases like passing structures by name
17955 +and floating point arguments which tend not to apply to the kernel, is :-
17957 +i386. With -mpregparm=0, all arguments are passed on stack, except for
17958 + functions defined as FASTCALL, where the first 3 arguments are passed in
17961 + With -mregparm=3, the first 3 arguments are passed in registers except
17962 + for functions defined as asmlinkage or with variable number of
17963 + arguments, when arguments are still passed on stack. -mpregparm=3 used
17964 + to be a config option, in recent kernels it is the default.
17966 + Arguments defined as long long (64 bit) are passed in two registers or
17967 + in two locations on stack. Being passed in two pieces makes a 64 bit
17968 + argument look like two 32 bit arguments to KDB, it will be printed as
17969 + two separate arguments.
17971 + When compiled with -mregparm=3, if a 64 bit argument is argument number
17972 + 2 then it will not be split between register and stack, instead it will
17973 + all be on stack and the third argument register will not be used. This
17974 + makes it look like there is an extra argument in the list. There is
17975 + nothing that KDB can do to detect these corner cases with 64 bit
17976 + arguments on i386, which is a pity because they can confuse users.
17978 + The preserved registers are ebx, ebp, esp, esi, edi. Arguments are
17979 + passed in eax, edx, ecx. The return value is in eax.
17981 +x86_64. The first 6 arguments are passed in registers, the 7th and later
17982 + arguments are passed on stack. Except for functions with a variable
17983 + number of arguments (e.g. printk) where all arguments are on stack
17984 + except for rax which contains the number of SSE arguments (always 0 for
17987 + The preserved registers are rbx, rbp, rsp, r12, r13, r14, r15.
17988 + Arguments are passed in rdi, rsi, rdx, rcx, r8, r9. The return value is
17991 +For both architectures, kdba_bt detects an argument that is passed in a register
17992 +by the fact that the function code reads from that argument type register while
17993 +it contains its original value. IOW, testing the value of rax, copying rax to
17994 +another register or storing it on stack without first overwriting rax means that
17995 +rax contains a useful input value. Reading from memory which is above the
17996 +original stack pointer means that there is a argument at that location on
17999 +There are some functions in the kernel whose definition contains arguments that
18000 +are not actually used. Typically these functions are instantiations of generic
18001 +function definitions where some, but not all, instantiations use all the
18002 +arguments. For example, a filesystem function may take flags that are not used
18003 +by this particular filesystem, but the function definition has to match the
18004 +generic filesystem declarations. If the unused arguments are at the end of the
18005 +list then there is no way of telling from the object code that they exist, the
18006 +function that does not use the trailing aguments will have no code that refers
18007 +to them. KDB will print a truncated argument list for this case.
18009 +If the unused arguments are not at the end of the list then KDB can detect the
18010 +presence of the unused arguments, because there is code that refers to later
18011 +arguments. KDB will print the unused argument, although gcc may have
18012 +overwritten the register it is in, in which case KDB prints "invalid".
18014 +Originally kdba_bt_x86 would detect that there was no reference to arguments in
18015 +registers but there were still references to arguments on stack and assume that
18016 +the function had all its arguments on stack. Unfortunately this did not work
18017 +with the large number of 'pass through' functions in the kernel. A 'pass
18018 +through' function is one which calls another function with roughly the same
18019 +argument list and makes no other reference to the register arguments. For
18020 +example, ipv4_doint_and_flush_strategy() takes 7 arguments, calls
18021 +devinet_conf_sysctl() with those 7 arguments in the same order and has no other
18022 +reference to any of its arguments.
18024 +Pass through functions do not touch the arguments that are passed in registers
18025 +because they are already in the right location for the routine about to be
18026 +called, so the pass through function has no code that references the argument
18027 +registers. No code means that kdba_bt_x86 cannot tell if the function has
18028 +register arguments or not. The arguments passed on stack must always be copied
18029 +to the new stack frame, even for pass through functions, so the arguments on
18030 +stack can always be detected.
18032 +kdba_bt_x86 was changed to assume that if there are any arguments on stack then
18033 +there are always arguments in registers, except for a list of functions that are
18034 +known to be asmlinkage or to have a variable number of arguments.
18035 +bb_assume_pass_through() ignores the known special cases, for other functions
18036 +which have stack arguments but no register arguments it assumes the function is
18037 +pass through and prints a warning about that assumption.
18039 +The above heuristics mean that there is one case that kdba_bt_x86 cannot detect:
18040 +pass through functions where all the arguments are in registers. These have no
18041 +argument references at all in their code, so they are printed with no arguments.
18042 +All they do is call another function so this class of functions never fails, or
18043 +if it does fail then it is due to something that is not argument related. If
18044 +the failure is further down the call stack then the arguments are printed at the
18045 +next function down the stack, so the user still has the arguments.
18047 +This list of limitations on getting the x86 arguments may seem to be a long one,
18048 +but kdba_bt_x86 gives sensible results for most functions. For kernel
18049 +debugging, any arguments are far better than none at all.
18052 +Kernel Stack Switching
18053 +======================
18055 +Understanding the unusual way that x86 kernel stacks are used is very important
18056 +when diagnosing backtrace problems. Every process has its own normal kernel
18057 +stack, even processes that run entirely within the kernel such as kthread or the
18058 +per cpu migration processes. The normal stacks are 4K or 8K on i386 (depending
18059 +on CONFIG_4KSTACKS) and 8K on x86_64. The normal stacks are global, they are
18060 +not tied to any cpu.
18062 +For i386 with 8K stacks there are no other kernel stacks so there is no stack
18063 +switching to worry about.
18065 +For i386 with 4K process stacks, each cpu also has a 4K soft irq stack and a 4K
18066 +hard irq stack. It is possible for a process to be running on its own process
18067 +stack, for the process to be interrupted by a soft irq which is then interrupted
18068 +by a hard irq. At that point the backtrace is split between the hard irq, the
18069 +soft irq and the normal normal stacks.
18071 +On x86_64, each cpu always has stacks for stackfault, doublefault, nmi, debug,
18072 +mce and interrupts. See Documentation/x86_64/kernel-stacks.
18074 +The arch specific kdba_get_stack_info_alternate() function works out which stack
18075 +the backtrace starts on, how big the stack is and how to switch to the next
18076 +stack. This information is stored in the kdb_activation_record and used by the
18077 +higher level backtrace code to detect a stack switch.
18079 +The normal stack has some padding at the end, this reflects the stack pointer
18080 +when the process was created in the kernel. kdba_bt_x86 cannot backtrace
18081 +through this padding data, mainly because the code that set the nitial stack
18082 +pointer no longer exists after boot. ARCH_NORMAL_PADDING defines how many words
18083 +to ignore at the end of the normal stack.
18089 +KDB has conditional debugging print statements scattered throughout the code.
18090 +If KDB is not behaving as expected, you can turn on debugging and rerun the
18091 +command. Before debugging KDB, set LINES 10000 and capture the output via a
18092 +serial console. If using minicom, turn on word wrap (control-A W) and capture
18093 +mode (control-A L). If you are using a serial console via a serial to Ethernet
18094 +interface using ssh or telnet, use the 'script' command to start the session.
18096 +The various KDB_DEBUG_FLAG_* flags are listed in include/linux/kdbprivate.h.
18097 +You set debug with 'set KDBDEBUG 0xnn' where nn is the or'd value of the desired
18098 +flags. 'set KDBDEBUG 0' turns off KDB debugging. When diagnosing x86 backtrace
18099 +problems, the most useful debug flags are
18101 + KDB_DEBUG_FLAG_ARA 0x10 Activation record, arch specific
18102 + KDB_DEBUG_FLAG_BB_SUMM 0x04 Basic block analysis, summary only
18103 + KDB_DEBUG_FLAG_BB 0x20 All basic block analysis
18105 +ARA prints information about the different kernel stacks as kdba_bt_x86 unwinds
18106 +through the switched kernel stacks. BB_SUMM prints a summary of the basic block
18107 +analysis for each function, including the abstract exit state and the rollback
18108 +calculations. BB prints a huge amount of basic block debugging, you probably
18109 +only want to turn this for the full backtrace on as a last resort.
18111 +I find 'set KDBDEBUG 0x14' to be best to get an overview of a problem. It gives
18112 +both the kernel stack information plus the abstract state and actual location of
18113 +data for each function.
18115 +Command 'bb1' does a detailed debug session for a single function, bb1 takes a
18116 +single parameter, the address of the exit point from the function, by number,
18117 +not by name. bb1 turns on KDB_DEBUG_FLAG_BB, does basic block analysis for the
18118 +function that contains the exit point then resets the debug flags to their
18121 +Command 'bb_all' runs through every function in the base kernel (not module
18122 +functions) and does a basic block analysis of every function. It also validates
18123 +the various tables in kdba_bt_x86 where possible. bb_all is meant for the KDB
18124 +maintainer to check that all the base kernel function pass the sanity checks, it
18125 +can also be used by end users when reporting a bug. bb_all takes no parameters.
18126 +It prints a '.' for every 100 functions it has analysed and allows for up to 20
18127 +errors before giving up. The output from bb_all also includes the config
18128 +variables that affect basic block analysis plus any assumptions about 'pass
18129 +through' functions.
18132 +Submitting a Bug Report Against kdba_bt_x86
18133 +===========================================
18135 +Capture the KDB output via a serial console.
18140 +Reproduce the problem.
18144 +If you can identify the rip/eip where kdba_bt_x86 gets confused, run bb1 with
18147 +Find each set of output from kdba_get_stack_info in the trace, extract the last
18148 +two lines and type those lines into KDB. That will give a hex and symbolic dump
18149 +of the raw kernel stacks. For example, if the trace data is
18151 +kdba_get_stack_info: esp=0xc04fbef8 cpu=0 task=c047b3e0
18152 +kdba_get_stack_info: ar->stack
18153 + physical_start=0xc04fb000
18154 + physical_end=0xc04fc000
18155 + logical_start=0xc04fb038
18156 + logical_end=0xc04fc000
18162 +then type the last two lines into KDB. Repeat this for each stack listed by
18163 +kdba_get_stack_info on the failing backtrace.
18165 +Send all the console output to the KDB maintainer.
18168 +Examples of Basic Block Debugging Output
18169 +========================================
18171 +Example of the basic block analysis of fs/namei::getname() on i386. Kernel
18172 +2.6.22, i386, compiled with frame pointers, gcc 4.1.0.
18174 +Basic block debugging is very verbose, so set a high number of output lines.
18175 +You really need a reliable serial console to capture this amount of output.
18177 + [0]kdb> set LINES 10000
18179 +A simple disassemble of getname(). This is not required for debugging purposes
18180 +since each instruction is printed as part of basic block debugging, but this can
18181 +be easier to read.
18183 + [0]kdb> id getname
18184 + 0xc015cce8 getname: push %ebp
18185 + 0xc015cce9 getname+0x1: mov %esp,%ebp
18186 + 0xc015cceb getname+0x3: push %edi
18187 + 0xc015ccec getname+0x4: push %esi
18188 + 0xc015cced getname+0x5: push %ebx
18189 + 0xc015ccee getname+0x6: sub $0x4,%esp
18190 + 0xc015ccf1 getname+0x9: mov %eax,%edi
18191 + 0xc015ccf3 getname+0xb: mov $0xd0,%edx
18192 + 0xc015ccf8 getname+0x10: mov 0xc04b2120,%eax
18193 + 0xc015ccfd getname+0x15: call 0xc0153009 kmem_cache_alloc
18194 + 0xc015cd02 getname+0x1a: mov %eax,0xfffffff0(%ebp)
18195 + 0xc015cd05 getname+0x1d: mov $0xfffffff4,%eax
18196 + 0xc015cd0a getname+0x22: cmpl $0x0,0xfffffff0(%ebp)
18197 + 0xc015cd0e getname+0x26: je 0xc015cd7d getname+0x95
18198 + 0xc015cd10 getname+0x28: mov %esp,%eax
18199 + 0xc015cd12 getname+0x2a: and $0xfffff000,%eax
18200 + 0xc015cd17 getname+0x2f: cmpl $0xffffffff,0x18(%eax)
18201 + 0xc015cd1b getname+0x33: je 0xc015cd39 getname+0x51
18202 + 0xc015cd1d getname+0x35: mov $0xfffffff2,%esi
18203 + 0xc015cd22 getname+0x3a: cmp $0xbfffffff,%edi
18204 + 0xc015cd28 getname+0x40: ja 0xc015cd60 getname+0x78
18205 + 0xc015cd2a getname+0x42: mov $0xc0000000,%ebx
18206 + 0xc015cd2f getname+0x47: sub %edi,%ebx
18207 + 0xc015cd31 getname+0x49: cmp $0xfff,%ebx
18208 + 0xc015cd37 getname+0x4f: jbe 0xc015cd3e getname+0x56
18209 + 0xc015cd39 getname+0x51: mov $0x1000,%ebx
18210 + 0xc015cd3e getname+0x56: mov %ebx,%ecx
18211 + 0xc015cd40 getname+0x58: mov %edi,%edx
18212 + 0xc015cd42 getname+0x5a: mov 0xfffffff0(%ebp),%eax
18213 + 0xc015cd45 getname+0x5d: call 0xc023dbb4 strncpy_from_user
18214 + 0xc015cd4a getname+0x62: cmp $0x0,%eax
18215 + 0xc015cd4d getname+0x65: jle 0xc015cd5a getname+0x72
18216 + 0xc015cd4f getname+0x67: mov $0xffffffdc,%esi
18217 + 0xc015cd54 getname+0x6c: cmp %ebx,%eax
18218 + 0xc015cd56 getname+0x6e: jae 0xc015cd60 getname+0x78
18219 + 0xc015cd58 getname+0x70: jmp 0xc015cd71 getname+0x89
18220 + 0xc015cd5a getname+0x72: je 0xc015cd76 getname+0x8e
18221 + 0xc015cd5c getname+0x74: jge 0xc015cd71 getname+0x89
18222 + 0xc015cd5e getname+0x76: mov %eax,%esi
18223 + 0xc015cd60 getname+0x78: mov 0xfffffff0(%ebp),%edx
18224 + 0xc015cd63 getname+0x7b: mov 0xc04b2120,%eax
18225 + 0xc015cd68 getname+0x80: call 0xc01521f1 kmem_cache_free
18226 + 0xc015cd6d getname+0x85: mov %esi,%eax
18227 + 0xc015cd6f getname+0x87: jmp 0xc015cd7d getname+0x95
18228 + 0xc015cd71 getname+0x89: mov 0xfffffff0(%ebp),%eax
18229 + 0xc015cd74 getname+0x8c: jmp 0xc015cd7d getname+0x95
18230 + 0xc015cd76 getname+0x8e: mov $0xfffffffe,%esi
18231 + 0xc015cd7b getname+0x93: jmp 0xc015cd60 getname+0x78
18232 + 0xc015cd7d getname+0x95: pop %edx
18233 + 0xc015cd7e getname+0x96: pop %ebx
18234 + 0xc015cd7f getname+0x97: pop %esi
18235 + 0xc015cd80 getname+0x98: pop %edi
18236 + 0xc015cd81 getname+0x99: pop %ebp
18237 + 0xc015cd82 getname+0x9a: ret
18239 +The bb1 command only one argument which must be an address, not a name. bb1
18240 +turns on full basic block debugging and analyses the function containing the
18241 +supplied address. Give bb1 the address of the exit point from this function,
18242 +IOW the return address that is stored on stack due to a call from this function
18243 +to the next function down the call stack. Assume that getname() has called
18244 +kmem_cache_free() and something went wrong in kmem_cache_free() or one of the
18245 +functions that it calls. The call to kmem_cache_free is at 0xc015cd68 and the
18246 +return address on stack is the instruction after the call, i.e. 0xc015cd6d, so
18248 + [0]kdb> bb1 0xc015cd6d
18249 + bb_pass1: func_name getname func_start 0xc015cce8 func_end 0xc015cd83
18251 +bb_pass1 has identified the function name and its start and end address. For C
18252 +functions these are just the function start address and the next symbol in
18253 +kallsyms. For Assembler code there may be spurious labels so the function name
18254 +may not match the label prior to the address given to bb1. For an example of
18255 +that on i386, find the address of resume_userspace then pass that address to the
18259 + bb[0] start 0xc015cce8 end 0xc015cd38 drop_through 1
18260 + bb[1] start 0xc015cd39 end 0xc015cd3d drop_through 1
18261 + bb[2] start 0xc015cd3e end 0xc015cd58 drop_through 0
18262 + bb[3] start 0xc015cd5a end 0xc015cd5f drop_through 1
18263 + bb[4] start 0xc015cd60 end 0xc015cd6f drop_through 0
18264 + bb[5] start 0xc015cd71 end 0xc015cd74 drop_through 0
18265 + bb[6] start 0xc015cd76 end 0xc015cd7b drop_through 0
18266 + bb[7] start 0xc015cd7d end 0xc015cd82 drop_through 0
18267 + bb_jmp[0] from 0xc015cd0e to 0xc015cd7d drop_through 0
18268 + bb_jmp[1] from 0xc015cd1b to 0xc015cd39 drop_through 0
18269 + bb_jmp[2] from 0xc015cd28 to 0xc015cd60 drop_through 0
18270 + bb_jmp[3] from 0xc015cd37 to 0xc015cd3e drop_through 0
18271 + bb_jmp[4] from 0xc015cd4d to 0xc015cd5a drop_through 0
18272 + bb_jmp[5] from 0xc015cd56 to 0xc015cd60 drop_through 0
18273 + bb_jmp[6] from 0xc015cd58 to 0xc015cd71 drop_through 0
18274 + bb_jmp[7] from 0xc015cd5a to 0xc015cd76 drop_through 0
18275 + bb_jmp[8] from 0xc015cd5c to 0xc015cd71 drop_through 0
18276 + bb_jmp[9] from 0xc015cd6f to 0xc015cd7d drop_through 0
18277 + bb_jmp[10] from 0xc015cd74 to 0xc015cd7d drop_through 0
18278 + bb_jmp[11] from 0xc015cd7b to 0xc015cd60 drop_through 0
18279 + bb_jmp[12] from 0xc015cd38 to 0xc015cd39 drop_through 1
18280 + bb_jmp[13] from 0xc015cd3d to 0xc015cd3e drop_through 1
18281 + bb_jmp[14] from 0xc015cd5f to 0xc015cd60 drop_through 1
18283 +After analysing the logic flow, we can see that getname() consists of 8 basic
18284 +blocks (nodes in bb_list[]). 5 of these blocks end in unconditional jumps, the
18285 +other 3 drop through to the next block. There are 15 transfers of control
18286 +(vertices in bb_jmp_list[]). 12 of these transfers are explicit jmp or jcc
18287 +instructions, the other 3 are implicit transfers when dropping through from one
18288 +block to the next. The node list is sorted by start address, the vertex list is
18291 +Basic block 0 starts at the function start (0xc015cce8) and ends at 0xc015cd38.
18292 +0xc015cd39 is the target of a jump instruction (0xc015cd1b: je 0xc015cd39) so
18293 +0xc015cd39 starts a new block, which means that 0xc015cd38 becomes the end of
18294 +the previous block. Because bb[0] does not end in an explicit jmp instruction,
18295 +there is a drop through from the end of bb[0] to the start of bb[1], see
18300 +To get the most accurate results from pass2, try to scan the directed graph by
18301 +only looking at nodes whose inputs are all defined. Initially only process
18302 +nodes with no missing inputs.
18304 + bb_pass2_do_changed_blocks: allow_missing 0
18307 + bb_reg_state c07282e0
18317 +The initial state for bb[0] is the same for all C functions. Each register
18318 +contains its own abstract value, except for rsp which is defined in terms of the
18319 +original stack pointer (osp).
18321 + '0xc015cce8 getname: push %ebp'
18323 +The first instruction of getname() saves the frame pointer.
18325 + opcode 'push' matched by 'push', usage 44
18326 + src R: %ebp base_rc 8 (rbp)
18328 +bb_usage() reports how the instruction was recognised and how its operands were
18329 +decoded. Although this is i386 (ebp), it is reported as rbp. Using the x86_64
18330 +names for registers throughout makes it easier to create common code for the two
18333 + rsp osp offset +0x0 -> -0x4
18335 +A push instruction decrements rsp by 4 (i386) or 8 (x86_64) bytes. rsp
18336 +originally contained the original stack pointer (osp), now it contains the
18337 +original stack pointer - 4.
18339 + *(rsp+0x0 osp-0x4) = rbp slot 0
18341 +The stack location pointed to by *rsp now contains the original value of rbp.
18342 +Since rsp contains (osp-0x4), *(osp-0x4) contains rbp. It is slot 0 in the
18343 +memory array associated with the register state.
18345 + '0xc015cce9 getname+0x1: mov %esp,%ebp'
18346 + opcode 'mov' matched by 'mov', usage 36
18347 + src R: %esp base_rc 9 (rsp)
18348 + dst R: %ebp base_rc 8 (rbp)
18349 + rbp = rsp (osp-0x4)
18351 +Copy esp (rsp) to ebp (rbp). rsp contained (osp-0x4) so rbp also contains
18352 +(osp-0x4). Any reference to data via either rbp or rsp will now be tracked as a
18355 + '0xc015cceb getname+0x3: push %edi'
18356 + opcode 'push' matched by 'push', usage 44
18357 + src R: %edi base_rc 6 (rdi)
18358 + rsp osp offset -0x4 -> -0x8
18359 + *(rsp+0x0 osp-0x8) = rdi slot 1
18360 + '0xc015ccec getname+0x4: push %esi'
18361 + opcode 'push' matched by 'push', usage 44
18362 + src R: %esi base_rc 7 (rsi)
18363 + rsp osp offset -0x8 -> -0xc
18364 + *(rsp+0x0 osp-0xc) = rsi slot 2
18365 + '0xc015cced getname+0x5: push %ebx'
18366 + opcode 'push' matched by 'push', usage 44
18367 + src R: %ebx base_rc 3 (rbx)
18368 + rsp osp offset -0xc -> -0x10
18369 + *(rsp+0x0 osp-0x10) = rbx slot 3
18371 +Push 3 registers to stack. rsp is adjusted for each push and stack locations
18372 +are assigned to contain the values of edi, esi and ebx. This sequence is very
18373 +common in i386 C functions. edi, esi and ebx are preserved registers on i386,
18374 +but gcc wants to use them for scratch space. The original contents iof these
18375 +registers must be saved on stack and restored before returning to our caller.
18377 + '0xc015ccee getname+0x6: sub $0x4,%esp'
18378 + opcode 'sub' matched by 'sub', usage 51
18380 + dst R: %esp base_rc 9 (rsp)
18381 + rsp osp offset -0x10 -> -0x14
18383 +Subtract 4 bytes from esp. This defines the local stack variables. Sorry,
18384 +names for local stack variables are not available to KDB.
18386 + '0xc015ccf1 getname+0x9: mov %eax,%edi'
18387 + opcode 'mov' matched by 'mov', usage 36
18388 + src R: %eax base_rc 2 (rax)
18389 + dst R: %edi base_rc 6 (rdi)
18392 +Having saved edi on stack, gcc now overwrites edi with eax. At this point rax
18393 +still contains its original value, so rdi now contains a copy of rax, as well as
18394 +the original value which is still in rax. This is a common sequence in C code.
18395 +rax contains argument 0 but it is also a scratch register. If the code needs to
18396 +use argument 0 later then its value must be saved somewhere before executing any
18397 +instruction that changes rax. edi is a preserved register so its contents will
18398 +not be changed by any function that we call, or if it is changed then it will be
18399 +restored before returning to this function.
18401 +rax is listed in the arch specific bb_param_reg[] list and the code is reading
18402 +from rax while it still contains its original value. The only way that makes
18403 +any sense is when rax is an input argument to getname(). We note that fact in
18406 + '0xc015ccf3 getname+0xb: mov $0xd0,%edx'
18407 + opcode 'mov' matched by 'mov', usage 36
18409 + dst R: %edx base_rc 5 (rdx)
18412 +Moving an constant value to edx. Although this is a constant, it does not refer
18413 +to any of the original values that were supplied to this function. Therefore
18414 +rdx becomes undefined for the purposes of the code analysis.
18416 + '0xc015ccf8 getname+0x10: mov 0xc04b2120,%eax'
18417 + opcode 'mov' matched by 'mov', usage 36
18418 + src M: 0xc04b2120
18419 + dst R: %eax base_rc 2 (rax)
18422 +Moving a constant value to eax makes rax undefined.
18424 + '0xc015ccfd getname+0x15: call 0xc0153009 <kmem_cache_alloc>'
18425 + opcode 'call' matched by 'call', usage 17
18426 + src M: 0xc0153009
18427 + bb_reg_state c0728658
18436 + slot 0 offset_address -0x4 rbp
18437 + slot 1 offset_address -0x8 rdi
18438 + slot 2 offset_address -0xc rsi
18439 + slot 3 offset_address -0x10 rbx
18441 +Basic block debugging prints the register and memory state when transfering
18442 +control between blocks and when issuing call instructions. The call state is
18443 +mainly useful when C code calls assembler routines, especially if you are not
18444 +sure what state the assembler code expects. Not all of our assembler is as well
18445 +documented as it could be :(
18451 +The i386 ABI says that some registers are preserved across calls, see the arch
18452 +specific bb_preserved_reg[] list. Any registers not in that list automatically
18453 +become undefined after a call instruction.
18455 + '0xc015cd02 getname+0x1a: mov %eax,0xfffffff0(%ebp)'
18456 + opcode 'mov' matched by 'mov', usage 36
18457 + src R: %eax base_rc 2 (rax)
18458 + dst M: 0xfffffff0(%ebp) base_rc 8 (rbp)
18460 +eax is the return value from the call, it is being saved at offset 0xfffffff0
18461 +(-0x10) from ebp. Since rbp contains (osp-0x4) the return value is being stored
18462 +at (osp-0x14). This is a stack location but we have no record of any data being
18463 +held at that location, it is part of the local stack variables.
18465 + '0xc015cd05 getname+0x1d: mov $0xfffffff4,%eax'
18466 + opcode 'mov' matched by 'mov', usage 36
18467 + src I: $0xfffffff4
18468 + dst R: %eax base_rc 2 (rax)
18470 + '0xc015cd0a getname+0x22: cmpl $0x0,0xfffffff0(%ebp)'
18471 + opcode 'cmpl' matched by 'cmp', usage 3
18473 + dst M: 0xfffffff0(%ebp) base_rc 8 (rbp)
18474 + '0xc015cd0e getname+0x26: je 0xc015cd7d <getname+0x95>'
18475 + opcode 'je' matched by 'j', usage 28
18476 + src M: 0xc015cd7d
18477 + bb_reg_state c0728658
18486 + slot 0 offset_address -0x4 rbp
18487 + slot 1 offset_address -0x8 rdi
18488 + slot 2 offset_address -0xc rsi
18489 + slot 3 offset_address -0x10 rbx
18491 +Transfer of control, print the register and memory state.
18493 + matched: from 0xc015cd0e to 0xc015cd7d drop_through 0 bb_jmp[0]
18495 +Which bb_jmp_list[] entry matches this transfer.
18497 + new state c07286b8
18499 +The current abstract register and memory state is cloned at address c07286b8.
18500 +This state becomes one of the inputs to the basic block whose start address is
18503 + '0xc015cd10 getname+0x28: mov %esp,%eax'
18504 + opcode 'mov' matched by 'mov', usage 36
18505 + src R: %esp base_rc 9 (rsp)
18506 + dst R: %eax base_rc 2 (rax)
18507 + rax = rsp (osp-0x14)
18509 +Copy rsp which contains (osp-0x14) to rax. rax contains a valid stack pointer.
18511 + '0xc015cd12 getname+0x2a: and $0xfffff000,%eax'
18512 + opcode 'and' matched by 'and', usage 11
18513 + src I: $0xfffff000
18514 + dst R: %eax base_rc 2 (rax)
18519 + '0xc015cd17 getname+0x2f: cmpl $0xffffffff,0x18(%eax)'
18520 + opcode 'cmpl' matched by 'cmp', usage 3
18521 + src I: $0xffffffff
18522 + dst M: 0x18(%eax) base_rc 2 (rax)
18523 + '0xc015cd1b getname+0x33: je 0xc015cd39 <getname+0x51>'
18524 + opcode 'je' matched by 'j', usage 28
18525 + src M: 0xc015cd39
18526 + bb_reg_state c0728658
18535 + slot 0 offset_address -0x4 rbp
18536 + slot 1 offset_address -0x8 rdi
18537 + slot 2 offset_address -0xc rsi
18538 + slot 3 offset_address -0x10 rbx
18540 +Another transfer of control, print the state.
18542 + matched: from 0xc015cd1b to 0xc015cd39 drop_through 0 bb_jmp[1]
18544 +Which bb_jmp_list[] entry was used.
18548 +To save space, we only clone the state if it is different. Otherwise we reuse
18549 +the state from another vertex and bump the reference count.
18551 + '0xc015cd1d getname+0x35: mov $0xfffffff2,%esi'
18552 + opcode 'mov' matched by 'mov', usage 36
18553 + src I: $0xfffffff2
18554 + dst R: %esi base_rc 7 (rsi)
18557 +Using esi as a scratch register, even though the i386 ABi says that esi is a
18558 +preserved register. Not to worry, the original value of rsi was saved on stack
18559 +on entry and it will be restored before exit.
18561 + '0xc015cd22 getname+0x3a: cmp $0xbfffffff,%edi'
18562 + opcode 'cmp' matched by 'cmp', usage 3
18563 + src I: $0xbfffffff
18564 + dst R: %edi base_rc 6 (rdi)
18565 + '0xc015cd28 getname+0x40: ja 0xc015cd60 <getname+0x78>'
18566 + opcode 'ja' matched by 'j', usage 28
18567 + src M: 0xc015cd60
18568 + bb_reg_state c0728658
18577 + slot 0 offset_address -0x4 rbp
18578 + slot 1 offset_address -0x8 rdi
18579 + slot 2 offset_address -0xc rsi
18580 + slot 3 offset_address -0x10 rbx
18581 + matched: from 0xc015cd28 to 0xc015cd60 drop_through 0 bb_jmp[2]
18582 + new state c0728710
18584 +This state is different from any states already saved, clone to a new entry.
18586 + '0xc015cd2a getname+0x42: mov $0xc0000000,%ebx'
18587 + opcode 'mov' matched by 'mov', usage 36
18588 + src I: $0xc0000000
18589 + dst R: %ebx base_rc 3 (rbx)
18591 + '0xc015cd2f getname+0x47: sub %edi,%ebx'
18592 + opcode 'sub' matched by 'sub', usage 51
18593 + src R: %edi base_rc 6 (rdi)
18594 + dst R: %ebx base_rc 3 (rbx)
18596 + '0xc015cd31 getname+0x49: cmp $0xfff,%ebx'
18597 + opcode 'cmp' matched by 'cmp', usage 3
18599 + dst R: %ebx base_rc 3 (rbx)
18600 + '0xc015cd37 getname+0x4f: jbe 0xc015cd3e <getname+0x56>'
18601 + opcode 'jbe' matched by 'j', usage 28
18602 + src M: 0xc015cd3e
18603 + bb_reg_state c0728658
18612 + slot 0 offset_address -0x4 rbp
18613 + slot 1 offset_address -0x8 rdi
18614 + slot 2 offset_address -0xc rsi
18615 + slot 3 offset_address -0x10 rbx
18616 + matched: from 0xc015cd37 to 0xc015cd3e drop_through 0 bb_jmp[3]
18617 + new state c0728768
18619 +This state is different from any states already saved, clone to a new entry.
18621 + bb_reg_state c0728658
18630 + slot 0 offset_address -0x4 rbp
18631 + slot 1 offset_address -0x8 rdi
18632 + slot 2 offset_address -0xc rsi
18633 + slot 3 offset_address -0x10 rbx
18634 + matched: from 0xc015cd38 to 0xc015cd39 drop_through 1 bb_jmp[12]
18637 +Basic block 0 drops through to basic block 1, treat it as an implicit transfer
18638 +of control. The state is the same as the previous jump instruction so reuse it
18639 +and bump the reference count.
18641 +That ends basic block 0, now pick the next block in the list that (a) needs to
18642 +be scanned and (b) has all its input states defined. In this case bb[1].
18646 +bb[1] starts at 0xc015cd39 and has two paths that transfer control to it.
18647 +bb_jmp[1] from an explicit jump at 0xc015cd1b and a drop through at bb_jmp[12].
18648 +Where there is more than one input state we have to merge them and reconcile the
18651 + first state c07286b8
18653 +The first input state is stored at c07286b8. Looking back through the trace we
18654 +find that entry associated with bb_jmp[0], not bb_jmp[1] as expected. However
18655 +bb_jmp[1] reused the state that was stored for bb_jmp[0] so all is well.
18657 + bb_reg_state c0728658
18666 + slot 0 offset_address -0x4 rbp
18667 + slot 1 offset_address -0x8 rdi
18668 + slot 2 offset_address -0xc rsi
18669 + slot 3 offset_address -0x10 rbx
18671 +The first state for bb[1].
18673 + merging state c0728768
18675 +Now merge the second state, which is held at c0728768.
18680 +The two states disagree on the values being tracked in rbx and rsi. Compiler
18681 +theory 101 says that if two or more paths to a basic block have different values
18682 +for a register then that register cannot be relied on at the start of the block,
18683 +so make it undefined. The same logic applies to memory locations.
18686 + bb_reg_state c0728658
18695 + slot 0 offset_address -0x4 rbp
18696 + slot 1 offset_address -0x8 rdi
18697 + slot 2 offset_address -0xc rsi
18698 + slot 3 offset_address -0x10 rbx
18700 +After merging all the input states, this is the final starting state for bb[1].
18701 +Now track what bb[1] does to the state.
18703 + '0xc015cd39 getname+0x51: mov $0x1000,%ebx'
18704 + opcode 'mov' matched by 'mov', usage 36
18706 + dst R: %ebx base_rc 3 (rbx)
18708 + bb_reg_state c0728658
18717 + slot 0 offset_address -0x4 rbp
18718 + slot 1 offset_address -0x8 rdi
18719 + slot 2 offset_address -0xc rsi
18720 + slot 3 offset_address -0x10 rbx
18721 + matched: from 0xc015cd3d to 0xc015cd3e drop_through 1 bb_jmp[13]
18724 +bb[1] is a single instruction which drops through to bb[2].
18727 + first state c0728768
18728 + bb_reg_state c0728658
18737 + slot 0 offset_address -0x4 rbp
18738 + slot 1 offset_address -0x8 rdi
18739 + slot 2 offset_address -0xc rsi
18740 + slot 3 offset_address -0x10 rbx
18741 + merging state c0728768
18743 +bb[2] has two inputs, both vertices are pointing to input state c0728768.
18744 +Merging an entry with itself has no effect.
18746 + '0xc015cd3e getname+0x56: mov %ebx,%ecx'
18747 + opcode 'mov' matched by 'mov', usage 36
18748 + src R: %ebx base_rc 3 (rbx)
18749 + dst R: %ecx base_rc 4 (rcx)
18750 + rcx = rbx (undefined)
18751 + '0xc015cd40 getname+0x58: mov %edi,%edx'
18752 + opcode 'mov' matched by 'mov', usage 36
18753 + src R: %edi base_rc 6 (rdi)
18754 + dst R: %edx base_rc 5 (rdx)
18756 + '0xc015cd42 getname+0x5a: mov 0xfffffff0(%ebp),%eax'
18757 + opcode 'mov' matched by 'mov', usage 36
18758 + src M: 0xfffffff0(%ebp) base_rc 8 (rbp)
18759 + dst R: %eax base_rc 2 (rax)
18760 + rax = *(rbp-0x10) (osp-0x14) rax = undefined
18761 + '0xc015cd45 getname+0x5d: call 0xc023dbb4 <strncpy_from_user>'
18762 + opcode 'call' matched by 'call', usage 17
18763 + src M: 0xc023dbb4
18764 + bb_reg_state c0728658
18773 + slot 0 offset_address -0x4 rbp
18774 + slot 1 offset_address -0x8 rdi
18775 + slot 2 offset_address -0xc rsi
18776 + slot 3 offset_address -0x10 rbx
18780 + '0xc015cd4a getname+0x62: cmp $0x0,%eax'
18781 + opcode 'cmp' matched by 'cmp', usage 3
18783 + dst R: %eax base_rc 2 (rax)
18784 + '0xc015cd4d getname+0x65: jle 0xc015cd5a <getname+0x72>'
18785 + opcode 'jle' matched by 'j', usage 28
18786 + src M: 0xc015cd5a
18787 + bb_reg_state c0728658
18796 + slot 0 offset_address -0x4 rbp
18797 + slot 1 offset_address -0x8 rdi
18798 + slot 2 offset_address -0xc rsi
18799 + slot 3 offset_address -0x10 rbx
18800 + matched: from 0xc015cd4d to 0xc015cd5a drop_through 0 bb_jmp[4]
18802 + '0xc015cd4f getname+0x67: mov $0xffffffdc,%esi'
18803 + opcode 'mov' matched by 'mov', usage 36
18804 + src I: $0xffffffdc
18805 + dst R: %esi base_rc 7 (rsi)
18807 + '0xc015cd54 getname+0x6c: cmp %ebx,%eax'
18808 + opcode 'cmp' matched by 'cmp', usage 3
18809 + src R: %ebx base_rc 3 (rbx)
18810 + dst R: %eax base_rc 2 (rax)
18811 + '0xc015cd56 getname+0x6e: jae 0xc015cd60 <getname+0x78>'
18812 + opcode 'jae' matched by 'j', usage 28
18813 + src M: 0xc015cd60
18814 + bb_reg_state c0728658
18823 + slot 0 offset_address -0x4 rbp
18824 + slot 1 offset_address -0x8 rdi
18825 + slot 2 offset_address -0xc rsi
18826 + slot 3 offset_address -0x10 rbx
18827 + matched: from 0xc015cd56 to 0xc015cd60 drop_through 0 bb_jmp[5]
18829 + '0xc015cd58 getname+0x70: jmp 0xc015cd71 <getname+0x89>'
18830 + opcode 'jmp' matched by 'j', usage 28
18831 + src M: 0xc015cd71
18832 + bb_reg_state c0728658
18841 + slot 0 offset_address -0x4 rbp
18842 + slot 1 offset_address -0x8 rdi
18843 + slot 2 offset_address -0xc rsi
18844 + slot 3 offset_address -0x10 rbx
18845 + matched: from 0xc015cd58 to 0xc015cd71 drop_through 0 bb_jmp[6]
18849 + first state c0728768
18850 + bb_reg_state c0728658
18859 + slot 0 offset_address -0x4 rbp
18860 + slot 1 offset_address -0x8 rdi
18861 + slot 2 offset_address -0xc rsi
18862 + slot 3 offset_address -0x10 rbx
18864 +bb[3] only has one input, nothing to merge.
18866 + '0xc015cd5a getname+0x72: je 0xc015cd76 <getname+0x8e>'
18867 + opcode 'je' matched by 'j', usage 28
18868 + src M: 0xc015cd76
18869 + bb_reg_state c0728658
18878 + slot 0 offset_address -0x4 rbp
18879 + slot 1 offset_address -0x8 rdi
18880 + slot 2 offset_address -0xc rsi
18881 + slot 3 offset_address -0x10 rbx
18882 + matched: from 0xc015cd5a to 0xc015cd76 drop_through 0 bb_jmp[7]
18884 + '0xc015cd5c getname+0x74: jge 0xc015cd71 <getname+0x89>'
18885 + opcode 'jge' matched by 'j', usage 28
18886 + src M: 0xc015cd71
18887 + bb_reg_state c0728658
18896 + slot 0 offset_address -0x4 rbp
18897 + slot 1 offset_address -0x8 rdi
18898 + slot 2 offset_address -0xc rsi
18899 + slot 3 offset_address -0x10 rbx
18900 + matched: from 0xc015cd5c to 0xc015cd71 drop_through 0 bb_jmp[8]
18902 + '0xc015cd5e getname+0x76: mov %eax,%esi'
18903 + opcode 'mov' matched by 'mov', usage 36
18904 + src R: %eax base_rc 2 (rax)
18905 + dst R: %esi base_rc 7 (rsi)
18906 + rsi = rax (undefined)
18907 + bb_reg_state c0728658
18916 + slot 0 offset_address -0x4 rbp
18917 + slot 1 offset_address -0x8 rdi
18918 + slot 2 offset_address -0xc rsi
18919 + slot 3 offset_address -0x10 rbx
18920 + matched: from 0xc015cd5f to 0xc015cd60 drop_through 1 bb_jmp[14]
18924 + first state c0728768
18925 + bb_reg_state c0728658
18934 + slot 0 offset_address -0x4 rbp
18935 + slot 1 offset_address -0x8 rdi
18936 + slot 2 offset_address -0xc rsi
18937 + slot 3 offset_address -0x10 rbx
18938 + merging state c0728768
18939 + '0xc015cd71 getname+0x89: mov 0xfffffff0(%ebp),%eax'
18940 + opcode 'mov' matched by 'mov', usage 36
18941 + src M: 0xfffffff0(%ebp) base_rc 8 (rbp)
18942 + dst R: %eax base_rc 2 (rax)
18943 + rax = *(rbp-0x10) (osp-0x14) rax = undefined
18944 + '0xc015cd74 getname+0x8c: jmp 0xc015cd7d <getname+0x95>'
18945 + opcode 'jmp' matched by 'j', usage 28
18946 + src M: 0xc015cd7d
18947 + bb_reg_state c0728658
18956 + slot 0 offset_address -0x4 rbp
18957 + slot 1 offset_address -0x8 rdi
18958 + slot 2 offset_address -0xc rsi
18959 + slot 3 offset_address -0x10 rbx
18960 + matched: from 0xc015cd74 to 0xc015cd7d drop_through 0 bb_jmp[10]
18964 + first state c0728768
18965 + bb_reg_state c0728658
18974 + slot 0 offset_address -0x4 rbp
18975 + slot 1 offset_address -0x8 rdi
18976 + slot 2 offset_address -0xc rsi
18977 + slot 3 offset_address -0x10 rbx
18978 + '0xc015cd76 getname+0x8e: mov $0xfffffffe,%esi'
18979 + opcode 'mov' matched by 'mov', usage 36
18980 + src I: $0xfffffffe
18981 + dst R: %esi base_rc 7 (rsi)
18983 + '0xc015cd7b getname+0x93: jmp 0xc015cd60 <getname+0x78>'
18984 + opcode 'jmp' matched by 'j', usage 28
18985 + src M: 0xc015cd60
18986 + bb_reg_state c0728658
18995 + slot 0 offset_address -0x4 rbp
18996 + slot 1 offset_address -0x8 rdi
18997 + slot 2 offset_address -0xc rsi
18998 + slot 3 offset_address -0x10 rbx
18999 + matched: from 0xc015cd7b to 0xc015cd60 drop_through 0 bb_jmp[11]
19003 + first state c0728710
19004 + bb_reg_state c0728658
19013 + slot 0 offset_address -0x4 rbp
19014 + slot 1 offset_address -0x8 rdi
19015 + slot 2 offset_address -0xc rsi
19016 + slot 3 offset_address -0x10 rbx
19017 + merging state c0728768
19019 + merging state c0728768
19020 + merging state c0728768
19022 +bb[4] has 4 inputs, 3 of which have the same state. One one path (state
19023 +c0728710) rbx is defined, on the others (c0728768) rbx is undefined so the final
19024 +state has rbx as undefined.
19027 + bb_reg_state c0728658
19036 + slot 0 offset_address -0x4 rbp
19037 + slot 1 offset_address -0x8 rdi
19038 + slot 2 offset_address -0xc rsi
19039 + slot 3 offset_address -0x10 rbx
19040 + '0xc015cd60 getname+0x78: mov 0xfffffff0(%ebp),%edx'
19041 + opcode 'mov' matched by 'mov', usage 36
19042 + src M: 0xfffffff0(%ebp) base_rc 8 (rbp)
19043 + dst R: %edx base_rc 5 (rdx)
19044 + rdx = *(rbp-0x10) (osp-0x14) rdx = undefined
19045 + '0xc015cd63 getname+0x7b: mov 0xc04b2120,%eax'
19046 + opcode 'mov' matched by 'mov', usage 36
19047 + src M: 0xc04b2120
19048 + dst R: %eax base_rc 2 (rax)
19050 + '0xc015cd68 getname+0x80: call 0xc01521f1 <kmem_cache_free>'
19051 + opcode 'call' matched by 'call', usage 17
19052 + src M: 0xc01521f1
19053 + bb_reg_state c0728658
19062 + slot 0 offset_address -0x4 rbp
19063 + slot 1 offset_address -0x8 rdi
19064 + slot 2 offset_address -0xc rsi
19065 + slot 3 offset_address -0x10 rbx
19069 + bb_reg_state c0728658
19078 + slot 0 offset_address -0x4 rbp
19079 + slot 1 offset_address -0x8 rdi
19080 + slot 2 offset_address -0xc rsi
19081 + slot 3 offset_address -0x10 rbx
19082 + '0xc015cd6d getname+0x85: mov %esi,%eax'
19083 + opcode 'mov' matched by 'mov', usage 36
19084 + src R: %esi base_rc 7 (rsi)
19085 + dst R: %eax base_rc 2 (rax)
19086 + rax = rsi (undefined)
19087 + '0xc015cd6f getname+0x87: jmp 0xc015cd7d <getname+0x95>'
19088 + opcode 'jmp' matched by 'j', usage 28
19089 + src M: 0xc015cd7d
19090 + bb_reg_state c0728658
19099 + slot 0 offset_address -0x4 rbp
19100 + slot 1 offset_address -0x8 rdi
19101 + slot 2 offset_address -0xc rsi
19102 + slot 3 offset_address -0x10 rbx
19103 + matched: from 0xc015cd6f to 0xc015cd7d drop_through 0 bb_jmp[9]
19107 + first state c07286b8
19108 + bb_reg_state c0728658
19117 + slot 0 offset_address -0x4 rbp
19118 + slot 1 offset_address -0x8 rdi
19119 + slot 2 offset_address -0xc rsi
19120 + slot 3 offset_address -0x10 rbx
19121 + merging state c0728768
19124 + merging state c0728768
19126 + bb_reg_state c0728658
19135 + slot 0 offset_address -0x4 rbp
19136 + slot 1 offset_address -0x8 rdi
19137 + slot 2 offset_address -0xc rsi
19138 + slot 3 offset_address -0x10 rbx
19139 + '0xc015cd7d getname+0x95: pop %edx'
19140 + opcode 'pop' matched by 'pop', usage 42
19141 + src R: %edx base_rc 5 (rdx)
19142 + rdx = *(rsp+0x0) (osp-0x14) rdx = undefined
19143 + rsp osp offset -0x14 -> -0x10
19145 +This instruction is a bit misleading. It looks like gcc is restoring a value
19146 +from the stack *(osp-0x14) to edx, but we have no record of any useful data
19147 +being stored at osp-0x14. In fact gcc is just reducing the stack pointer by 4
19148 +bytes to reverse the effect of 0xc015ccee: sub $0x4,%esp, the value popped into
19149 +edx contains nothing useful. Why gcc does pop instead of add $0x4,%esp is a
19150 +puzzle, probably some micro optimization.
19152 + '0xc015cd7e getname+0x96: pop %ebx'
19153 + opcode 'pop' matched by 'pop', usage 42
19154 + src R: %ebx base_rc 3 (rbx)
19155 + rbx = *(rsp+0x0) (osp-0x10) value rbx
19156 + rsp osp offset -0x10 -> -0xc
19157 + delete rbx from osp-0x10 slot 3
19159 +This pop is doing something useful. It is restoring the original value of the
19160 +preserved register ebx from stack, reversing 0xc015cced: push %ebx. Note that
19161 +incrementing rsp from osp-0x10 to osp-0xc invalidates the data held in memory at
19162 +osp-0x10, so we delete our record of it.
19164 + '0xc015cd7f getname+0x97: pop %esi'
19165 + opcode 'pop' matched by 'pop', usage 42
19166 + src R: %esi base_rc 7 (rsi)
19167 + rsi = *(rsp+0x0) (osp-0xc) value rsi
19168 + rsp osp offset -0xc -> -0x8
19169 + delete rsi from osp-0xc slot 2
19170 + '0xc015cd80 getname+0x98: pop %edi'
19171 + opcode 'pop' matched by 'pop', usage 42
19172 + src R: %edi base_rc 6 (rdi)
19173 + rdi = *(rsp+0x0) (osp-0x8) value rdi
19174 + rsp osp offset -0x8 -> -0x4
19175 + delete rdi from osp-0x8 slot 1
19177 +Pop the other preserved registers, in reverse order to the push sequence at the
19180 + '0xc015cd81 getname+0x99: pop %ebp'
19181 + opcode 'pop' matched by 'pop', usage 42
19182 + src R: %ebp base_rc 8 (rbp)
19183 + rbp = *(rsp+0x0) (osp-0x4) value rbp
19184 + rsp osp offset -0x4 -> +0x0
19185 + delete rbp from osp-0x4 slot 0
19187 +Pop the previous frame pointer.
19189 + '0xc015cd82 getname+0x9a: ret '
19190 + opcode 'ret' matched by 'ret', usage 48
19192 +When a ret instruction is executed, all the preserved registers must be back to
19193 +their original value and the stack pointer must contain osp+0.
19194 +bb_sanity_check() will complain and abort the backtrace if this is not true. No
19197 + bb_pass2: end bb_reg_params 1 bb_memory_params 0
19199 +We identified one argument passed in a register (the read of rax at 0xc015ccf1)
19200 +and no reference to memory locations above the stack frame. So we have one
19201 +argument being passed in a register and no arguments being passed on stack.
19204 + char * getname(const char __user * filename)
19206 + bb_pass2: bb_exit_state at 0xc015cd6d
19207 + bb_reg_state c07287c0
19216 + slot 0 offset_address -0x4 rbp
19217 + slot 1 offset_address -0x8 rdi
19218 + slot 2 offset_address -0xc rsi
19219 + slot 3 offset_address -0x10 rbx
19221 +We told bb1 that the exit address from this function is 0xc015cd6d. The
19222 +abstract state at this exit point was saved, it defines how we rollback the
19223 +actual register values from the next function down the stack (kmem_cache_free)
19224 +to get the actual register values on entry to this function (getname). See
19225 +bb_actual_rollback() which updates bb_actual[].
19227 +Looking at the exit state above, we see that rsp contains the abstracte value
19228 +osp-0x14. It is a given that we have the actual value of rsp after the call
19229 +from getname() to kmem_cache_free(), otherwise we would not have found the
19230 +return address on stack and we would not be analysing getname(). Adding 0x14
19231 +(the delta from osp to rsp) to our current actual rsp gives us the actual value
19232 +of osp on entry to getname().
19234 +The main aim of doing all this work is to track the function arguments so we can
19235 +print them if possible. getname() only has one argument which was passed in
19236 +eax. According to the abstract exit state, the original value of rax is
19237 +currently in rdi, so by looking at the actual value of rdi from the next stack
19238 +frame down we are able to get the argument to getname().
19240 +It is not always possible to get register arguments, gcc will only preserve
19241 +input arguments as long as it needs them so there may be no saved copy of
19242 +arguments that are passed in register. In this case, bt_print_one() prints
19245 +If basic block analysis detected any arguments were passed on stack, their
19246 +contents can now be extracted based on the known value of the stack pointer.
19247 +bt_print_one() prints the arguments, if BT_ARGS is non-zero then any argument
19248 +that might be a kernel address is printed as a symbol.
19250 +Once rsp has been rolled back to osp, we can calculate that actual address of
19251 +the stack locations that contain useful data. The previous values of rbp, rdi,
19252 +rsi and rbx are then copied from those locations into bb_actual[]. That gives
19253 +the values for those registers at the exit point from the function that called
19254 +getname(). Go up one level and repeat the analysis.
19256 +There are two references to rdi in the exit state, which can be confusing.
19259 + slot 1 offset_address -0x8 rdi
19261 +The first reference says that "register rdi contains the original value of rax",
19262 +the second reference says that "*(osp-0x8) contains the original value of rdi".
19263 +Do not confuse the two, one is by name, the other is by value.
19265 +getname() is a fairly simple function, it has no loops. __follow_mount is more
19266 +complicated, it has loops as well as BUG() statements.
19268 + [0]kdb> id __follow_mount
19269 + 0xc015be76 __follow_mount: push %ebp
19270 + 0xc015be77 __follow_mount+0x1: mov %esp,%ebp
19271 + 0xc015be79 __follow_mount+0x3: push %edi
19272 + 0xc015be7a __follow_mount+0x4: push %esi
19273 + 0xc015be7b __follow_mount+0x5: push %ebx
19274 + 0xc015be7c __follow_mount+0x6: mov %eax,%esi
19275 + 0xc015be7e __follow_mount+0x8: xor %edi,%edi
19276 + 0xc015be80 __follow_mount+0xa: jmp 0xc015beca __follow_mount+0x54
19277 + 0xc015be82 __follow_mount+0xc: mov (%esi),%eax
19278 + 0xc015be84 __follow_mount+0xe: call 0xc0169664 lookup_mnt
19279 + 0xc015be89 __follow_mount+0x13: mov %eax,%ebx
19280 + 0xc015be8b __follow_mount+0x15: test %eax,%eax
19281 + 0xc015be8d __follow_mount+0x17: je 0xc015bed3 __follow_mount+0x5d
19282 + 0xc015be8f __follow_mount+0x19: mov 0x4(%esi),%eax
19283 + 0xc015be92 __follow_mount+0x1c: call 0xc0163de2 dput
19284 + 0xc015be97 __follow_mount+0x21: test %edi,%edi
19285 + 0xc015be99 __follow_mount+0x23: je 0xc015bead __follow_mount+0x37
19286 + 0xc015be9b __follow_mount+0x25: mov (%esi),%eax
19287 + 0xc015be9d __follow_mount+0x27: test %eax,%eax
19288 + 0xc015be9f __follow_mount+0x29: je 0xc015bead __follow_mount+0x37
19289 + 0xc015bea1 __follow_mount+0x2b: movl $0x0,0x64(%eax)
19290 + 0xc015bea8 __follow_mount+0x32: call 0xc016835b mntput_no_expire
19291 + 0xc015bead __follow_mount+0x37: mov %ebx,(%esi)
19292 + 0xc015beaf __follow_mount+0x39: mov 0x10(%ebx),%eax
19293 + 0xc015beb2 __follow_mount+0x3c: test %eax,%eax
19294 + 0xc015beb4 __follow_mount+0x3e: je 0xc015bec2 __follow_mount+0x4c
19295 + 0xc015beb6 __follow_mount+0x40: cmpl $0x0,(%eax)
19296 + 0xc015beb9 __follow_mount+0x43: jne 0xc015bebf __follow_mount+0x49
19297 + 0xc015bebb __follow_mount+0x45: ud2a
19298 + 0xc015bebd __follow_mount+0x47: jmp 0xc015bebd __follow_mount+0x47
19299 + 0xc015bebf __follow_mount+0x49: lock incl (%eax)
19300 + 0xc015bec2 __follow_mount+0x4c: mov %eax,0x4(%esi)
19301 + 0xc015bec5 __follow_mount+0x4f: mov $0x1,%edi
19302 + 0xc015beca __follow_mount+0x54: mov 0x4(%esi),%edx
19303 + 0xc015becd __follow_mount+0x57: cmpl $0x0,0x74(%edx)
19304 + 0xc015bed1 __follow_mount+0x5b: jne 0xc015be82 __follow_mount+0xc
19305 + 0xc015bed3 __follow_mount+0x5d: mov %edi,%eax
19306 + 0xc015bed5 __follow_mount+0x5f: pop %ebx
19307 + 0xc015bed6 __follow_mount+0x60: pop %esi
19308 + 0xc015bed7 __follow_mount+0x61: pop %edi
19309 + 0xc015bed8 __follow_mount+0x62: pop %ebp
19310 + 0xc015bed9 __follow_mount+0x63: ret
19312 + [0]kdb> bb1 0xc015bed9
19313 + bb_pass1: func_name __follow_mount func_start 0xc015be76 func_end 0xc015beda
19315 + bb[0] start 0xc015be76 end 0xc015be80 drop_through 0
19316 + bb[1] start 0xc015be82 end 0xc015beac drop_through 1
19317 + bb[2] start 0xc015bead end 0xc015bebb drop_through 0
19319 +Note that the ud2a (BUG) instruction at 0xc015bebb ends bb[2].
19321 + bb[3] start 0xc015bebd end 0xc015bebd drop_through 0
19323 +bb[3] is peculiar, it is a jmp to itself, nothing else refers to 0xc015bebd and
19324 +you cannot drop through from the previous instruction because ud2a kills the
19325 +kernel. The i386 and x86_64 BUG() macros contain for(;;) after ud2a, for no
19326 +good reason that I can see (is there old hardware that does not abort on ud2a?).
19327 +ia64 and the generic versions of BUG() do not contain for(;;). for(;;) after
19328 +ud2a generates a branch to itself than can never be executed.
19330 + bb[4] start 0xc015bebf end 0xc015bec1 drop_through 1
19331 + bb[5] start 0xc015bec2 end 0xc015bec9 drop_through 1
19332 + bb[6] start 0xc015beca end 0xc015bed2 drop_through 1
19333 + bb[7] start 0xc015bed3 end 0xc015bed9 drop_through 0
19334 + bb_jmp[0] from 0xc015be80 to 0xc015beca drop_through 0
19335 + bb_jmp[1] from 0xc015be8d to 0xc015bed3 drop_through 0
19336 + bb_jmp[2] from 0xc015be99 to 0xc015bead drop_through 0
19337 + bb_jmp[3] from 0xc015be9f to 0xc015bead drop_through 0
19338 + bb_jmp[4] from 0xc015beb4 to 0xc015bec2 drop_through 0
19339 + bb_jmp[5] from 0xc015beb9 to 0xc015bebf drop_through 0
19340 + bb_jmp[6] from 0xc015bebd to 0xc015bebd drop_through 0
19341 + bb_jmp[7] from 0xc015bed1 to 0xc015be82 drop_through 0
19342 + bb_jmp[8] from 0xc015beac to 0xc015bead drop_through 1
19343 + bb_jmp[9] from 0xc015bec1 to 0xc015bec2 drop_through 1
19344 + bb_jmp[10] from 0xc015bec9 to 0xc015beca drop_through 1
19345 + bb_jmp[11] from 0xc015bed2 to 0xc015bed3 drop_through 1
19347 +Apart from bb[0] and the special case bb[3], all the other blocks are part of a
19348 +cycle. That cycle goes bb[0] -> bb[6]. bb[6] -> {bb[1], bb[7]}. bb[1] ->
19349 +{bb[2], bb[7]}. bb[2] -> {bb[4], bb[5]}. bb[4] -> bb[5]. bb[5] -> bb[6] and
19350 +back to the start. bb[7] ends with 'ret', it does not feed into other blocks.
19354 + bb_pass2_do_changed_blocks: allow_missing 0
19357 + [ ... detail snipped ... ]
19358 + matched: from 0xc015be80 to 0xc015beca drop_through 0 bb_jmp[0]
19359 + new state c07286d8
19361 + bb_pass2_do_changed_blocks: allow_missing 1
19363 +Because of the cycle, only bb[0] can be processed with 0 missing inputs, all the
19364 +other blocks have at least one missing input. Call bb_pass2_do_changed_blocks()
19365 +again, this time allowing one missing input per blocks.
19368 + first state c07286d8
19369 + [ ... detail snipped ... ]
19370 + matched: from 0xc015bed2 to 0xc015bed3 drop_through 1 bb_jmp[11]
19374 + first state c0728730
19375 + [ ... detail snipped ... ]
19378 + first state c0728730
19379 + [ ... detail snipped ... ]
19380 + matched: from 0xc015beac to 0xc015bead drop_through 1 bb_jmp[8]
19384 + first state c0728788
19385 + [ ... detail snipped ... ]
19386 + merging state c0728788
19387 + merging state c0728788
19388 + [ ... detail snipped ... ]
19389 + matched: from 0xc015beb9 to 0xc015bebf drop_through 0 bb_jmp[5]
19393 + first state c0728788
19394 + [ ... detail snipped ... ]
19395 + matched: from 0xc015bec1 to 0xc015bec2 drop_through 1 bb_jmp[9]
19399 + first state c0728788
19400 + [ ... detail snipped ... ]
19401 + merging state c0728788
19402 + [ ... detail snipped ... ]
19403 + matched: from 0xc015bec9 to 0xc015beca drop_through 1 bb_jmp[10]
19407 + first state c07286d8
19408 + [ ... detail snipped ... ]
19409 + merging state c0728788
19410 + matched: from 0xc015bed2 to 0xc015bed3 drop_through 1 bb_jmp[11]
19413 +Note the rescan of bb[6]. The first scan only had one input from bb[0]. After
19414 +traversing the cycle and getting back from bb[5] to bb[6], bb[6] now has more
19415 +inputs so we need to rescan it. With the additional input, the output state
19416 +from bb[6] has changed since the first scan, which means that every block it
19417 +feeds has to be rescanned. bb[6] feeds bb[1] and bb[7].
19420 + first state c0728788
19421 + [ ... detail snipped ... ]
19422 + merging state c0728788
19423 + [ ... detail snipped ... ]
19425 +bb[7] being rescanned, this time it has data for both its inputs.
19428 + first state c0728788
19429 + [ ... detail snipped ... ]
19430 + matched: from 0xc015beac to 0xc015bead drop_through 1 bb_jmp[8]
19433 +bb[1] is being rescanned because the input from bb[6] has changed, however the
19434 +rescan of bb[1] reports 'no state change', the changed input from bb[6] did not
19435 +affect the final output state from bb[1]. Because the output state from bb[1]
19436 +has not changed since the previous scan, there is no need to rescan bb[2], bb[7]
19437 +or bb[4]. Since bb[4] is not being rescanned, there is no need to rescan bb[5]
19438 +or bb[6] and the cycle is closed.
19439 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_bp.man linux-2.6.22-600/Documentation/kdb/kdb_bp.man
19440 --- linux-2.6.22-590/Documentation/kdb/kdb_bp.man 1970-01-01 01:00:00.000000000 +0100
19441 +++ linux-2.6.22-600/Documentation/kdb/kdb_bp.man 2008-04-09 18:14:28.000000000 +0200
19443 +.TH BD 1 "July 12, 2004"
19445 +bp, bpa, bph, bpha, bd, bc, be, bl \- breakpoint commands
19447 +bp \fIaddress-expression\fP
19449 +bpa \fIaddress-expression\fP
19451 +bph \fIaddress-expression\fP [\f(CWDATAR|DATAW|DATAA|IO\fP [\fIlength\fP]]
19453 +bpha \fIaddress-expression\fP [\f(CWDATAR|DATAW|DATAA|IO\fP [\fIlength\fP]]
19455 +bd \fIbreakpoint-number\fP
19457 +bc \fIbreakpoint-number\fP
19459 +be \fIbreakpoint-number\fP
19466 +family of commands are used to establish a breakpoint.
19467 +The \fIaddress-expression\fP may be a numeric value (decimal or
19468 +hexidecimal), a symbol name, a register name preceeded by a
19469 +percent symbol '%', or a simple expression consisting of a
19470 +symbol name, an addition or subtraction character and a numeric
19471 +value (decimal or hexidecimal).
19473 +\fBbph\fP and \fBbpha\fP will force the use of a hardware register, provided
19474 +the processor architecture supports them.
19476 +The \fIaddress-expression\fP may also consist of a single
19477 +asterisk '*' symbol which indicates that the command should
19478 +operate on all existing breakpoints (valid only for \fBbc\fP,
19479 +\fBbd\fP and \fBbe\fP).
19481 +Four different types of
19482 +breakpoints may be set:
19486 +Causes the kernel debugger to be invoked from the debug exception
19487 +path when an instruction is fetched from the specified address. This
19488 +is the default if no other type of breakpoint is requested or when
19489 +the \fBbp\fP command is used.
19493 +Causes the kernel debugger to be entered when data of length
19494 +\fIlength\fP is read from or written to the specified address.
19495 +This type of breakpoint must use a processor debug register which
19496 +places an architecture dependent limit on the number of data and I/O
19497 +breakpoints that may be established. On arm mode XScale platform
19498 +(thumb mode is not supported yet),
19499 +debugger is triggered by reading from the specified address.
19500 +The \fBbph\fP or \fBbpha\fP commands must be used.
19504 +Enters the kernel debugger when data of length \fIlength\fP
19505 +is written to the specified address. \fIlength\fP defaults
19506 +to four bytes if it is not explicitly specified.
19507 +Note that the processor may have already overwritten the prior data at
19508 +the breakpoint location before the kernel debugger is invoked.
19509 +The prior data should be saved before establishing the breakpoint, if
19510 +required. On arm mode XScale platform, the debugger is triggered
19511 +after having overwritten the specified address.
19512 +The \fBbph\fP or \fBbpha\fP commands must be used.
19516 +Enters the kernel debugger when an \fBin\fP or \fBout\fP instruction
19517 +targets the specified I/O address. The \fBbph\fP or \fBbpha\fP
19518 +commands must be used. This type of breakpoint is not valid in
19519 +arm mode XScale platform. This option is not valid in arm
19520 +mode XScale platform.
19524 +Enters the kernel debugger after the data in specified address has
19525 +been accessed (read or write), this option is only used in arm
19526 +mode XScale platform.
19531 +command will establish a breakpoint on all processors in an
19532 +SMP system. This command is not available in an uniprocessor
19537 +command will disable a breakpoint without removing it from the kernel
19538 +debugger's breakpoint table.
19539 +This can be used to keep breakpoints in the table without exceeding the
19540 +architecture limit on breakpoint registers.
19541 +A breakpoint-number of \fI*\fR will disable all break points.
19545 +command will re-enable a disabled breakpoint.
19546 +A breakpoint-number of \fI*\fR will enable all break points.
19550 +command will clear a breakpoint from the breakpoint table.
19551 +A breakpoint-number of \fI*\fR will clear all break points.
19555 +command will list the existing set of breakpoints.
19557 +There is a compile time limit of sixteen entries in the
19558 +breakpoint table at any one time.
19560 +There are architecture dependent limits on the number of hardware
19561 +breakpoints that can be set.
19566 +Two for insruction breakpoints and another two for data breakpoint.
19574 +When issuing the "go" command after entering the debugger due to
19575 +a breakpoint, kdb will silently perform a single step in order to
19576 +reapply the breakpoint. The sparc64 port has some limitations on
19577 +single stepping, which may limit where a breakpoint may be safely
19578 +set. Please read the man page for \fBss\fP for more information.
19580 +The breakpoint subsystem does not currently use any environment
19582 +.SH SMP CONSIDERATIONS
19585 +is risky on SMP systems.
19586 +If you clear a breakpoint when another cpu has hit that breakpoint but
19587 +has not been processed then it may not be recognised as a kdb
19588 +breakpoint, usually resulting in incorrect program counters and kernel
19590 +It is safer to disable the breakpoint with
19594 +to let any other processors that are waiting on the breakpoint to
19596 +After all processors are clear of the disabled breakpoint then it is
19597 +safe to clear it using
19600 +Breakpoints which use the processor breakpoint registers
19601 +are only established on the processor which is
19602 +currently active. If you wish breakpoints to be universal
19611 +Sets an instruction breakpoint at the begining of the
19612 +function \fBschedule\fP.
19616 +Sets an instruction breakpoint at the instruction located
19617 +at \fBschedule\fP+\fI0x12e\fP.
19620 +bph ttybuffer+0x24 dataw
19621 +Sets a data write breakpoint at the location referenced by
19622 +\fBttybuffer\fP+\fI0x24\fP for a length of four bytes.
19625 +bph 0xc0254010 datar 1
19626 +Establishes a data reference breakpoint at address \fB0xc0254010\fP
19627 +for a length of one byte.
19631 +List current breakpoint table.
19635 +Disable breakpoint #0.
19639 +Clear all breakpoints
19640 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_bt.man linux-2.6.22-600/Documentation/kdb/kdb_bt.man
19641 --- linux-2.6.22-590/Documentation/kdb/kdb_bt.man 1970-01-01 01:00:00.000000000 +0100
19642 +++ linux-2.6.22-600/Documentation/kdb/kdb_bt.man 2008-04-09 18:14:28.000000000 +0200
19644 +.TH BT 1 "July 20, 2007"
19646 +bt \- Stack Traceback command
19648 +bt [ <stack-frame-address> ]
19652 +btt <struct-task-address>
19661 +command is used to print a stack traceback. It uses the
19662 +current registers (see \fBrd\fP command) to determine
19663 +the starting context and attempts to provide a complete
19664 +stack traceback for the active thread. If \fIstack-frame-address\fP
19665 +is supplied, it is assumed to point to the start of a valid
19666 +stack frame and the stack will be traced back from that
19668 +On x86 architecture, \fIstack-frame-address\fP must be the stack address of a
19669 +saved \fB%eip\fP (\fB%rip\fP for x86_64) value from a \fBcall\fP instruction.
19671 +The \fBbtp\fP command will analyze the stack for the given
19672 +process identification (see the \fBps\fP command).
19673 +\fBbtp\fP sets the current process for any following register display or update
19676 +The \fBbtt\fP command will analyze the stack for the given task
19678 +It is exactly equivalent to \fBbtp\fR on the pid extracted from the
19680 +\fBbtt\fP sets the current process for any following register display or update
19683 +The \fBbta\fP command lists the stack for all processes in the desired
19685 +Without any parameters, \fBbta\fP gives a backtrace for all useful processes.
19686 +If a parameter is specified, it is a single string consisting of the
19687 +letters D, R, S, T, Z, U, I, M and A in any order.
19688 +See the kdb \fBps\fR man page for more details.
19689 +\fBbta\fP does not change the current process.
19691 +The \fBbtc\fP command will analyze the stack for the current process on
19692 +a specified cpu or, if no cpu number is supplied, for the current
19693 +process on all cpus.
19694 +It does not switch to the other cpus, instead it uses the task
19695 +structures to identify and issue \fBbtt\fR against the current task on
19697 +\fBbtc\fP with no arguments does not change the current process.
19698 +\fBbtc\fP with a cpu number sets the current process for any following register
19699 +display or update commands.
19701 +For each function, the stack trace prints at least two lines.
19702 +The first line contains four or five fields\ :-
19704 +The pointer to the stack frame.
19707 +The current address within this frame.
19709 +The address converted to a function name (actually the first non-local
19710 +label which is <= the address).
19712 +The offset of the address within the function.
19714 +Any parameters to the function.
19717 +If environment variable NOSECT is set to 0 then the next line contains
19718 +five fields which are designed to make it easier to match the trace
19719 +against the kernel code\ :-
19721 +The module name that contains the address, "kernel" if it is in the
19725 +The section name that contains the address (not available on 2.6 kernels).
19727 +The start address of the section (not available on 2.6 kernels).
19729 +The start address of the function.
19731 +The end address of the function (the first non-local label which is >
19735 +If arguments are being converted to symbols, any argument which
19736 +converts to a kernel or module address is printed as\ :-
19741 +The module name that contains the address, "kernel" if it is in the
19744 +The symbol name the argument maps to.
19746 +The offset of the argument from the symbol, suppressed if 0.
19749 +On architectures that use nested stacks, the backtrace will indicate a
19750 +switch to a new stack by printing a line of equal signs and the type of
19752 +.SH MATCHING TRACE TO KERNEL CODE
19753 +The command "objdump\ -S" will disassemble an object and, if the code
19754 +was compiled with debugging (gcc flag -g), objdump will interleave the
19755 +C source lines with the generated object.
19757 +A complete objdump of the kernel or a module is too big, normally you
19758 +only want specific functions.
19759 +By default objdump will only print the .text section but Linux uses
19760 +other section names for executable code.
19761 +When objdump prints relocatable objects (modules) it uses an offset of
19762 +0 which is awkward to relate to the stack trace.
19763 +The five fields which are printed for each function are designed to
19764 +make it easier to match the stack trace against the kernel code using
19767 +If the function is in the kernel then you need the section name, the
19768 +start and end address of the function. The command is
19771 + objdump -S -j <section_name> \\
19772 + --start-address=<start-address> \\
19773 + --stop-address=<end-address> \\
19774 + /usr/src/linux/vmlinux
19777 +If the function is in a module then you need the section name, the
19778 +start address of the section, the start and end address of the
19779 +function, the module name. The command is
19782 + objdump -S -j <section_name> \\
19783 + --adjust-vma=<section-start> \\
19784 + --start-address=<start-address> \\
19785 + --stop-address=<end-address> \\
19786 + /path/to/module/<module-name>.o
19789 +Unfortunately the 2.6 kernel does not provide the information required
19790 +to locate the start of the section, which makes it very difficult to
19791 +perform a reliable objdump on a module.
19793 +All addresses to objdump must be preceded by '0x' if they are in hex,
19794 +objdump does not assume hex.
19795 +The stack trace values are printed with leading '0x' to make it easy to
19798 +Some architectures pass parameters in registers; ia64, x86_64 and i386 (with
19799 +gcc flag -mregparm) fall into this category.
19800 +On these architectures, the compiler may reuse input parameter registers as
19802 +For example, if a function takes a pointer to a structure and only accesses one
19803 +field in that structure, the compiler may calculate the address of the field by
19804 +adding a value to the input register.
19805 +Once the input register has been updated, it no longer points to the
19806 +start of the structure, but to some field within it.
19807 +This also occurs with array pointers, the compiler may update the input pointer
19808 +directly, leaving it pointing to some element of the array instead of the start
19810 +Always treat parameter values that have been passed in registers with extreme
19811 +suspicion, the compiler may have changed the value.
19812 +The x86 backtrace can generally identify register parameters that are no longer
19813 +valid, it prints them as 'invalid' instead of as a misleading number.
19814 +The ia64 backtrace cannot identify parameter registers that have been
19817 +x86 architectures do not have full unwind information in the kernel.
19818 +The KDB backtrace on x86 performs code decomposition and analysis to track the
19819 +frames on the call stack (including stack switches) and to locate parameters.
19820 +if this code analysis does not yield a valid result, KDB falls back on the old
19821 +method of scanning the process stack and printing anything that looks like a
19823 +This old method is unreliable (it produces lots of false positives in the
19824 +trace) and cannot track parameters at all, so no parameters are printed.
19825 +If you get an x86 backtrace that falls back to the old method, read
19826 +Documentation/kdb/bt_x86 and follow the steps listed to get diagnostics and to
19827 +submit a bug report.
19829 +There are a lot of functions in the kernel which take some arguments then do
19830 +nothing except call another function with the same initial arguments, sometimes
19831 +adding parameters at the end. For example\ :-
19836 +int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen,
19837 + void __user *oldval, size_t __user *oldlenp,
19838 + void __user *newval, size_t newlen)
19840 + int ret = devinet_conf_sysctl(table, name, nlen, oldval, oldlenp,
19844 + rt_cache_flush(0);
19851 +ipv4_doint_and_flush_strategy() passes all its parameters directly to
19852 +devinet_conf_sysctl() and makes no other use of those parameters,
19853 +so ipv4_doint_and_flush_strategy is a 'pass through' function.
19854 +The x86_64 calling sequence mandates that the first 6 parameters are passed in
19855 +registers, with other parameters being passed on stack.
19856 +The i386 calling sequence with -mregparm=3 (which is the default since about
19857 +2.6.18) passes the first 3 parameters in registers, with other parameters being
19859 +The only exceptions to the above calling sequence are for functions declared as
19860 +asmlinkage or functions with a variable number of parameters (e.g. printk).
19862 +When a pass through function calls another function, the first 3 (i386) or 6
19863 +(x86) parameters are already in their correct registers so the pass through
19864 +function does not need to access the registers, which means that there are no
19865 +references to these registers in the assembler code for the function.
19866 +Users still want to see those arguments so the x86 backtrace has to assume that
19869 +There are parameters passed on the stack and
19871 +There are no code references to parameters passed in registers and
19873 +The function is not a known asmlinkage or variadic function, then
19874 +there are pass through register arguments.
19876 +The x86 backtrace will warn you when it makes this assumption, like this\ :-
19881 + <function_name> has memory parameters but no register parameters.
19882 + Assuming it is a 'pass through' function that does not refer to its register
19883 + parameters and setting <n> register parameters
19887 +The above 3 line message is only printed once, any future assumptions will
19888 +print a shorter message.
19890 +The \fBbt\fP command may print more or less arguments for a function
19891 +than that function accepts.
19892 +For x86, trailing arguments that are passed in but not used by the function
19893 +will not be printed, resulting in fewer arguments than expected.
19894 +For ia64, the hardware does not distinguish between input and local registers,
19895 +some local registers may be printed as function arguments, resulting in more
19896 +arguments than expected.
19898 +On i386, 64 bit arguments (long long) occupy two adjacent 32 bit fields.
19899 +There is no way for KDB to tell that this has occurred, so 64 bit arguments
19900 +will be printed as two separate 32 bit arguments.
19902 +The \fBBTARGS\fP environment variable governs the maximum number
19903 +of arguments that are printed for any single function.
19904 +On IA64 hardware, there is no difference between input and local registers, the
19905 +first \fBBTARGS\fP registers are printed, up to the total limit of input plus
19907 +Use a large value for \fBBTARGS\fP if you want to see the local registers on
19910 +If the \fBBTSP\fP environment variable is non-zero then the entire backtrace is
19911 +printed, otherwise only the backtrace to the point of the last interrupt is
19913 +Printing the entire backtrace with 'set\ BTSP\ 1' is useful for diagnosing
19914 +problems with the backtrace algorithms.
19915 +In addition, when BTSP is non-zero, each backtrace frame may print extra lines
19916 +giving information about the stack pointers, this is architecture specific.
19918 +If the \fBBTSYMARG\fP environment variable is non-zero then any
19919 +arguments that fall within the kernel or modules are converted to symbols.
19921 +If the \fBNOSECT\fP environment variable is non-zero then the
19922 +section information is suppressed.
19923 +The default is NOSECT=1 so section data is suppressed; use set\ NOSECT=0
19924 +to see section information.
19926 +The \fBBTAPROMPT\fP environment variable controls the prompt after each
19927 +process is listed by the \fBbta\fP command. If \fBBTAPROMPT\fP is not
19928 +set or is non-zero then \fBbta\fP issues a prompt after each process is
19929 +listed. If \fBBTAPROMPT\fP is set to zero then no prompt is issued and
19930 +all processes are listed without human intervention.
19932 +\fBbt\fR with no parameters uses the \fBPS\fR environment variable, see
19933 +the kdb \fBps\fR man page.
19934 +.SH SMP CONSIDERATIONS
19941 +Stack traceback for pid 2873
19942 +0xc2efc0f0 2873 2836 1 0 R 0xc2efc2a0 *mount
19943 +esp eip Function (args)
19944 +0xf65a3c88 0xc0201f9f xfs_mount_validate_sb (0xf68bcb08, 0xf68bcb48, 0x0)
19945 +0xf65a3c94 0xc0202f17 xfs_readsb+0x9d (0xf68bcb08, 0x0)
19946 +0xf65a3cc0 0xc020a72e xfs_mount+0x21d (invalid, 0xf68bc2f0, 0x0)
19947 +0xf65a3cf4 0xc021a84a vfs_mount+0x1a (invalid)
19948 +0xf65a3d04 0xc021a721 xfs_fs_fill_super+0x76 (0xf76b6200, invalid, invalid)
19949 +0xf65a3d78 0xc015ad81 get_sb_bdev+0xd4 (invalid, invalid, invalid, 0xf7257000, 0xc021a6ab, 0xf7594b38)
19950 + xfs_fs_get_sb has memory parameters but no register parameters.
19951 + Assuming it is a 'pass through' function that does not refer to its register
19952 + parameters and setting 3 register parameters
19953 +0xf65a3db4 0xc0219a3a xfs_fs_get_sb+0x21 (invalid, invalid, invalid, 0xf7257000, 0xf7594b38)
19954 +0xf65a3dcc 0xc015a992 vfs_kern_mount+0x41 (0xc04847e0, 0x0, 0xf68e9000, 0xf7257000)
19955 +0xf65a3df0 0xc015aa11 do_kern_mount+0x38 (0xf6818000, 0x0, 0xf68e9000, 0xf7257000)
19956 +0xf65a3e10 0xc016c8b0 do_mount+0x5df (0xf68e9000, 0xf65d6000, 0xf6818000, 0xc0ed0000, 0xf7257000)
19957 +0xf65a3f90 0xc016c996 sys_mount+0x6f (0x8069b50, 0x8069b60, 0x8069b70, 0xc0ed0000, 0x8069ba0)
19958 +0xf65a3fb4 0xc0102646 sysenter_past_esp+0x5f (invalid, invalid, invalid, 0x73, 0x246, 0xbfe52f50)
19959 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_env.man linux-2.6.22-600/Documentation/kdb/kdb_env.man
19960 --- linux-2.6.22-590/Documentation/kdb/kdb_env.man 1970-01-01 01:00:00.000000000 +0100
19961 +++ linux-2.6.22-600/Documentation/kdb/kdb_env.man 2008-04-09 18:14:28.000000000 +0200
19963 +.TH ENV 1 "24 September 2000"
19965 +env, set \- Environment manipulation commands
19969 +set \fIenvironment-variable\fP=\fIvalue\fP
19971 +The kernel debugger contains an environment which contains a series
19972 +of name-value pairs. Some environment variables are known to the
19973 +various kernel debugger commands and have specific meaning to the
19974 +command; such are enumerated on the respective reference material.
19976 +Arbitrary environment variables may be created and used with
19977 +many commands (those which require an \fIaddress-expression\fP).
19981 +command is used to display the current environment.
19985 +command is used to alter an existing environment variable or
19986 +establish a new environment variable.
19988 +There is a compile-time limit of 33 environment variables.
19990 +There is a compile-time limit of 512 bytes (\fBKDB_ENVBUFSIZE\fP)
19991 +of heap space available for new environment variables and for
19992 +environment variables changed from their compile-time values.
19994 +These commands explicitly manipulate the environment.
19995 +.SH SMP CONSIDERATIONS
19998 +You can include "set" commands in kdb/kdb_cmds (see kdb.mm) to define
19999 +your environment variables at kernel startup.
20003 +Display current environment settings.
20007 +Set the number of lines to display for the \fBid\fP command
20008 +to the value \fI100\fP.
20009 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_ll.man linux-2.6.22-600/Documentation/kdb/kdb_ll.man
20010 --- linux-2.6.22-590/Documentation/kdb/kdb_ll.man 1970-01-01 01:00:00.000000000 +0100
20011 +++ linux-2.6.22-600/Documentation/kdb/kdb_ll.man 2008-04-09 18:14:28.000000000 +0200
20013 +.TH LL 1 "19 April 1999"
20015 +ll \- Linked List examination
20017 +ll <addr> <link-offset> <cmd>
20021 +command is used to execute a single command repetitively for
20022 +each element of a linked list.
20024 +The command specified by <cmd> will be executed with a single
20025 +argument, the address of the current element.
20027 +Be careful if using this command recursively.
20030 +.SH SMP CONSIDERATIONS
20037 +# insmod kdbm_vm.o
20038 +# Entering kdb on processor 0 due to PAUSE
20040 +Task Addr Pid Parent cpu lcpu Tss Command
20041 +0xc03de000 0000000001 0000000000 0000 0000 0xc03de2d4 init
20042 +0xc0090000 0000000002 0000000001 0000 0000 0xc00902d4 kflushd
20043 +0xc000e000 0000000003 0000000001 0000 0000 0xc000e2d4 kpiod
20044 +0xc000c000 0000000004 0000000001 0000 0000 0xc000c2d4 kswapd
20045 +0xc7de2000 0000000056 0000000001 0000 0000 0xc7de22d4 kerneld
20046 +0xc7d3a000 0000000179 0000000001 0000 0000 0xc7d3a2d4 syslogd
20047 +0xc7a7e000 0000000188 0000000001 0000 0000 0xc7a7e2d4 klogd
20048 +0xc7a04000 0000000199 0000000001 0000 0000 0xc7a042d4 atd
20049 +0xc7b84000 0000000210 0000000001 0000 0000 0xc7b842d4 crond
20050 +0xc79d6000 0000000221 0000000001 0000 0000 0xc79d62d4 portmap
20051 +0xc798e000 0000000232 0000000001 0000 0000 0xc798e2d4 snmpd
20052 +0xc7904000 0000000244 0000000001 0000 0000 0xc79042d4 inetd
20053 +0xc78fc000 0000000255 0000000001 0000 0000 0xc78fc2d4 lpd
20054 +0xc77ec000 0000000270 0000000001 0000 0000 0xc77ec2d4 sendmail
20055 +0xc77b8000 0000000282 0000000001 0000 0000 0xc77b82d4 gpm
20056 +0xc7716000 0000000300 0000000001 0000 0000 0xc77162d4 smbd
20057 +0xc7ee2000 0000000322 0000000001 0000 0000 0xc7ee22d4 mingetty
20058 +0xc7d6e000 0000000323 0000000001 0000 0000 0xc7d6e2d4 login
20059 +0xc778c000 0000000324 0000000001 0000 0000 0xc778c2d4 mingetty
20060 +0xc78b6000 0000000325 0000000001 0000 0000 0xc78b62d4 mingetty
20061 +0xc77e8000 0000000326 0000000001 0000 0000 0xc77e82d4 mingetty
20062 +0xc7708000 0000000327 0000000001 0000 0000 0xc77082d4 mingetty
20063 +0xc770e000 0000000328 0000000001 0000 0000 0xc770e2d4 mingetty
20064 +0xc76b0000 0000000330 0000000001 0000 0000 0xc76b02d4 update
20065 +0xc7592000 0000000331 0000000323 0000 0000 0xc75922d4 ksh
20066 +0xc7546000 0000000338 0000000331 0000 0000 0xc75462d4 su
20067 +0xc74dc000 0000000339 0000000338 0000 0000 0xc74dc2d4 ksh
20068 +kdb> md 0xc74dc2d4
20069 +c74dc2d4: 00000000 c74de000 00000018 00000000 .....`MG........
20070 +c74dc2e4: 00000000 00000000 00000000 074de000 .............`M.
20071 +c74dc2f4: c01123ff 00000000 00000000 00000000 #.@............
20072 +c74dc304: 00000000 00000000 c74dded0 00000000 ........P^MG....
20074 +c74dc474: 00000000 00000000 00000000 00000000 ................
20075 +c74dc484: 00000000 c7c15d00 c77b0900 c026fbe0 .....]AG..{G`{&@
20076 +c74dc494: 00000000 c76c2000 00000000 00000000 ..... lG........
20077 +c74dc4a4: 00000000 00000000 00000000 c74dc4ac ............,DMG
20078 +kdb> md 0xc026fbe0
20079 +c026fbe0: c0262b60 00000000 c7594940 c74de000 @HYG....@IYG.`MG
20081 +kdb> md 0xc0262b60
20082 +c0262b60: c0266660 08048000 0804c000 c7bec360 `f&@.....@..`C>G
20083 +kdb> ll c0262b60 12 md
20084 +c0262b60: c0266660 08048000 0804c000 c7bec360 `f&@.....@..`C>G
20085 +c7bec360: c0266660 0804c000 0804d000 c7becb20 `f&@.@...P.. K>G
20086 +c7becb20: c0266660 0804d000 08050000 c7bec3a0 `f&@.P...... C>G
20087 +c7bec3a0: c0266660 40000000 40009000 c7bec420 `f&@...@...@ D>G
20088 +c7bec420: c0266660 40009000 4000b000 c7bec4a0 `f&@...@.0.@ D>G
20089 +c7bec4a0: c0266660 4000b000 40010000 c7bec8e0 `f&@.0.@...@`H>G
20090 +c7bec8e0: c0266660 40010000 400a1000 c7becbe0 `f&@...@...@`K>G
20091 +c7becbe0: c0266660 400a1000 400a8000 c7becc60 `f&@...@...@`L>G
20092 +c7becc60: c0266660 400a8000 400b4000 c7952300 `f&@...@.@.@.#.G
20093 +c7952300: c0266660 400b5000 400bc000 c79521c0 `f&@.P.@.@.@@!.G
20094 +c79521c0: c0266660 400bc000 400bd000 c7bec6e0 `f&@.@.@.P.@`F>G
20095 +c7bec6e0: c0266660 bffff000 c0000000 00000000 `f&@.p?...@....
20097 +kdb> ll c0262b60 12 vm
20098 +struct vm_area_struct at 0xc0262b60 for 56 bytes
20099 +vm_start = 0x8048000 vm_end = 0x804c000
20100 +page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
20101 +flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
20102 +struct vm_area_struct at 0xc7bec360 for 56 bytes
20103 +vm_start = 0x804c000 vm_end = 0x804d000
20104 +page_prot = 0x25 avl_height = -31808 vm_offset = 0x3000
20105 +flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
20106 +struct vm_area_struct at 0xc7becb20 for 56 bytes
20107 +vm_start = 0x804d000 vm_end = 0x8050000
20108 +page_prot = 0x25 avl_height = -28664 vm_offset = 0x0
20109 +flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC
20110 +struct vm_area_struct at 0xc7bec3a0 for 56 bytes
20111 +vm_start = 0x40000000 vm_end = 0x40009000
20112 +page_prot = 0x25 avl_height = 30126 vm_offset = 0x0
20113 +flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE
20114 +struct vm_area_struct at 0xc7bec420 for 56 bytes
20115 +vm_start = 0x40009000 vm_end = 0x4000b000
20116 +page_prot = 0x25 avl_height = 30126 vm_offset = 0x8000
20117 +flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE
20118 +struct vm_area_struct at 0xc7bec4a0 for 56 bytes
20119 +vm_start = 0x4000b000 vm_end = 0x40010000
20120 +page_prot = 0x25 avl_height = 26853 vm_offset = 0x0
20121 +flags: READ MAYREAD MAYWRITE MAYEXEC
20122 +struct vm_area_struct at 0xc7bec8e0 for 56 bytes
20123 +vm_start = 0x40010000 vm_end = 0x400a1000
20124 +page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
20125 +flags: READ EXEC MAYREAD MAYWRITE MAYEXEC
20126 +struct vm_area_struct at 0xc7becbe0 for 56 bytes
20127 +vm_start = 0x400a1000 vm_end = 0x400a8000
20128 +page_prot = 0x25 avl_height = 30126 vm_offset = 0x90000
20129 +flags: READ WRITE MAYREAD MAYWRITE MAYEXEC
20130 +struct vm_area_struct at 0xc7becc60 for 56 bytes
20131 +vm_start = 0x400a8000 vm_end = 0x400b4000
20132 +page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
20133 +flags: READ WRITE MAYREAD MAYWRITE MAYEXEC
20134 +struct vm_area_struct at 0xc7952300 for 56 bytes
20135 +vm_start = 0x400b5000 vm_end = 0x400bc000
20136 +page_prot = 0x25 avl_height = 30126 vm_offset = 0x0
20137 +flags: READ EXEC MAYREAD MAYWRITE MAYEXEC
20138 +struct vm_area_struct at 0xc79521c0 for 56 bytes
20139 +vm_start = 0x400bc000 vm_end = 0x400bd000
20140 +page_prot = 0x25 avl_height = -16344 vm_offset = 0x6000
20141 +flags: READ WRITE MAYREAD MAYWRITE MAYEXEC
20142 +struct vm_area_struct at 0xc7bec6e0 for 56 bytes
20143 +vm_start = 0xbffff000 vm_end = 0xc0000000
20144 +page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
20145 +flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC GROWSDOWN
20147 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_md.man linux-2.6.22-600/Documentation/kdb/kdb_md.man
20148 --- linux-2.6.22-590/Documentation/kdb/kdb_md.man 1970-01-01 01:00:00.000000000 +0100
20149 +++ linux-2.6.22-600/Documentation/kdb/kdb_md.man 2008-04-09 18:14:28.000000000 +0200
20151 +.TH MD 1 "August 4, 2004"
20153 +md, mdWcN, mdr, mds, mm, mmW\- Memory manipulation commands
20155 +md [ \fIaddress-expression\fP [ \fIline-count\fP [\fIoutput-radix\fP ] ] ]
20157 +md\fIW\fRc\fIn\fR [ \fIaddress-expression\fP [ \fIline-count\fP [\fIoutput-radix\fP ] ] ]
20159 +mdp \fIphysical-address-expression\fP,\fIbytes\fP
20161 +mdr \fIaddress-expression\fP,\fIbytes\fP
20163 +mds [ \fIaddress-expression\fP [ \fIline-count\fP [\fIoutput-radix\fP ] ] ]
20165 +mm \fIaddress-expression\fP \fInew-contents\fP
20167 +mm\fIW\fR \fIaddress-expression\fP \fInew-contents\fP
20171 +command is used to display the contents of memory.
20172 +The \fIaddress-expression\fP may be a numeric value (decimal or
20173 +hexidecimal), a symbol name, a register name preceeded by one or more
20174 +percent symbols '%', an environment variable name preceeded by
20175 +a currency symbol '$', or a simple expression consisting of a
20176 +symbol name, an addition or subtraction character and a numeric
20177 +value (decimal or hexidecimal).
20179 +If an address is specified and the \fIline-count\fP or \fIradix\fP arguments
20180 +are omitted, they default to the values of the \fBMDCOUNT\fP and \fBRADIX\fP
20181 +environment variables respectively. If the \fBMDCOUNT\fP or \fBRADIX\fP
20182 +environment variables are unset, the appropriate defaults will be used [see
20183 +\fBENVIRONMENT\fP below]. If no address is specified then md resumes
20184 +after the last address printed, using the previous values of count and
20185 +radix. The start address is rounded down to a multiple of the
20186 +BYTESPERWORD (md) or width (md\fIW\fR).
20188 +md uses the current value of environment variable \fBBYTESPERWORD\fP to
20189 +read the data. When reading hardware registers that require special
20190 +widths, it is more convenient to use md\fIW\fRc\fIn\fR where \fIW\fR is
20191 +the width for this command and \fRc\fIn\fR is the number of entries to
20192 +read. For example, md1c20 reads 20 bytes, 1 at a time. To continue
20193 +printing just type md, the width and count apply to following md
20194 +commands with no parameters. \fBNote:\fR The count is the number of
20195 +repeats of the width, unlike MDCOUNT which gives the number of md lines
20200 +command displays the contents of physical memory, starting at the
20201 +specified physical address for the specified number of bytes.
20202 +The address is preceded by 'phys'.
20206 +command displays the raw contents of memory, starting at the specified
20207 +address for the specified number of bytes.
20208 +The data is printed in one line without a leading address and no
20209 +trailing character conversion.
20211 +is intended for interfacing with external debuggers, it is of little
20216 +command displays the contents of memory one word per line and
20217 +attempts to correlate the contents of each word with a symbol
20218 +in the symbol table. If no symbol is found, the ascii representation
20219 +of the word is printed, otherwise the symbol name and offset from
20220 +symbol value are printed.
20221 +By default the section data is printed for kernel symbols.
20227 +commands allow modification of memory. The bytes at the address
20228 +represented by \fIaddress-expression\fP are changed to
20229 +\fInew-contents\fP. \fInew-contents\fP is allowed to be an
20230 +\fIaddress-expression\fP.
20232 +changes a machine word, \fBmm\fIW\fR changes \fIW\fR bytes at that
20239 +This environment variable (default=8) defines the number of lines
20240 +that will be displayed by each invocation of the \fBmd\fP command.
20244 +This environment variable (default=16) defines the radix used to
20245 +print the memory contents.
20249 +This environment variable (default=4) selects the width of output
20250 +data when printing memory contents. Select the value two to get
20251 +16-bit word output, select the value one to get byte output.
20255 +This environment variable governs the number of lines of output
20256 +that will be presented before the kernel debugger built-in pager
20257 +pauses the output. This variable only affects the functioning
20258 +of the \fBmd\fP and \fBmds\fP if the \fBMDCOUNT\fP variable
20259 +is set to a value greater than the \fBLINES\fP variable.
20263 +If the \fBNOSECT\fP environment variable is non-zero then the
20264 +section information is suppressed.
20265 +The default is NOSECT=1 so section data is suppressed; use set\ NOSECT=0
20266 +to see section information.
20267 +.SH SMP CONSIDERATIONS
20272 +Display memory starting at the address contained in register \fB%edx\fP.
20276 +Display stack contents symbolically. This command is quite useful
20277 +in manual stack traceback.
20280 +mm 0xc0252110 0x25
20281 +Change the memory location at 0xc0252110 to the value 0x25.
20284 +md chrdev_table 15
20285 +Display 15 lines (at 16 bytes per line) starting at address
20286 +represented by the symbol \fIchrdev_table\fP.
20287 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb.mm linux-2.6.22-600/Documentation/kdb/kdb.mm
20288 --- linux-2.6.22-590/Documentation/kdb/kdb.mm 1970-01-01 01:00:00.000000000 +0100
20289 +++ linux-2.6.22-600/Documentation/kdb/kdb.mm 2008-04-09 18:14:28.000000000 +0200
20291 +.TH KDB 8 "September 21, 2005"
20294 +Built-in Kernel Debugger for Linux - v4.4
20296 +This document describes the built-in kernel debugger available
20297 +for linux. This debugger allows the programmer to interactively
20298 +examine kernel memory, disassemble kernel functions, set breakpoints
20299 +in the kernel code and display and modify register contents.
20301 +A symbol table is included in the kernel image and in modules which
20302 +enables all non-stack symbols (including static symbols) to be used as
20303 +arguments to the kernel debugger commands.
20304 +.SH "Getting Started"
20305 +To include the kernel debugger in a linux kernel, use a
20306 +configuration mechanism (e.g. xconfig, menuconfig, et. al.)
20307 +to enable the \fBCONFIG_KDB\fP option. Additionally, for accurate
20308 +stack tracebacks, it is recommended that the \fBCONFIG_FRAME_POINTER\fP
20309 +option be enabled (if present). \fBCONFIG_FRAME_POINTER\fP changes the compiler
20310 +flags so that the frame pointer register will be used as a frame
20311 +pointer rather than a general purpose register.
20313 +After linux has been configured to include the kernel debugger,
20314 +make a new kernel with the new configuration file (a make clean
20315 +is recommended before making the kernel), and install the kernel
20318 +You can compile a kernel with kdb support but have kdb off by default,
20319 +select \fBCONFIG_KDB_OFF\fR. Then the user has to explicitly activate
20320 +kdb by booting with the 'kdb=on' flag or, after /proc is mounted, by
20322 + echo "1" > /proc/sys/kernel/kdb
20324 +You can also do the reverse, compile a kernel with kdb on and
20325 +deactivate kdb with the boot flag 'kdb=off' or, after /proc is mounted,
20328 + echo "0" > /proc/sys/kernel/kdb
20331 +When booting the new kernel, the 'kdb=early' flag
20332 +may be added after the image name on the boot line to
20333 +force the kernel to stop in the kernel debugger early in the
20334 +kernel initialization process. 'kdb=early' implies 'kdb=on'.
20335 +If the 'kdb=early' flag isn't provided, then kdb will automatically be
20336 +invoked upon system panic or when the \fBPAUSE\fP key is used from the
20337 +keyboard, assuming that kdb is on. Older versions of kdb used just a
20338 +boot flag of 'kdb' to activate kdb early, this is no longer supported.
20340 +KDB can also be used via the serial port. Set up the system to
20341 +have a serial console (see \fIDocumentation/serial-console.txt\fP), you
20342 +must also have a user space program such as agetty set up to read from
20343 +the serial console.
20344 +The control sequence \fB<esc>KDB\fP on the serial port will cause the
20345 +kernel debugger to be entered, assuming that kdb is on, that some
20346 +program is reading from the serial console, at least one cpu is
20347 +accepting interrupts and the serial console driver is still usable.
20349 +\fBNote:\fR\ When the serial console sequence consists of multiple
20350 +characters such as <esc>KDB then all but the last character are passed
20351 +through to the application that is reading from the serial console.
20352 +After exiting from kdb, you should use backspace to delete the rest of
20353 +the control sequence.
20355 +You can boot with kdb activated but without the ability to enter kdb
20356 +via any keyboard sequence.
20357 +In this mode, kdb will only be entered after a system failure.
20358 +Booting with kdb=on-nokey will activate kdb but ignore keyboard
20359 +sequences that would normally drop you into kdb.
20360 +kdb=on-nokey is mainly useful when you are using a PC keyboard and your
20361 +application needs to use the Pause key.
20362 +You can also activate this mode by
20364 + echo "2" > /proc/sys/kernel/kdb
20367 +If the console is sitting on the login prompt when you enter kdb, then
20368 +the login command may switch into upper case mode.
20369 +This is not a kdb bug, it is a "feature" of login - if the userid is
20370 +all upper case then login assumes that you using a TeleType (circa
20371 +1960) which does not have lower case characters.
20372 +Wait 60 seconds for login to timeout and it will switch back to lower
20375 +\fBNote:\fR\ Your distributor may have chosen a different kdb
20376 +activation sequence for the serial console.
20377 +Consult your distribution documentation.
20379 +If you have both a keyboard+video and a serial console, you can use
20381 +Define both video and serial consoles with boot parameters
20384 + console=tty0 console=ttyS0,38400
20387 +Any kdb data entered on the keyboard or the serial console will be echoed
20390 +If you are using a USB keyboard then kdb commands cannot be entered
20391 +until the kernel has initialised the USB subsystem and recognised the
20393 +Using kdb=early with a USB keyboard will not work, the USB subsystem is
20394 +initialised too late.
20396 +While kdb is active, the keyboard (not serial console) indicators may strobe.
20397 +The caps lock and scroll lock lights will turn on and off, num lock is not used
20398 +because it can confuse laptop keyboards where the numeric keypad is mapped over
20400 +On exit from kdb the keyboard indicators will probably be wrong, they will not match the kernel state.
20401 +Pressing caps lock twice should get the indicators back in sync with
20403 +.SH "Basic Commands"
20404 +There are several categories of commands available to the
20405 +kernel debugger user including commands providing memory
20406 +display and modification, register display and modification,
20407 +instruction disassemble, breakpoints and stack tracebacks.
20408 +Any command can be prefixed with '-' which will cause kdb to ignore any
20409 +errors on that command, this is useful when packaging commands using
20411 +A line whose first non-space character is '#' is printed and ignored.
20413 +The following table shows the currently implemented standard commands,
20414 +these are always available. Other commands can be added by extra
20415 +debugging modules, type '?' at the kdb prompt to get a list of all
20416 +available commands.
20422 +Command Description
20424 +bc Clear Breakpoint
20425 +bd Disable Breakpoint
20426 +be Enable Breakpoint
20427 +bl Display breakpoints
20428 +bp Set or Display breakpoint
20429 +bph Set or Display hardware breakpoint
20430 +bpa Set or Display breakpoint globally
20431 +bpha Set or Display hardware breakpoint globally
20432 +bt Stack backtrace for current process
20433 +btp Stack backtrace for specific process
20434 +bta Stack backtrace for all processes
20435 +btc Cycle over all live cpus and backtrace each one
20436 +cpu Display or switch cpus
20437 +dmesg Display system messages
20438 +defcmd Define a command as a set of other commands
20439 +ef Print exception frame
20440 +env Show environment
20441 +go Restart execution
20442 +handlers Control the display of IA64 MCA/INIT handlers
20443 +help Display help message
20444 +id Disassemble Instructions
20445 +kill Send a signal to a process
20446 +ll Follow Linked Lists
20447 +lsmod List loaded modules
20448 +md Display memory contents
20449 +mdWcN Display memory contents with width W and count N.
20450 +mdp Display memory based on a physical address
20451 +mdr Display raw memory contents
20452 +mds Display memory contents symbolically
20453 +mm Modify memory contents, words
20454 +mmW Modify memory contents, bytes
20455 +per_cpu Display per_cpu variables
20456 +pid Change the default process context
20457 +ps Display process status
20458 +reboot Reboot the machine
20459 +rd Display register contents
20460 +rm Modify register contents
20461 +rq Display runqueue for one cpu
20462 +rqa Display runqueue for all cpus
20463 +set Add/change environment variable
20464 +sr Invoke SysReq commands
20465 +ss Single step a cpu
20466 +ssb Single step a cpu until a branch instruction
20467 +stackdepth Print the stack depth for selected processes
20468 +summary Summarize the system
20472 +Some commands can be abbreviated, such commands are indicated by a
20473 +non-zero \fIminlen\fP parameter to \fBkdb_register\fP; the value of
20474 +\fIminlen\fP being the minimum length to which the command can be
20475 +abbreviated (for example, the \fBgo\fP command can be abbreviated
20476 +legally to \fBg\fP).
20478 +If an input string does not match a command in the command table,
20479 +it is treated as an address expression and the corresponding address
20480 +value and nearest symbol are shown.
20482 +Some of the commands are described here.
20483 +Information on the more complicated commands can be found in the
20484 +appropriate manual pages.
20487 +With no parameters, it lists the available cpus.
20488 +\&'*' after a cpu number indicates a cpu that did not respond to the kdb
20490 +\&'+' after a cpu number indicates a cpu for which kdb has some data, but
20491 +that cpu is no longer responding to kdb, so you cannot switch to it.
20492 +This could be a cpu that has failed after entering kdb, or the cpu may
20493 +have saved its state for debugging then entered the prom, this is
20494 +normal for an IA64 MCA event.
20495 +\&'I' after a cpu number means that the cpu was idle before it entered
20496 +kdb, it is unlikely to contain any useful data.
20497 +\&'F' after a cpu number means that the cpu is offline.
20498 +There is currenly no way to distinguish between cpus that used to be
20499 +online but are now offline and cpus that were never online, the kernel
20500 +does not maintain the information required to separate those two cases.
20502 +followed by a number will switch to that cpu, you cannot switch to
20503 +a cpu marked '*', '+' or 'F'.
20504 +This command is only available if the kernel was configured for SMP.
20506 +dmesg [lines] [adjust]
20507 +Displays the system messages from the kernel buffer.
20508 +If kdb logging is on, it is disabled by dmesg and is left as disabled.
20509 +With no parameters or a zero value for 'lines', dmesg dumps the entire
20511 +If lines is specified and is positive, dmesg dumps the last 'lines'
20513 +If lines is specified and is negative, dmesg dumps the first 'lines'
20515 +If adjust is specified, adjust the starting point for the lines that
20517 +When 'lines' is positive, move the starting point back by 'adjust'
20518 +lines, when 'lines' is negative, move the starting point forward by
20521 +will dump 100 lines, from the start of the buffer.
20523 +will dump 100 lines, starting 100 lines from the end of the buffer,
20525 +will dump 100 lines, starting 200 lines from the end of the buffer.
20527 +will dump 100 lines, starting 100 lines from the start of the buffer.
20530 +Defines a new command as a set of other commands, all input until
20532 +is saved and executed as a package.
20534 +takes three parameters, the command name to be defined and used to
20535 +invoke the package, a quoted string containing the usage text and a
20536 +quoted string containing the help text for the command.
20537 +When using defcmd, it is a good idea to prefix commands that might fail
20538 +with '-', this ignores errors so the following commands are still
20543 + defcmd diag "" "Standard diagnostics"
20555 +When used with no parameters, defcmd prints all the defined commands.
20558 +Continue normal execution.
20559 +Active breakpoints are reestablished and the processor(s) allowed to
20561 +To continue at a specific address, use
20563 +to change the instruction pointer then go.
20566 +Control the display of IA64 MCA/INIT handlers.
20567 +The IA64 MCA/INIT handlers run on separate tasks.
20568 +During an MCA/INIT event, the active tasks are typically the handlers,
20569 +rather than the original tasks, which is not very useful for debugging.
20570 +By default, KDB hides the MCA/INIT handlers so commands such as ps and
20571 +btc will display the original task.
20572 +You can change this behaviour by using
20574 +to display the MCA/INIT handlers instead of the original tasks or use
20576 +(the default) to hide the MCA/INIT handlers and display the original
20578 +.I handlers status
20579 +will list the address of the handler task and the original task for
20581 +\fBNote:\fR\ If the original task was running in user space or it
20582 +failed any of the MCA/INIT verification tests then there is no original
20584 +In this case, the handler will be displayed even if
20587 +.I handlers status
20588 +will not show an original task.
20591 +Disassemble instructions starting at an address.
20592 +Environment variable IDCOUNT controls how many lines of disassembly
20593 +output the command produces.
20596 +Internal command to send a signal (like kill(1)) to a process.
20600 +Internal command to list modules.
20601 +This does not use any kernel nor user space services so can be used at any time.
20603 +per_cpu <variable_name> [<length>] [<cpu>]
20604 +Display the values of a per_cpu variable, the variable_name is
20605 +specified without the \fIper_cpu__\fR prefix.
20606 +Length is the length of the variable, 1-8, if omitted or 0 it defaults
20607 +to the size of the machine's register.
20608 +To display the variable on a specific cpu, the third parameter is the
20610 +When the third parameter is omitted, the variable's value is printed
20611 +from all cpus, except that zero values are suppressed.
20612 +For each cpu, per_cpu prints the cpu number, the address of the
20613 +variable and its value.
20616 +Change the current process context, with no parameters it displays the
20618 +The current process is used to display registers, both kernel and user
20620 +It is also used when dumping user pages.
20622 +resets to the original process that was running when kdb was entered.
20623 +This command is useful if you have been looking at other processes and/or
20624 +cpus and you want to get back to the original process.
20625 +It does not switch cpus, it only resets the context to the original process.
20628 +Reboot the system, with no attempt to do a clean close down.
20631 +Display the runqueues for the specified cpu.
20634 +Display the runqueues for all cpus.
20636 +stackdepth <percentage>
20637 +Print the stack usage for processes using more than the specified
20638 +percentage of their stack.
20639 +If percentage is not supplied, it defaults to 60.
20640 +This command is only implemented on i386 and ia64 architectures,
20641 +patches for other architectures will be gratefully accepted.
20644 +Print a summary of the system, including the time (no timezone is
20645 +applied), uname information and various critical system counters.
20646 +.SH INITIAL KDB COMMANDS
20647 +kdb/kdb_cmds is a plain text file where you can define kdb commands
20648 +which are to be issued during kdb_init(). One command per line, blank
20649 +lines are ignored, lines starting with '#' are ignored. kdb_cmds is
20650 +intended for per user customization of kdb, you can use it to set
20651 +environment variables to suit your hardware or to set standard
20652 +breakpoints for the problem you are debugging. This file is converted
20653 +to a small C object, compiled and linked into the kernel. You must
20654 +rebuild and reinstall the kernel after changing kdb_cmds. This file
20655 +will never be shipped with any useful data so you can always override
20656 +it with your local copy. Sample kdb_cmds:
20659 +# Initial commands for kdb, alter to suit your needs.
20660 +# These commands are executed in kdb_init() context, no SMP, no
20661 +# processes. Commands that require process data (including stack or
20662 +# registers) are not reliable this early. set and bp commands should
20663 +# be safe. Global breakpoint commands affect each cpu as it is booted.
20668 +bp sys_init_module
20670 +.SH INTERRUPTS AND KDB
20671 +When a kdb event occurs, one cpu (the initial cpu) enters kdb state.
20672 +It uses a cross system interrupt to interrupt the
20673 +other cpus and bring them all into kdb state. All cpus run with
20674 +interrupts disabled while they are inside kdb, this prevents most
20675 +external events from disturbing the kernel while kdb is running.
20677 +Disabled interrupts means that any I/O that relies on interrupts cannot
20678 +proceed while kdb is in control, devices can time out. The clock tick
20679 +is also disabled, machines will lose track of time while they are
20682 +Even with interrupts disabled, some non-maskable interrupt events will
20683 +still occur, these can disturb the kernel while you are debugging it.
20684 +The initial cpu will still accept NMI events, assuming that kdb was not
20685 +entered for an NMI event. Any cpu where you use the SS or SSB commands
20686 +will accept NMI events, even after the instruction has finished and the
20687 +cpu is back in kdb. This is an unavoidable side effect of the fact that
20688 +doing SS[B] requires the cpu to drop all the way out of kdb, including
20689 +exiting from the event that brought the cpu into kdb. Under normal
20690 +circumstances the only NMI event is for the NMI oopser and that is kdb
20691 +aware so it does not disturb the kernel while kdb is running.
20693 +Sometimes doing SS or SSB on ix86 will allow one interrupt to proceed,
20694 +even though the cpu is disabled for interrupts. I have not been able
20695 +to track this one down but I suspect that the interrupt was pending
20696 +when kdb was entered and it runs when kdb exits through IRET even
20697 +though the popped flags are marked as cli(). If any ix86 hardware
20698 +expert can shed some light on this problem, please notify the kdb
20700 +.SH RECOVERING FROM KDB ERRORS
20701 +If a kdb command breaks and kdb has enough of a recovery environment
20702 +then kdb will abort the command and drop back into mainline kdb code.
20703 +This means that user written kdb commands can follow bad pointers
20704 +without killing kdb. Ideally all code should verify that data areas
20705 +are valid (using kdb_getarea) before accessing it but lots of calls to
20706 +kdb_getarea can be clumsy.
20708 +The sparc64 port does not currently provide this error recovery.
20709 +If someone would volunteer to write the necessary longjmp/setjmp
20710 +code, their efforts would be greatly appreciated. In the
20711 +meantime, it is possible for kdb to trigger a panic by accessing
20713 +.SH DEBUGGING THE DEBUGGER
20714 +kdb has limited support for debugging problems within kdb. If you
20715 +suspect that kdb is failing, you can set environment variable KDBDEBUG
20716 +to a bit pattern which will activate kdb_printf statements within kdb.
20717 +See include/linux/kdb.h, KDB_DEBUG_FLAG_xxx defines. For example
20719 + set KDBDEBUG=0x60
20721 +activates the event callbacks into kdb plus state tracing in sections
20724 + set KDBDEBUG=0x18
20726 +gives lots of tracing as kdb tries to decode the process stack.
20728 +You can also perform one level of recursion in kdb. If environment
20729 +variable RECURSE is not set or is 0 then kdb will either recover from
20730 +an error (if the recovery environment is satisfactory) or kdb will
20731 +allow the error to percolate, usually resulting in a dead system. When
20732 +RECURSE is 1 then kdb will recover from an error or, if there is no
20733 +satisfactory recovery environment, it will drop into kdb state to let
20734 +you diagnose the problem. When RECURSE is 2 then all errors drop into
20735 +kdb state, kdb does not attempt recovery first. Errors while in
20736 +recursive state all drop through, kdb does not even attempt to recover
20737 +from recursive errors.
20738 +.SH KEYBOARD EDITING
20739 +kdb supports a command history, which can be accessed via keyboard
20741 +It supports the special keys on PC keyboards, control characters and
20742 +vt100 sequences on a serial console or a PC keyboard.
20749 +PC Special keys Control VT100 key Codes Action
20751 +Backspace ctrl-H Backspace 0x7f Delete character to the left of the cursor
20752 +Delete ctrl-D Delete \\e[3~ Delete character to the right of the cursor
20753 +Home ctrl-A Home \\e[1~ Go to start of line
20754 +End ctrl-E End \\e[4~ Go to end of line
20755 +Up arrow ctrl-P Up arrow \\e[A Up one command in history
20756 +Down arrow ctrl-N Down arrow \\e[B Down one command in history
20757 +Left arrow ctrl-B Left arrow \\e[D Left one character in current command
20758 +Right arrow ctrl-F Right arrow \\e[C Right one character in current command
20762 +There is no toggle for insert/replace mode, kdb editing is always in
20764 +Use delete and backspace to delete characters.
20766 +kdb also supports tab completion for kernel symbols
20767 +Type the start of a kernel symbol and press tab (ctrl-I) to complete
20769 +If there is more than one possible match, kdb will append any common
20770 +characters and wait for more input, pressing tab a second time will
20771 +display the possible matches
20772 +The number of matches is limited by environment variable DTABCOUNT,
20773 +with a default of 30 if that variable is not set.
20775 +Scott Lurndal, Richard Bass, Scott Foehner, Srinivasa Thirumalachar,
20776 +Masahiro Adegawa, Marc Esipovich, Ted Kline, Steve Lord, Andi Kleen,
20779 +Keith Owens <kaos@sgi.com> - kdb maintainer.
20782 +linux/Documentation/kdb/kdb_{bp,bt,env,ll,md,ps,rd,sr,ss}.man
20783 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_ps.man linux-2.6.22-600/Documentation/kdb/kdb_ps.man
20784 --- linux-2.6.22-590/Documentation/kdb/kdb_ps.man 1970-01-01 01:00:00.000000000 +0100
20785 +++ linux-2.6.22-600/Documentation/kdb/kdb_ps.man 2008-04-09 18:14:28.000000000 +0200
20787 +.TH PS 1 "September 14, 2004"
20789 +ps \- Display processes
20791 +ps [ DRSTCZEUIMA ]
20795 +command displays the status of all processes in the desired state.
20796 +This command does not take any locks (all cpus should be frozen while
20797 +kdb is running) so it can safely be used to debug lock problems with
20798 +the process table.
20800 +Without any parameters, \fBps\fP displays all the interesting
20801 +processes, excluding idle tasks and sleeping system daemons.
20802 +If a parameter is specified, it is a single string consisting of the
20803 +letters D, R, S, T, C, Z, E, U, I and M, in any order.
20804 +Each letter selects processes in a specific state, when multiple
20805 +letters are specified, a process will be displayed if it is in any of
20806 +the specified states.
20807 +The states are\ :-
20814 +D Uninterruptible sleep
20816 +S Interruptible sleep
20823 +M Sleeping system daemon
20828 +For state R (running), the process may not be on a cpu at the moment,
20829 +but it is ready to run.
20830 +The header line above the backtrace contains '1' in the fourth field if
20831 +the process is actually on a cpu.
20833 +The idle task is run on each cpu when there is no work for that cpu to do.
20834 +Unless the idle task is servicing an interrupt, there is no point in
20835 +printing the idle task.
20836 +An idle task that is not servicing a interrupt is marked as state I,
20837 +while servicing an interrupt it is in state R.
20838 +By default, idle tasks are not printed, use \fBps\ I\fR to print them.
20839 +If the idle tasks are not being printed, the start of the \fBps\R
20840 +output contains a list of which cpus are idle.
20842 +Each cpu has one or more system daemons to handle per cpu work such as
20844 +A system daemon (idenified by a NULL mm pointer) that is sleeping is
20845 +marked as state M.
20846 +These processes rarely have any useful data and generate a lot of
20847 +output on large machines, so sleeping system daemons are not printed by
20849 +Use \fBps\ M\fR to print them.
20851 +At the start of the \fBps\fR output is a line giving the cpu status,
20852 +see the kdb \fBcpu\fR command.
20858 +This environment variable (default=DRSTCZEU) is used when \fBps\fR
20859 +is issued with no parameters.
20861 +.SH SMP CONSIDERATIONS
20866 +displays the useful tasks, suppressing idle tasks and sleeping
20871 +displays only tasks that are running or are in an uninterruptible
20875 +\fBps\ DRSTCZEUIM\fR
20876 +displays all tasks.
20880 +displays all tasks.
20881 +This is easier than remembering DRSTCZEUIM.
20883 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_rd.man linux-2.6.22-600/Documentation/kdb/kdb_rd.man
20884 --- linux-2.6.22-590/Documentation/kdb/kdb_rd.man 1970-01-01 01:00:00.000000000 +0100
20885 +++ linux-2.6.22-600/Documentation/kdb/kdb_rd.man 2008-04-09 18:14:28.000000000 +0200
20887 +.TH RD 1 "September 20, 2005"
20889 +rd, rm\- Register manipulation commands
20893 +rm \fIregister-name\fP \fInew-contents\fP
20899 +command is used to display the contents of processor and coprocessor registers.
20900 +Without any arguments, the rd command displays the contents of the general
20901 +register set at the point at which the kernel debugger was entered.
20902 +If the bt* or pid commands have been used to change the current process then
20906 +may not be able to display any registers.
20907 +'n' argument is only used for XScale platform to identify the desired
20908 +coprocessor number, while 'd' option is not valid for XScale platform.
20910 +On IA32 and IA64, with the 'c' argument, the processor control registers
20911 +%cr0, %cr1, %cr2 and %cr4 are displayed, while with the 'd' argument
20912 +the processor debug registers are displayed. If the 'u' argument
20913 +is supplied, the registers for the current task as of the last
20914 +time the current task entered the kernel are displayed.
20916 +On XScale, 'c' argument is used to display the
20917 +all coprocessor control registers or specified coprocessor registers by
20918 +argumnet 'n'. Argument 'u' is used to display the
20919 +registers for the current task as of the last time the current task
20920 +entered the kernel. Argument 'd' is not supported.
20924 +command allows modification of a register. The following
20925 +register names are valid: \fB%eax\fP, \fB%ebx\fP, \fB%ecx\fP,
20926 +\fB%edx\fP, \fB%esi\fP, \fB%edi\fP, \fB%esp\fP, \fB%eip\fP,
20927 +and \fB%ebp\fP. Note that if two '%' symbols are used
20928 +consecutively, the register set displayed by the 'u' argument
20929 +to the \fBrd\fP command is modified.
20931 +The debug registers, \fBdr0\fP through \fBdr3\fP and both
20932 +\fBdr6\fP and \fBdr7\fP can also be modified with the \fBrm\fP
20935 +On sparc64, the valid registers are named \fB%g0\fP through
20936 +\fB%g7\fP, \fB%l0\fP through \fB%l7\fP, \fB%o0\fP through
20937 +\fB%o7\fP, and \fB%i0\fP through \fB%i7\fP, with the exceptions
20938 +that \fB%o6\fP is called \fB%sp\fP and that \fB%i6\fP is called
20939 +\fB%fp\fP. The registers \fB%tstate\fP, \fB%tpc\fP, \fB%tnpc\fP,
20940 +\fB%y\fP, and \fB%fprs\fP provide state information at the time
20941 +the system entered kdb. Additionally, when viewing registers, two
20942 +convenience names are provided: \fB%®s\fP shows the
20943 +address on the stack of the current registers, and \fB%csp\fP
20944 +shows the current stack pointer within kdb itself.
20946 +While on XScale, both the cpu registers and most coprocessor
20947 +registers can be be modified. \fIregister-name\fP can be followings like
20948 +r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14,
20949 +r15, cpsr to address cpu registers. For the coprocessor registers in XSacle,
20950 +either alias name or \fICpcc[CRndd[CRmbb[Opaa]]]\fP can be used to address
20951 +the register in coprocessor cc with CRn=dd, CRm=bb and opcode2=aa. All aa, bb, cc, dd can be
20952 +1 or 2 decimal digitals, the default value is 0 when any of them is omitted. Name
20953 +acc0_h and acc0_l are used to identify the high byte and
20954 +low word of accumulator in coprocessor 0.
20956 +On IA64, the parameter to
20958 +can be d (debug registers), u (user registers at most recent entry to kernel),
20959 +i (interrupt registers), %isr (current interrupt status), s (stacked
20960 +registers), k (kernel registers). You can also specify these individual
21005 +can change any of the individual registers or the stacked registers.
21009 +command displays an exception frame at the specified address.
21011 +Currently the \fBrm\fP command will not allow modification of the
21012 +control registers.
21014 +Currently neither the \fBrd\fP command nor the \fBrm\fP command will
21015 +display or modify the model specific registers on the Pentium
21016 +and Pentium Pro families.
21019 +.SH SMP CONSIDERATIONS
21024 +Display general register set from kdb's current task.
21028 +Display coprocessor 0 registers.
21032 +Set the contents of \fB%eax\fP to zero. This will be the
21033 +value of %eax when kdb returns from the condition which
21038 +Set the value of the \fB%eax\fP register to zero. This will
21039 +be the value the user-mode application will see upon returning
21044 +Set the contents of high byte of accumulator to zero.
21048 +Set the value of the \fBdr0\fB register to \f(CW0xc1287220\fP.
21052 +Write 0 to coprocessor 15 register with CRn=7, CRm=5, opcode2=6.
21055 +rm %CP15CRn7CRm5Op6 0
21057 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_sr.man linux-2.6.22-600/Documentation/kdb/kdb_sr.man
21058 --- linux-2.6.22-590/Documentation/kdb/kdb_sr.man 1970-01-01 01:00:00.000000000 +0100
21059 +++ linux-2.6.22-600/Documentation/kdb/kdb_sr.man 2008-04-09 18:14:28.000000000 +0200
21061 +.TH SR 1 "7 October 2002"
21063 +sr \- invoke sysrq commands from kdb
21070 +command invokes the existing sysrq handler code in the kernel.
21071 +This command takes a single character which is passed to sysrq
21072 +processing, as if you had entered the sysrq key sequence followed by
21077 +kdb will always call the sysrq code but sysrq may be disabled.
21078 +If you expect to use sysrq functions during debugging then
21080 +echo "1" > /proc/sys/kernel/sysrq
21082 +before starting the debug session.
21083 +Alternatively issue
21085 +mm4 sysrq_enabled 1
21089 +The sysrq code prints a heading using console loglevel 7 then reverts
21090 +to the original loglevel for the rest of the sysrq processing.
21091 +If the rest of the sysrq output is printed at a level below your
21092 +current loglevel then you will not see the output on the kdb console,
21093 +the output will only appear in the printk buffer.
21094 +It is the user's responsibility to set the loglevel correctly if they
21095 +want to see the sysrq output on the console.
21102 +commands if you want to see the output on the console.
21103 +You may even have to adjust the default message loglevel in order to
21104 +see any output from
21106 +See Documentation/sysctl/kernel.txt for details on setting console
21107 +loglevels via /proc.
21108 +You can also adjust the loglevel variables via kdb
21110 +on older kernels there are variables such as default_message_level, on
21111 +newer kernels all the loglevel variables are in array console_printk,
21112 +see kernel/printk.c for your kernel.
21114 +Operations that require interrupt driven I/O can be invoked from kdb
21116 +but they will not do anything until you type 'go' to exit from kdb
21117 +(interrupts are disabled while in kdb).
21118 +There is no guarantee that these operations will work, if the machine
21119 +entered kdb because of an error then interrupt driven I/O may already
21121 +Do not assume that
21123 +does anything useful.
21125 +The sysrq handler uses locks and calls printk which also uses locks.
21126 +If the sysrq handler or any of the sysrq functions have to wait for a
21127 +lock then they will never return and kdb will appear to hang.
21128 +Invoking sysrq code from kdb is inherently unsafe.
21129 diff -Nurp linux-2.6.22-590/Documentation/kdb/kdb_ss.man linux-2.6.22-600/Documentation/kdb/kdb_ss.man
21130 --- linux-2.6.22-590/Documentation/kdb/kdb_ss.man 1970-01-01 01:00:00.000000000 +0100
21131 +++ linux-2.6.22-600/Documentation/kdb/kdb_ss.man 2008-04-09 18:14:28.000000000 +0200
21133 +.TH SS 1 "17 January 2002"
21135 +ss, ssb \- Single Step
21143 +command is used to execute a single instruction and return
21144 +to the kernel debugger.
21146 +Both the instruction that was single-stepped and the next
21147 +instruction to execute are printed.
21149 +The \fBssb\fP command will execute instructions from the
21150 +current value of the instruction pointer. Each instruction
21151 +may be printed as it is executed, depending upon architecture;
21152 +execution will stop at any instruction which would cause the flow
21153 +of control to change (e.g. branch, call, interrupt instruction,
21156 +On sparc64, there are some circumstances where single-stepping
21157 +can be dangerous. Do not single-step across an instruction which
21158 +changes the interrupt-enable bit in %tstate. Do not single step
21159 +through code which is invoked when entering or leaving the
21160 +kernel, particularly any kernel entry code before %tl is set to
21161 +0, or any kernel exit code after %tl is set to 1.
21164 +.SH SMP CONSIDERATIONS
21165 +Other processors are held in the kernel debugger when the instruction
21166 +is traced. Single stepping though code that requires a lock which is
21167 +in use by another processor is an exercise in futility, it will never
21169 +.SH INTERRUPT CONSIDERATIONS
21170 +When a kdb event occurs, one cpu (the initial cpu) enters kdb state.
21171 +It uses a cross system interrupt to interrupt the
21172 +other cpus and bring them all into kdb state. All cpus run with
21173 +interrupts disabled while they are inside kdb, this prevents most
21174 +external events from disturbing the kernel while kdb is running.
21176 +Disabled interrupts means that any I/O that relies on interrupts cannot
21177 +proceed while kdb is in control, devices can time out. The clock tick
21178 +is also disabled, machines will lose track of time while they are
21181 +Even with interrupts disabled, some non-maskable interrupt events
21182 +will still occur, these can disturb the kernel while you are
21183 +debugging it. The initial cpu will still accept NMI events,
21184 +assuming that kdb was not entered for an NMI event. Any cpu
21185 +where you use the SS or SSB commands will accept NMI events, even
21186 +after the instruction has finished and the cpu is back in kdb.
21187 +This is an unavoidable side effect of the fact that doing SS[B]
21188 +requires the cpu to drop all the way out of kdb, including
21189 +exiting from the NMI event that brought the cpu into kdb. Under
21190 +normal circumstances the only NMI event is for the NMI oopser and
21191 +that is kdb aware so it does not disturb the kernel while kdb is
21194 +Sometimes doing SS or SSB on ix86 will allow one interrupt to proceed,
21195 +even though the cpu is disabled for interrupts. I have not been able
21196 +to track this one down but I suspect that the interrupt was pending
21197 +when kdb was entered and it runs when kdb exits through IRET even
21198 +though the popped flags are marked as cli(). If any ix86 hardware
21199 +expert can shed some light on this problem, please notify the kdb
21205 +kdb> bp gendisk_head datar 4
21206 +Data Access Breakpoint #0 at 0xc024ddf4 (gendisk_head) in dr0 is enabled on cpu 0
21210 +[root@host /root]# cat /proc/partitions
21211 +Entering kdb on processor 0 due to Debug Exception @ 0xc01845e3
21212 +Read/Write breakpoint #0 at 0xc024ddf4
21214 +sd_finish+0x7b: movzbl 0xc02565d4,%edx
21215 +sd_finish+0x82: leal 0xf(%edx),%eax
21216 +sd_finish+0x85: sarl $0x4,%eax
21217 +sd_finish+0x88: movl 0xc0256654,%ecx
21218 +sd_finish+0x8e: leal (%eax,%eax,4),%edx
21219 +sd_finish+0x91: leal (%eax,%edx,2),%edx
21220 +sd_finish+0x94: movl 0xc0251108,%eax
21221 +sd_finish+0x99: movl %eax,0xffffffc(%ecx,%edx,4)
21222 +sd_finish+0x9d: movl %ecx,0xc0251108
21223 +sd_finish+0xa3: xorl %ebx,%ebx
21224 +sd_finish+0xa5: cmpb $0x0,0xc02565d4
21226 +[root@host /root]#
21229 +sys_read: pushl %ebp
21230 +SS trap at 0xc01274c1
21231 +sys_read+0x1: movl %esp,%ebp
21233 +sys_read+0x1: movl %esp,%ebp
21234 +SS trap at 0xc01274c3
21235 +sys_read+0x3: subl $0xc,%esp
21237 +sys_read+0x3: subl $0xc,%esp
21238 +SS trap at 0xc01274c6
21239 +sys_read+0x6: pushl %edi
21242 diff -Nurp linux-2.6.22-590/Documentation/kdb/slides linux-2.6.22-600/Documentation/kdb/slides
21243 --- linux-2.6.22-590/Documentation/kdb/slides 1970-01-01 01:00:00.000000000 +0100
21244 +++ linux-2.6.22-600/Documentation/kdb/slides 2008-04-09 18:14:28.000000000 +0200
21246 +#! /opt/cpg/bin/do-mgp
21247 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21249 +%deffont "standard" tfont "comic.ttf"
21250 +%deffont "thick" tfont "arialb.ttf"
21251 +%deffont "typewriter" xfont "courier new-bold-r"
21252 +%deffont "type2writer" xfont "arial narrow-bold-r"
21254 +%% Default settings per each line numbers.
21256 +#%default 1 leftfill, size 2, fore "black", back "LemonChiffon2", font "thick"
21257 +%default 1 leftfill, size 2, fore "black", back "white", font "thick"
21258 +%default 2 size 10, vgap 10, prefix " ", center
21259 +%default 3 size 2, bar "gray70", vgap 10
21260 +%default 4 size 6, fore "black", vgap 30, prefix " ", font "standard", left
21262 +%% Default settings that are applied to TAB-indented lines.
21264 +%tab 1 size 4, vgap 35, prefix " ", icon arc "red" 40
21265 +%tab 2 size 4, vgap 20, prefix " ", icon delta3 "blue" 40
21266 +%tab 3 size 4, vgap 20, prefix " ", icon delta3 "green" 40
21269 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21272 +KDB - Kernel Debugger
21276 +%size 7,center, font "thick"
21286 +February 5, 2002 IBM Linux Technology Center Paul Dorwin
21287 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21293 + IBM Legal requires this information:
21297 + THE INFORMATION IN THE FOLLOWING PRESENTATION IS PREPARED
21298 + SOLELY FOR THE INFORMATION OF THE READER, AND COMES "AS IS"
21299 + AND WITHOUT WARRANTY OR REPRESENATION OF ANY KIND.
21301 + ANY PARTY USING THE MATERIALS IN THIS PRESENTATION DOES SO
21302 + AT ITS OWN RISK LIABILITY AND THE PROVIDER OF THE MATERIALS
21303 + ACCEPTS NO RISK OR LIABILITY FOR SUCH USE OR RESULTING FROM
21304 + DISSEMINATION TO OR USE BY ANY OTHER PARTY
21306 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21313 + Installing and Configuring KDB
21319 + Setting Breakpoints
21321 + Displaying Data Structures
21323 + Kernel Data structures
21325 + Take a walk through an IO operation
21326 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21329 +Installing Configuring KDB
21332 + Install KDB patch.
21333 + Start with a clean source tree
21334 + Apply architecture specific patches
21335 + Obtain patch for your kernel version
21336 + see http://oss.sgi.com/projects/kdb/
21337 + Apply the kdb patch
21338 + patch -p 1 -N -u -i /path/to/patch
21339 + Apply any other patches
21340 + Build and reboot on your kdb enabled kernel
21341 + Man pages can be found at Documentation/kdb
21343 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21349 + Config kernel with the following options:
21350 + These are documented in Documentation/Configure.help
21353 + Enable compilation of KDB in the kernel..
21354 + Setting this also sets CONFIG_KALLSYMS=y.
21355 + CONFIG_KDB_MODULES=n
21356 + KDB may be extended, compiling kdb/modules.
21358 + y = KDB is disabled by default.
21359 + boot with kdb=on to enable at boot.
21360 + /proc/sys/kernel/kdb to enable/disable when system is up.
21361 + CONFIG_KALLSYMS=y
21362 + This causes all symbols to be exported.
21363 + CONFIG_FRAME_POINTER=y
21364 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21370 + KDB can be invoked in the following ways:
21372 + Early init with "kdb=early" lilo flag
21373 + Hits breakpoint prior to fork_init() (init/main.c)
21375 + Serial console with CNTRL-A
21377 + Console with PAUSE key
21379 + When a pre-set breakpoint is hit
21383 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21390 + env Show environment variables
21391 + set Set environment variables
21392 + help Display Help Message
21393 + ? Display Help Message
21396 + sections List kernel and module sections
21397 + lsmod List loaded kernel modules
21398 + reboot Reboot the machine immediately
21399 + cpu <cpunum> Switch to new cpu
21401 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21407 + Memory Manipulation
21408 + md <vaddr> Display Memory Contents
21409 + mdr <vaddr> <bytes> Display Raw Memory
21410 + mds <vaddr> Display Symbolically
21411 + mm <vaddr> <value> Modify Memory Contents
21412 + id <vaddr> Display Instructions
21414 + Register Manipulation
21415 + rd Display Registers
21416 + rm <reg> <value> Modify Registers
21417 + ef <vaddr> Display exception frame
21420 + bt [<vaddr>] Stack traceback
21421 + btp <pid> Display stack for <pid>
21422 + bta Display all stacks
21424 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21431 + bc <bpnum> Clear Breakpoint
21432 + bd <bpnum> Disable Breakpoint
21433 + be <bpnum> Enable Breakpoint
21434 + bl [<vaddr>] Display breakpoints
21435 + bp [<vaddr>] Set/Display breakpoints
21436 + bpa [<vaddr>] Set/Display global breakpoints
21437 + bph [<vaddr>] Set hardware breakpoint
21438 + bpha [<vaddr>] Set global hardware breakpoint
21440 + instruction - break on instruction fetch (default)
21441 + datar - break on read at vaddr
21442 + dataw - break on write at vaddr
21443 + IO - break on in or out op at vaddress
21445 + Execution control
21446 + go [<vaddr>] Continue Execution
21447 + ss [<#steps>] Single Step
21448 + ssb Single step to branch/call
21449 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21455 + Kernel structures
21456 + ll <vaddr> <offset> <command> Traverse list and execute command
21457 + ps Display active task list
21458 + vm <vaddr> Display vm_area_struct
21459 + dentry <dentry> Display interesting dentry stuff
21460 + filp <filp> Display interesting filp stuff
21461 + sh <vaddr> Show scsi_host
21462 + sd <vaddr> Show scsi_device
21463 + sc <vaddr> Show scsi_cmnd
21464 + kiobuf <vaddr> Display kiobuf
21465 + page <vaddr> Display page
21466 + inode <vaddr> Display inode
21467 + bh <vaddr> Display buffer head
21468 + inode_pages <inode *> Display pages in an inode
21469 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21476 + Find and display the data associated with a scull device
21478 + The sequence of events
21479 + Populate the scull device with data
21480 + Identify the breakpoints
21481 + Set breakpoint in the device read function
21482 + Identify the data structure elements
21483 + Identify device structures used to track data
21484 + Display data structures containing the data
21485 + Show the usage of the filp command
21487 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21490 +Scull Demo: Populate Device
21494 + Surf to http://examples.oreilly.com/linuxdrive2/
21495 + Download the tarball
21496 + Untar it to /usr/src
21498 + Build and install the module
21499 + cd /usr/src/ldd2-samples-1.0.1/scull
21501 + ./scull.init start
21503 + Populate the scull device
21504 + cat main.c > /dev/scull0
21506 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21509 +Scull Demo: Driver Details
21514 +%fore "blue", cont
21516 +%fore "black", cont
21517 +("/dev/scull0", O_RDONLY);
21518 + Kernel finds the file_operations structure
21519 + Kernel then invokes the open function
21522 +%fore "black", cont
21524 + Kernel finds the file_operations structure
21525 + Kernel then invokes the read function
21527 + Scull device file operations structure
21529 +%font "typewriter", size 3
21530 + struct file_operations scull_fops = {
21531 + llseek: scull_llseek,
21533 + read: scull_read,
21535 + write: scull_write,
21536 + ioctl: scull_ioctl,
21538 + open: scull_open,
21540 + release: scull_release,
21542 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21545 +Scull Demo: Driver Details
21547 +%font "typewriter", size 3
21549 +%font "typewriter", size 3
21551 +%fore "blue", cont
21553 +%fore "black", cont
21554 +(struct inode *inode, struct file *filp)
21556 + Scull_Dev *dev; /* device information */
21557 + int num = NUM(inode->i_rdev);
21561 + dev = (Scull_Dev *)filp->private_data;
21563 + if (num >= scull_nr_devs) return -ENODEV;
21565 + dev = &scull_devices[num];
21566 + filp->private_data = dev;
21573 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21576 +Scull Demo: Driver Details
21578 +%font "typewriter", size 3
21580 +%font "typewriter", size 3
21582 +%fore "blue", cont
21584 +%fore "black", cont
21585 +(struct file *filp, char *buf, size_t count,
21589 +%fore "blue", cont
21590 + Scull_Dev *dev = filp->private_data;
21591 +%fore "black", cont
21592 + /* the first listitem */
21596 + int quantum = dev->quantum;
21597 + int qset = dev->qset;
21598 + int itemsize = quantum * qset;
21599 + if (down_interruptible(&dev->sem))
21600 + return -ERESTARTSYS;
21601 + if (*f_pos + count > dev->size)
21602 + count = dev->size - *f_pos;
21604 + /* find listitem, qset index, and offset in the quantum */
21605 + item = (long)*f_pos / itemsize;
21606 + rest = (long)*f_pos % itemsize;
21607 + s_pos = rest / quantum; q_pos = rest % quantum;
21609 + /* follow the list up to the right position */
21611 + dptr = scull_follow(dev, item);
21617 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21620 +Scull Demo: Breakpoints
21623 +%font "typewriter", size 3
21624 + Determine where to set breakpoint
21625 +%font "typewriter", size 3
21627 + dptr = scull_follow(dev, item);
21630 +%font "typewriter", size 3
21631 + Disassemble scull_read
21632 +%font "typewriter", size 3
21634 +%fore "blue", cont
21637 + 0xf8c083b4 scull_read: push %ebp
21638 + 0xf8c083b5 scull_read+0x1:mov %esp,%ebp
21639 + 0xf8c083b7 scull_read+0x3:push %edi
21641 + 0xf8c08465 scull_read+0xb1:sub $0x8,%esp
21643 + 0xf8c08468 scull_read+0xb4:push %ecx
21644 + 0xf8c08469 scull_read+0xb5:push %esi
21645 + 0xf8c0846a scull_read+0xb6:call 0xf8c08364 scull_follow:
21647 + 0xf8c0846f scull_read+0xbb:mov %eax,
21648 +%fore "blue", cont
21652 +%fore "blue", cont
21654 +%fore "black", cont
21658 + Set breakpoint in driver read
21659 +%font "typewriter", size 3
21662 +bp scull_read+0xbd
21664 + Instruction(i) BP #0 at 0xf8c08471 ([scull]scull_read+0xbd)
21665 + is enabled globally adjust 1
21666 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21669 +Scull Demo: Breakpoints
21672 +%font "typewriter", size 3
21673 + Restart the system
21674 +%font "typewriter", size 3
21676 +%fore "blue", cont
21680 + Hit the Breakpoint
21681 +%font "typewriter", size 3
21682 + [root@elm3b77 root]#
21683 +%fore "blue", cont
21686 + Instruction(i) breakpoint #0 at 0xf8c08471 (adjusted)
21687 + 0xf8c08471 scull_read+0xbd:int3
21688 + Entering kdb (current=0xf73ec000, pid 1249) on processor 2
21689 + due to Breakpoint @ 0xf8c08471
21691 + Display the registers
21692 +%font "typewriter", size 3
21694 +%fore "blue", cont
21697 + eax = 0xf77d7b60 ebx = 0x00000000 ecx = 0x00000000 edx =
21698 +%fore "blue", cont
21702 +%fore "blue", cont
21704 +%fore "black", cont
21705 + edi = 0x00001000 esp = 0xf7415f40 eip = 0xf8c08471
21706 + ebp = 0xf7415f78 xss = 0x00000018 xcs = 0x00000010 eflags = 0x00000246
21707 + xds = 0xf7590018 xes = 0x00000018 origeax = 0xffffffff ®s = 0xf7415f0c
21708 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21711 +Scull Demo: Data Structures
21713 +%font "typewriter", size 3
21714 + Display the Scull_Dev structure
21715 +%font "typewriter", size 3
21717 +%fore "blue", cont
21721 +%fore "blue", cont
21723 +%fore "black", cont
21724 + 00000000 00000fa0 000003e8 ..@w.... ...h...
21725 + 0xf77d7b70 0000534e 00000000 00000000 00000000 NS..............
21727 + Scull Device Structure
21728 +%font "typewriter", size 3
21729 + typedef struct Scull_Dev {
21733 + struct Scull_Dev *next; /* next listitem */
21734 + int quantum; /* the current quantum size */
21735 + int qset; /* the current array size */
21736 + unsigned long size;
21737 + devfs_handle_t handle; /* only used if devfs is there */
21738 + unsigned int access_key; /* used by sculluid and scullpriv */
21739 + struct semaphore sem; /* mutual exclusion semaphore */
21743 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21746 +Scull Demo: Data Structures
21749 +%font "typewriter", size 3
21750 + Display the quantum set (dev->data)
21751 +%font "typewriter", size 3
21753 +%fore "blue", cont
21757 +%fore "blue", cont
21759 +%fore "black", cont
21760 + f73f1000 f740c000 f7ab4000 . >w..?w.@@w.@+w
21761 + 0xf7400010 f73ef000 f755b000 00000000 00000000 .p>w.0Uw........
21763 + Display the first quantum (dev->data[0])
21764 +%font "typewriter", size 3
21766 +%fore "blue", cont
21769 + 0xf73ea000 200a2a2f 616d202a 632e6e69 202d2d20 /*. * main.c --
21770 + 0xf73ea010 20656874 65726162 75637320 63206c6c the bare scull c
21771 + 0xf73ea020 20726168 75646f6d 200a656c 2a200a2a har module. *. *
21772 + 0xf73ea030 706f4320 67697279 28207468 32202943 Copyright (C) 2
21773 + 0xf73ea040 20313030 73656c41 646e6173 52206f72 001 Alessandro R
21774 + 0xf73ea050 6e696275 6e612069 6f4a2064 6874616e ubini and Jonath
21775 + 0xf73ea060 43206e61 6562726f 2a200a74 706f4320 an Corbet. * Cop
21776 + 0xf73ea070 67697279 28207468 32202943 20313030 yright (C) 2001
21777 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21780 +Scull Demo: filp command
21783 +%font "typewriter", size 3
21784 + Show filp usage - here is the scull_read prototype
21785 +%font "typewriter", size 3
21786 + ssize_t scull_read(
21787 +%fore "blue", cont
21789 +%fore "black", cont
21791 + size_t count, loff_t *f_pos);
21792 + Show the stack trace:
21793 +%font "typewriter", size 3
21795 +%fore "blue", cont
21798 + EBP EIP Function(args)
21799 + 0xee9dbf78 0xf8c08471 [scull]scull_read+0xbd (
21800 +%fore "blue", cont
21802 +%fore "black", cont
21804 + 0x1000, 0xeaf6c0e0, 0x804f000)
21805 + scull .text 0xf8c08060 0xf8c083b4 0xf8c084dc
21806 + 0xee9dbfbc 0xc0136278 sys_read+0x98 (0x3, 0x804e128, 0x1000, ...
21807 + kernel .text 0xc0100000 0xc01361e0 0xc01362b0
21808 + 0xc010702b system_call+0x33
21809 + kernel .text 0xc0100000 0xc0106ff8 0xc0107030
21810 + And show the filp output
21811 +%font "typewriter", size 3
21813 +%fore "blue", cont
21816 + name.name 0xe93889fc name.len 6
21817 + File Pointer at 0xeaf6c0c0
21818 + f_list.nxt = 0xe42deca0 f_list.prv = 0xf7e69070
21820 + f_dentry = 0xe93889a0
21821 +%fore "black", cont
21822 + f_op = 0xf8c0a200
21823 + f_count = 2 f_flags = 0x8000 f_mode = 0x1
21824 + f_pos = 0 f_reada = 0 f_ramax = 0
21825 + f_raend = 0 f_ralen = 0 f_rawin = 0
21827 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21830 +Scull Demo: filp command
21833 +%font "typewriter", size 3
21834 + filp output - continued
21835 +%font "typewriter", size 3
21837 + Directory Entry at 0xe93889a0
21840 +%fore "orange", cont
21841 +d_name.name = 0xe93889fc
21842 +%fore "black", cont
21844 + d_count = 1 d_flags = 0x0
21845 +%fore "blue", cont
21846 +d_inode = 0xe827b680
21848 + d_hash.nxt = 0xc215aec8 d_hash.prv = 0xc215aec8
21849 + d_lru.nxt = 0xe93889b8 d_lru.prv = 0xe93889b8
21850 + d_child.nxt = 0xe89e1e80 d_child.prv = 0xe9388940
21851 + d_subdirs.nxt = 0xe93889c8 d_subdirs.prv = 0xe93889c8
21852 + d_alias.nxt = 0xe827b690 d_alias.prv = 0xe827b690
21853 + d_op = 0x00000000 d_sb = 0xf7e69000
21856 + Inode Entry at 0xe827b680
21858 + i_mode = 0x21a4 i_nlink = 1 i_rdev = 0xfe00
21859 + i_ino = 37182 i_count = 1 i_dev = 0x821
21860 + i_hash.nxt = 0xc20e6be8 i_hash.prv = 0xc20e6be8
21861 + i_list.nxt = 0xe827b2c8 i_list.prv = 0xe827b868
21862 + i_dentry.nxt = 0xe93889d0 i_dentry.prv = 0xe93889d0
21864 + Check the filename (display d_name.name)
21865 +%font "typewriter", size 3
21867 +%fore "orange", cont
21870 + 0xe93889fc 6c756373 0000306c 00000000 00000000 scull0..........
21872 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21879 + Show output from various kernel related kdb commands
21881 + Sequence of events
21883 + Write a simple program which allocates memory and hangs
21884 + Show usage of the ps, vm, and ll commands
21885 + Walk an IO operation
21886 + Hit a breakpoint in qlogic driver (isp1020_queuecommand)
21887 + Show usage of scsi related commands (sc, sh, and sd)
21888 + Show usage of vm related commands (bh, page, inode, inode_pages)
21892 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21897 +%font "typewriter", size 3
21898 + simple.c - simple program which allocates memory
21899 +%font "typewriter", size 3
21901 + int foo_global[8192];
21906 +%fore "blue", cont
21910 + foo_malloc = (int *)malloc(0x8192);
21911 + for(i = 0; i < 0x100; i++) {
21912 + foo_global[i] = 0xdead0000 | i;
21913 + foo_malloc[i] = 0xbeef0000 | i;
21915 + printf("foo_global at %x\n", (int)foo_global);
21916 + printf("foo_malloc at %x\n", (int)foo_malloc);
21917 + printf("sleep forever\n");
21922 +%font "typewriter", size 3
21923 + [root@elm3b77 scull]# cc -o simple simple.c
21924 + [root@elm3b77 scull]# ./simple
21926 +%fore "blue", cont
21930 +%fore "blue", cont
21935 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21940 +%font "typewriter", size 3
21941 + Show the output of the ps command
21942 +%font "typewriter", size 3
21943 + Entering kdb (current=0xc2010000, pid 0) on processor 3 due to
21946 +%fore "blue", cont
21949 + Task Addr Pid Parent [*] cpu State Thread Command
21950 + 0xf7efe000 00000001 00000000 0 003 stop 0xf7efe370 init
21951 + 0xf7ef0000 00000002 00000001 0 001 stop 0xf7ef0370 keventd
21952 + 0xf7eec000 00000003 00000000 0 000 stop 0xf7eec370 ksoftirqd_CPU0
21953 + 0xf7eea000 00000004 00000000 0 001 stop 0xf7eea370 ksoftirqd_CPU1
21954 + 0xf7ee8000 00000005 00000000 0 002 stop 0xf7ee8370 ksoftirqd_CPU2
21955 + 0xf7ee6000 00000006 00000000 0 003 stop 0xf7ee6370 ksoftirqd_CPU3
21959 + 0xf7b46000 00001006 00000737 0 003 stop 0xf7b46370 sshd
21960 + 0xf7ace000 00001007 00001006 0 000 stop 0xf7ace370 bash
21961 + 0xef06a000 00001066 00001007 0 003 stop 0xef06a370 su
21962 + 0xeef88000 00001067 00001066 0 000 stop 0xeef88370 bash
21963 + 0xeef64000 00001119 00000770 0 001 stop 0xeef64370 in.ftpd
21966 +%fore "black", cont
21967 + 00001138 00001067 0 001 stop 0xeeeac370
21968 +%fore "blue", cont
21972 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21977 +%font "typewriter", size 3
21978 + Display the task struct
21979 +%font "typewriter", size 3
21981 +%fore "blue", cont
21984 + 0xeeeac000 00000001 00000000 00000000 c0000000 ................
21985 + 0xeeeac010 c0339880 00000000 00000000 ffffffff ................
21986 + 0xeeeac020 0000000a 00000000 00000000
21987 +%fore "blue", cont
21989 +%fore "black", cont
21991 + 0xeeeac030 00000001 ffffffff ffffffff 00000000 ................
21993 +%font "typewriter", size 3
21994 + Determine offset of mm_struct ptr in task_struct
21995 +%font "typewriter", size 3
21996 + struct task_struct {
21997 + [0] volatile long state;
21998 + [4] unsigned long flags;
21999 + [8] int sigpending;
22000 + [c] mm_segment_t addr_limit;
22001 + [10] struct exec_domain *exec_domain;
22002 + [14] volatile long need_resched;
22003 + [18] unsigned long ptrace;
22004 + [1c] int lock_depth;
22005 + [20] long counter;
22007 + [28] unsigned long policy;
22009 + [2c] struct mm_struct *mm;
22011 + [30] int processor;
22012 + [34] unsigned long cpus_runnable, cpus_allowed;
22015 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22021 +%font "typewriter", size 3
22022 + Display the mm_struct associated with simple process
22023 +%font "typewriter", size 3
22025 +%fore "blue", cont
22029 +%fore "blue", cont
22031 +%fore "black", cont
22032 + e8357978 f7ac77e0 eb15eac0 .z5hxy5h`w,w@j.k
22033 + 0xf7e10f10 00000001 00000002 0000000b 00000000 ................
22034 + 0xf7e10f20 00000001 f7e10f24 f7e10f24 00000001 ................
22035 + 0xf7e10f30 f7e35e70 eea7e8f0 08048000 0804862b ................
22036 + 0xf7e10f40 0804962c 08049744 08051780 0805a000 ................
22037 + 0xf7e10f50 bffffd10 bffffe00 bffffe09 bffffe09 ................
22038 + 0xf7e10f60 bffffff3 0000005a 00000168 00000000 ................
22039 + 0xf7e10f70 00000000 00000002 00000000 00000001 ................
22041 +%font "typewriter", size 3
22042 + Determine offset of the first vma in the process
22043 +%font "typewriter", size 3
22044 + struct mm_struct {
22046 + struct vm_area_struct * mmap;
22049 + struct vm_area_struct * mmap_cache;
22053 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22058 +%font "typewriter", size 3
22059 + Display the first vma using md
22060 +%font "typewriter", size 3
22062 +%fore "blue", cont
22065 + 0xe8357a80 f7e10f00 08048000 08049000
22066 +%fore "blue", cont
22068 +%fore "black",cont
22070 + 0xe8357a90 00000025 00001875 e8727e18 00000001 %...u....~rh....
22072 + Display the first vma using vma
22073 +%font "typewriter", size 3
22075 +%fore "blue", cont
22078 + struct vm_area_struct at 0xe8357a80 for 68 bytes
22079 + vm_start = 0x8048000 vm_end = 0x8049000
22081 + flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
22082 +%font "typewriter", size 3
22084 + Determine the offset to the vma list
22085 +%font "typewriter", size 3
22086 + struct vm_area_struct {
22087 + [0] struct mm_struct * vm_mm;
22088 + [4] unsigned long vm_start;
22089 + [8] unsigned long vm_end;
22091 + [c] struct vm_area_struct *vm_next;
22095 + Display the next vma
22096 +%font "typewriter", size 3
22097 + [3]kdb> vma e8727e00
22098 + struct vm_area_struct at 0xe8727e00 for 68 bytes
22099 + vm_start = 0x8049000 vm_end = 0x804a000
22101 + flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
22102 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22107 +%font "typewriter", size 3
22108 + Use the ll command to display the list of vma's
22109 +%font "typewriter", size 3
22110 + [3]kdb> ll e8357a80 0xc vma
22112 + struct vm_area_struct at 0xe8357a80 for 68 bytes
22113 + vm_start = 0x8048000 vm_end = 0x8049000
22115 + flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
22117 + struct vm_area_struct at 0xe8727e00 for 68 bytes
22119 +%fore "orange", cont
22121 +%fore "black", cont
22123 +%fore "orange", cont
22127 + flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
22129 + struct vm_area_struct at 0xe8727c80 for 68 bytes
22131 +%fore "blue", cont
22133 +%fore "black", cont
22135 +%fore "blue", cont
22139 + flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC
22141 + struct vm_area_struct at 0xe8357900 for 68 bytes
22142 + vm_start = 0xbfffe000 vm_end = 0xc0000000
22144 + flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC GROWSDOWN
22146 + Match the vma to the displayed addresses
22147 +%font "typewriter", size 3
22149 +%fore "orange", cont
22153 +%fore "blue", cont
22156 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22159 +Walking IO structures
22163 + Show usage of various scsi and vm related kdb commands
22166 + Set a breakpoint in the scsi driver
22167 + Stops when queueing a command to the controller
22168 + Cause IO on an idle disk
22169 + Show various IO stack traces
22170 + Display the IO data structures
22171 + Display vm information about the data
22173 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22176 +Walking IO structures
22179 +%font "typewriter", size 3
22180 + Set the breakpoint
22182 +%font "typewriter", size 3
22184 +%fore "blue", cont
22185 +bp isp1020_queuecommand
22187 + Instruction(i) BP #0 at 0xc01ecfe0 (isp1020_queuecommand)
22188 + is enabled globally adjust 1
22190 +%font "typewriter", size 3
22191 + Create some activity on a previously unused disk
22193 +%font "typewriter", size 3
22195 +%fore "blue", cont
22198 + [root@elm3b77 root]#
22199 +%fore "blue", cont
22203 + Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
22204 + 0xc01ecfe0 isp1020_queuecommand:int3
22206 + Entering kdb (current=0xf75ba000, pid 1181) on processor 3 due to
22207 + Breakpoint @ 0xc01ecfe0
22210 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22213 +Walking IO structures
22216 +%font "typewriter", size 3
22218 + This is a read of the /rh62 directory
22220 +%font "typewriter", size 3
22222 +%fore "blue", cont
22225 + EBP EIP Function(args)
22226 + 0xf75bbdf4 0xc01ecfe0 isp1020_queuecommand
22227 + 0xc01e2c77 scsi_dispatch_cmd+0x1f7
22228 + 0xf75bbe24 0xc01e99b1 scsi_request_fn+0x2f1
22229 + 0xf75bbe34 0xc01c84fd generic_unplug_device+0x2d
22230 + 0xf75bbe50 0xc011b3af __run_task_queue+0x5f
22231 + 0xf75bbe6c 0xc013a63c block_sync_page+0x1c
22232 + 0xf75bbe98 0xc0128127 __lock_page+0x77
22233 + 0xf75bbea4 0xc0128178 lock_page+0x18
22234 + 0xf75bbec8 0xc012a4b3 read_cache_page+0xc3
22235 + 0xf75bbef4 0xc0168e23 ext2_get_page+0x23
22236 + 0xf75bbf48 0xc0168fdd ext2_readdir+0xfd
22237 + 0xf75bbf68 0xc0143d2e vfs_readdir+0x7e
22238 + 0xf75bbfbc 0xc01442ed
22239 +%fore "blue", cont
22240 +sys_getdents64+0x4d
22242 + 0xc010702b system_call+0x33
22244 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22247 +Walking IO structures
22250 +%font "typewriter", size 3
22251 + Allow the operation to complete
22253 +%font "typewriter", size 3
22255 +%fore "blue", cont
22258 + bench build etc lib mnt oldsys rh72 spv usr
22259 + bin data h linux mnt1 opt root test var
22260 + boot dev home lost+found mnt2 proc sbin tmp
22262 +%font "typewriter", size 3
22263 + Force some more activity
22265 +%font "typewriter", size 3
22266 + [root@elm3b77 root]#
22267 +%fore "blue", cont
22270 + Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
22271 + 0xc01ecfe0 isp1020_queuecommand:int3
22273 + Entering kdb (current=0xf768a000, pid 981) on processor 3 due to
22274 + Breakpoint @ 0xc01ecfe0
22276 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22279 +Walking IO structures
22282 +%font "typewriter", size 3
22284 + This is an inode read for /rh62/tmp
22286 +%font "typewriter", size 3
22288 +%fore "blue", cont
22291 + EBP EIP Function(args)
22292 + 0xf768bd68 0xc01ecfe0 isp1020_queuecommand
22293 + 0xc01e2c77 scsi_dispatch_cmd+0x1f7
22294 + 0xf768bd98 0xc01e99b1 scsi_request_fn+0x2f1
22295 + 0xf768bda8 0xc01c84fd generic_unplug_device+0x2d
22296 + 0xf768bdc4 0xc011b3af __run_task_queue+0x5f
22297 + 0xf768bdfc 0xc0137216 __wait_on_buffer+0x56
22298 + 0xf768be1c 0xc0138600 bread+0x50
22299 + 0xf768be5c 0xc016b684 ext2_read_inode+0x114
22300 + 0xf768bf0c 0xc013fbec real_lookup+0x7c
22301 + 0xf768bf78 0xc014035d link_path_walk+0x5ad
22302 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22305 +Walking IO structures
22308 +%font "typewriter", size 3
22309 + Create a new file, causing yet more disk activity
22311 +%font "typewriter", size 3
22313 +%fore "blue", cont
22317 + [root@elm3b77 tmp]#
22318 +%fore "blue", cont
22319 +echo "Hello linux reading group" > j1;sync
22322 + Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
22323 + 0xc01ecfe0 isp1020_queuecommand:int3
22325 + Entering kdb (current=0xf768a000, pid 981) on processor 3 due to
22326 + Breakpoint @ 0xc01ecfe0
22327 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22330 +Walking IO structures
22333 +%font "typewriter", size 3
22335 + This is an inode read in response to the open
22336 +%font "typewriter", size 3
22338 +%fore "blue", cont
22341 + EBP EIP Function(args)
22342 + 0xf768bd78 0xc01ecfe0 isp1020_queuecommand
22343 + 0xc01e2c77 scsi_dispatch_cmd+0x1f7
22344 + 0xf768bda8 0xc01e99b1 scsi_request_fn+0x2f1
22345 + 0xf768bdb8 0xc01c84fd generic_unplug_device+0x2d
22346 + 0xf768bdd4 0xc011b3af __run_task_queue+0x5f
22347 + 0xf768bdf0 0xc013a63c block_sync_page+0x1c
22348 + 0xf768be1c 0xc0128127 __lock_page+0x77
22349 + 0xf768be28 0xc0128178 lock_page+0x18
22350 + 0xf768be4c 0xc012a4b3 read_cache_page+0xc3
22351 + 0xf768be78 0xc0168e23 ext2_get_page+0x23
22352 + 0xf768beb8 0xc01691ed ext2_find_entry+0x8d
22353 + 0xf768bed4 0xc016933a ext2_inode_by_name+0x1a
22354 + 0xf768befc 0xc016c077 ext2_lookup+0x27
22355 + 0xf768bf1c 0xc014094a lookup_hash+0x9a
22356 + 0xf768bf64 0xc0140c4d open_namei+0xfd
22357 + 0xf768bfa0 0xc0135907 filp_open+0x37
22358 + 0xf768bfbc 0xc0135c64 sys_open+0x34
22359 + 0xc010702b system_call+0x33
22361 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22364 +Walking IO structures
22367 +%font "typewriter", size 3
22368 + Let the operation continue
22369 +%font "typewriter", size 3
22371 +%fore "blue", cont
22374 + Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
22375 + 0xc01ecfe0 isp1020_queuecommand: int3
22376 + Entering kdb (current=0xc0352000, pid 0) on processor 0 due to
22377 + Breakpoint @ 0xc01ecfe0
22379 + This is an io completion queuing the next request
22380 +%font "typewriter", size 3
22382 +%fore "blue", cont
22385 + EBP EIP Function(args)
22386 + 0xc0353df4 0xc01ecfe0 isp1020_queuecommand(
22387 +%fore "blue", cont
22389 +%fore "black", cont
22391 + 0xc01e2c77 scsi_dispatch_cmd+0x1f7
22392 + 0xc0353e24 0xc01e99b1 scsi_request_fn+0x2f1
22393 + 0xc0353e40 0xc01e8f6a
22394 +%fore "blue", cont
22395 +scsi_queue_next_request+0x4a
22397 + 0xc0353e5c 0xc01e9166 __scsi_end_request+0x116
22398 + 0xc0353ea8 0xc01e93e0
22399 +%fore "blue", cont
22400 +scsi_io_completion+0x170
22402 + 0xc0353ecc 0xc01f658e rw_intr+0x14e
22403 + 0xc0353ef8 0xc01e8668 scsi_old_done+0x6a8
22404 + 0xc0353fd4 0xc01052c2 cpu_idle+0x52
22405 + Function prototype
22406 +%font "typewriter", size 3
22407 + int isp1020_queuecommand(
22408 +%fore "blue", cont
22411 + void (*done)(Scsi_Cmnd *))
22412 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22415 +Walking IO structures
22418 +%font "typewriter", size 3
22419 + Show the command being queued
22420 +%font "typewriter", size 3
22422 +%fore "blue", cont
22425 + scsi_cmnd at 0xf7e63a00
22427 + host = 0xf7e91400
22428 +%fore "black", cont
22429 + state = 4099 owner = 258
22430 +%fore "blue", cont
22431 +device = 0xf7ed5d80
22433 + bnext = 0x00000000 reset_chain = 0x00000000 eh_state = 0
22434 + done = 0xc01f6440
22435 + serial_number = 3402 serial_num_at_to = 0 retries = 0 timeout = 0
22436 + id/lun/cmnd = [0/0/0] cmd_len = 10 old_cmd_len = 10
22437 + cmnd = [2a/00/00/28/00/3f/00/00/10/00/ef/f7]
22438 + data_cmnd = [2a/00/00/28/00/3f/00/00/10/00/ef/f7]
22439 + request_buffer = 0xc03fd000 bh_next = 0x00000000
22440 + request_bufflen = 8192
22441 + use_sg = 2 old_use_sg = 2 sglist_len = 512 abore_reason = 0
22442 + bufflen = 8192 buffer = 0xc03fd000 underflow = 8192
22443 + transfersize = 512
22444 + tag = 0 pid = 3401
22446 + rq_status = RQ_ACTIVE rq_dev = [8/1] errors = 1 cmd = 0
22447 + sector = 2621440 nr_sectors = 16 current_nr_sectors = 8
22448 + buffer = 0xf7599000
22449 +%fore "blue", cont
22451 +%fore "black", cont
22452 + bhtail = 0xf75ca3c0
22454 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22457 +Walking IO structures
22460 +%font "typewriter", size 3
22461 + Display the host adapter
22462 +%font "typewriter", size 3
22464 +%fore "blue", cont
22467 + Scsi_Host at 0xf7e91400
22468 + next = 0x00000000
22469 +%fore "blue", cont
22470 +host_queue = 0xf7ed5d80
22472 + ehandler = 0x00000000 eh_wait = 0x00000000 en_notify = 0x00000000
22473 + eh_action = 0x00000000
22474 + h_active = 0x0 host_wait = 0xc0353ac4 hostt = 0xc034bce0
22476 + host_failed = 0 extra_bytes = 524 host_no = 0 resetting = 0
22477 + max id/lun/channel = [16/8/0] this_id = 7
22478 + can_queue = 64 cmd_per_lun = 1 sg_tablesize = 427 u_isa_dma = 0
22479 + host_blocked = 0 reverse_ordering = 0
22481 +%font "typewriter", size 3
22482 + Display the scsi device
22483 +%font "typewriter", size 3
22485 +%fore "blue", cont
22488 + scsi_device at 0xf7ed5d80
22489 + next = 0xf7ed5c80 prev = 0x00000000 host = 0xf7e91400
22491 +%fore "blue", cont
22492 +device_queue 0xf7e63a00
22494 + id/lun/chan = [0/0/0] single_lun = 0 device_blocked = 0
22495 + queue_depth = 1 current_tag = 0 scsi_level = 4
22497 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22500 +Walking IO structures
22503 +%font "typewriter", size 3
22504 + Display the Buffer header associated with the command
22505 +%font "typewriter", size 3
22507 +%fore "blue", cont
22510 + buffer_head at 0xf75ca300
22511 + next 0x00000000 bno 327680 rsec 2621440 size 4096
22512 + dev 0x801 rdev 0x801
22513 + count 2 state 0x1d [Uptodate Lock Req Mapped] ftime 0x7695e
22514 + b_list 1 b_reqnext 0xf75ca3c0 b_data 0xf7599000
22516 + b_page 0xc1dd6640
22517 +%fore "black", cont
22518 + b_this_page 0xf75ca300 b_private 0x00000000
22520 + Display the associated page structure
22521 +%font "typewriter", size 3
22523 +%fore "blue", cont
22526 + struct page at 0xc1dd6640
22527 + next 0xc1dd7300 prev 0xc1dd6240
22528 +%fore "blue", cont
22529 +addr space 0xf7af04d0
22531 + index 327680 (offset 0x50000000)
22532 + count 2 flags PG_referenced PG_lru virtual 0xf7599000
22533 + buffers 0xf75ca300
22534 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22537 +Walking IO structures
22540 +%font "typewriter", size 3
22541 + Display the Address space associated with the page
22542 +%font "typewriter", size 3
22544 +%fore "blue", cont
22547 + 0xf7af04d0 c1dd6240 c1dea740 f7af04d8 f7af04d8 @b]A@'^AX./wX./w
22548 + 0xf7af04e0 f7af04e0 f7af04e0 00000007 c033b700 `./w`./w.....73@
22550 +%fore "blue", cont
22552 +%fore "black", cont
22553 + 00000000 00000000 00000001 ./w............
22554 + 0xf7af0500 000001d0 00000000 00000000 f7af050c P............./w
22555 + 0xf7af0510 f7af050c 00000000 f7a8afa0 00000000 ../w.... /(w....
22557 + The structure looks like:
22559 + struct address_space {
22560 + struct list_head clean_pages; /* list of clean pages */
22561 + struct list_head dirty_pages; /* list of dirty pages */
22562 + struct list_head locked_pages;/* list of locked pages */
22563 + unsigned long nrpages; /* number of total pages */
22564 + spinlock_t page_lock; /* spinlock protecting them*/
22565 + struct address_space_operations *a_ops; /* methods */
22567 + struct inode *host; /* owner: inode, block_dev */
22571 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22574 +Walking IO structures
22577 +%font "typewriter", size 3
22578 + Display the inode associated with the address space
22579 + I think htis is the inode for the block device.
22581 +%font "typewriter", size 3
22583 +%fore "blue", cont
22586 + struct inode at 0xf7af0420
22587 + i_ino = 289 i_count = 1 i_dev = 0x801 i_size 4301789184
22588 + i_mode = 0x8000 i_nlink = 1 i_rdev = 0x801
22589 + i_hash.nxt = 0xf7af0420 i_hash.prv = 0xf7af0420
22590 + i_list.nxt = 0xf7af0608 i_list.prv = 0xf7af0068
22591 + i_dentry.nxt = 0xf7af0430 i_dentry.prv = 0xf7af0430
22592 + i_dirty_buffers.nxt = 0xf7af0438 i_dirty_buffers.prv = 0xf7af0438
22593 + i_sb = 0xc201f200 i_op = 0xc03cfdc0 i_data = 0xf7af04d0 nrpages = 6
22594 + i_mapping = 0xf7af04d0
22595 + i_flags 0x0 i_state 0x0 [] fs specific info @ 0xf7af0540
22596 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22599 +Walking IO structures
22602 +%font "typewriter", size 3
22603 + Display the page list associated with the inode
22604 +%font "typewriter", size 3
22606 +%fore "blue", cont
22607 +inode_pages f7af0420
22609 +CLEAN page_struct index cnt flags
22610 + 0xc1dd6240 327735 2 0x44 bh 0xf75caae0 bno 327735
22611 + [Lock Req Mapped]
22613 + 0xc1dd6640 327680 2 0x44 bh 0xf75ca300 bno 327680
22614 + [Uptodate Lock Req Mapped]
22616 + 0xc1dd7300 327681 2 0x44 bh 0xf75ca3c0 bno 327681
22617 + [Uptodate Lock Req Mapped]
22618 + 0xc1dd6e00 327684 2 0x44 bh 0xf75ca420 bno 327684
22619 + [Uptodate Req Mapped]
22620 + 0xc1de8fc0 4 2 0xc0 bh 0xf7b5ade0 bno 4
22621 + [Uptodate Req Mapped]
22622 + 0xc1dea700 1 2 0x44 bh 0xf7e02740 bno 1
22623 + [Uptodate Req Mapped]
22624 + 0xc1dea740 0 2 0x44 bh 0xf7e028c0 bno 0
22625 + [Uptodate Req Mapped]
22626 +DIRTY page_struct index cnt flags
22627 +LOCKED page_struct index cnt flags
22628 diff -Nurp linux-2.6.22-590/drivers/char/keyboard.c linux-2.6.22-600/drivers/char/keyboard.c
22629 --- linux-2.6.22-590/drivers/char/keyboard.c 2007-07-09 01:32:17.000000000 +0200
22630 +++ linux-2.6.22-600/drivers/char/keyboard.c 2008-04-09 18:14:28.000000000 +0200
22632 #include <linux/sysrq.h>
22633 #include <linux/input.h>
22634 #include <linux/reboot.h>
22636 +#include <linux/kdb.h>
22637 +#endif /* CONFIG_KDB */
22639 extern void ctrl_alt_del(void);
22641 @@ -1138,6 +1141,13 @@ static void kbd_keycode(unsigned int key
22642 if (keycode < BTN_MISC && printk_ratelimit())
22643 printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
22646 + if (down && !rep && keycode == KEY_PAUSE && kdb_on == 1) {
22647 + kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
22650 +#endif /* CONFIG_KDB */
22652 #ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
22653 if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
22655 diff -Nurp linux-2.6.22-590/drivers/hid/usbhid/hid-core.c linux-2.6.22-600/drivers/hid/usbhid/hid-core.c
22656 --- linux-2.6.22-590/drivers/hid/usbhid/hid-core.c 2007-07-09 01:32:17.000000000 +0200
22657 +++ linux-2.6.22-600/drivers/hid/usbhid/hid-core.c 2008-04-09 18:14:28.000000000 +0200
22659 #define DRIVER_DESC "USB HID core driver"
22660 #define DRIVER_LICENSE "GPL"
22662 +#ifdef CONFIG_KDB_USB
22663 +#include <linux/kdb.h>
22666 static char *hid_types[] = {"Device", "Pointer", "Mouse", "Device", "Joystick",
22667 "Gamepad", "Keyboard", "Keypad", "Multi-Axis Controller"};
22669 @@ -948,6 +952,12 @@ static void hid_disconnect(struct usb_in
22671 usbhid = hid->driver_data;
22673 +#ifdef CONFIG_KDB_USB
22674 + /* Unlink the KDB USB struct */
22675 + if (usbhid->urbin == kdb_usb_infos.urb)
22676 + memset(&kdb_usb_infos, 0, sizeof(kdb_usb_infos));
22679 spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
22680 usb_set_intfdata(intf, NULL);
22681 spin_unlock_irq(&usbhid->inlock);
22682 @@ -1033,6 +1043,16 @@ static int hid_probe(struct usb_interfac
22683 printk(": USB HID v%x.%02x %s [%s] on %s\n",
22684 hid->version >> 8, hid->version & 0xff, c, hid->name, path);
22686 +#ifdef CONFIG_KDB_USB
22687 + /* Initialization of the KDB structure */
22688 + if (!strcmp(c, "Keyboard")) {
22689 + struct usbhid_device *usbhid = hid->driver_data;
22690 + kdb_usb_infos.urb = usbhid->urbin;
22691 + kdb_usb_infos.buffer = usbhid->inbuf;
22692 + kdb_usb_infos.reset_timer = NULL;
22699 diff -Nurp linux-2.6.22-590/drivers/hid/usbhid/usbkbd.c linux-2.6.22-600/drivers/hid/usbhid/usbkbd.c
22700 --- linux-2.6.22-590/drivers/hid/usbhid/usbkbd.c 2007-07-09 01:32:17.000000000 +0200
22701 +++ linux-2.6.22-600/drivers/hid/usbhid/usbkbd.c 2008-04-09 18:14:28.000000000 +0200
22703 #include <linux/init.h>
22704 #include <linux/usb/input.h>
22705 #include <linux/hid.h>
22706 +#ifdef CONFIG_KDB_USB
22707 +#include <linux/kdb.h>
22711 * Version Information
22712 @@ -288,6 +291,13 @@ static int usb_kbd_probe(struct usb_inte
22713 usb_fill_int_urb(kbd->irq, dev, pipe,
22714 kbd->new, (maxp > 8 ? 8 : maxp),
22715 usb_kbd_irq, kbd, endpoint->bInterval);
22717 +#ifdef CONFIG_KDB_USB
22718 + /* Init the KDB structure */
22719 + kdb_usb_infos.urb = kbd->irq;
22720 + kdb_usb_infos.buffer = kbd->new;
22721 + kdb_usb_infos.reset_timer = NULL;
22723 kbd->irq->transfer_dma = kbd->new_dma;
22724 kbd->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
22726 @@ -324,6 +334,11 @@ static void usb_kbd_disconnect(struct us
22727 struct usb_kbd *kbd = usb_get_intfdata (intf);
22729 usb_set_intfdata(intf, NULL);
22730 +#ifdef CONFIG_KDB_USB
22731 + /* Unlink the KDB USB struct */
22732 + if (kbd && kbd->irq == kdb_usb_infos.urb)
22733 + memset(&kdb_usb_infos, 0, sizeof(kdb_usb_infos));
22734 +#endif /* CONFIG_KDB_USB */
22736 usb_kill_urb(kbd->irq);
22737 input_unregister_device(kbd->dev);
22738 diff -Nurp linux-2.6.22-590/drivers/serial/8250.c linux-2.6.22-600/drivers/serial/8250.c
22739 --- linux-2.6.22-590/drivers/serial/8250.c 2007-07-09 01:32:17.000000000 +0200
22740 +++ linux-2.6.22-600/drivers/serial/8250.c 2008-04-09 18:14:28.000000000 +0200
22742 #include <asm/irq.h>
22745 +#include <linux/kdb.h>
22748 + * kdb_serial_line records the serial line number of the first serial console.
22749 + * NOTE: The kernel ignores characters on the serial line unless a user space
22750 + * program has opened the line first. To enter kdb before user space has opened
22751 + * the serial line, you can use the 'kdb=early' flag to lilo and set the
22752 + * appropriate breakpoints.
22755 +static int kdb_serial_line = -1;
22756 +static const char *kdb_serial_ptr = kdb_serial_str;
22757 +#endif /* CONFIG_KDB */
22761 @@ -1287,6 +1300,20 @@ receive_chars(struct uart_8250_port *up,
22764 ch = serial_inp(up, UART_RX);
22766 + if ((up->port.line == kdb_serial_line) && kdb_on == 1) {
22767 + if (ch == *kdb_serial_ptr) {
22768 + if (!(*++kdb_serial_ptr)) {
22769 + atomic_inc(&kdb_8250);
22770 + kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
22771 + atomic_dec(&kdb_8250);
22772 + kdb_serial_ptr = kdb_serial_str;
22776 + kdb_serial_ptr = kdb_serial_str;
22778 +#endif /* CONFIG_KDB */
22780 up->port.icount.rx++;
22782 @@ -2460,7 +2487,7 @@ serial8250_console_write(struct console
22783 if (up->port.sysrq) {
22784 /* serial8250_handle_port() already took the lock */
22786 - } else if (oops_in_progress) {
22787 + } else if (oops_in_progress || KDB_8250()) {
22788 locked = spin_trylock(&up->port.lock);
22790 spin_lock(&up->port.lock);
22791 @@ -2508,6 +2535,30 @@ static int __init serial8250_console_set
22792 if (!port->iobase && !port->membase)
22797 + * Remember the line number of the first serial
22798 + * console. We'll make this the kdb serial console too.
22800 + if (co && kdb_serial_line == -1) {
22801 + kdb_serial_line = co->index;
22802 + kdb_serial.io_type = port->iotype;
22803 + switch (port->iotype) {
22804 + case SERIAL_IO_MEM:
22805 +#ifdef SERIAL_IO_MEM32
22806 + case SERIAL_IO_MEM32:
22808 + kdb_serial.iobase = (unsigned long)(port->membase);
22809 + kdb_serial.ioreg_shift = port->regshift;
22812 + kdb_serial.iobase = port->iobase;
22813 + kdb_serial.ioreg_shift = 0;
22817 +#endif /* CONFIG_KDB */
22820 uart_parse_options(options, &baud, &parity, &bits, &flow);
22822 diff -Nurp linux-2.6.22-590/drivers/serial/8250_early.c linux-2.6.22-600/drivers/serial/8250_early.c
22823 --- linux-2.6.22-590/drivers/serial/8250_early.c 2007-07-09 01:32:17.000000000 +0200
22824 +++ linux-2.6.22-600/drivers/serial/8250_early.c 2008-04-09 18:14:28.000000000 +0200
22826 #include <asm/io.h>
22827 #include <asm/serial.h>
22831 +#include <linux/kdb.h>
22833 +static int kdb_serial_line = -1;
22834 +#endif /* CONFIG_KDB */
22836 struct early_uart_device {
22837 struct uart_port port;
22838 char options[16]; /* e.g., 115200n8 */
22839 @@ -186,6 +193,31 @@ static int __init early_uart_setup(struc
22840 if ((err = parse_options(device, options)) < 0)
22846 + * Remember the line number of the first serial
22847 + * console. We'll make this the kdb serial console too.
22849 + if (console && kdb_serial_line == -1) {
22850 + kdb_serial_line = console->index;
22851 + kdb_serial.io_type = device->port.iotype;
22852 + switch (device->port.iotype) {
22853 + case SERIAL_IO_MEM:
22854 +#ifdef SERIAL_IO_MEM32
22855 + case SERIAL_IO_MEM32:
22857 + kdb_serial.iobase = (unsigned long)(device->port.membase);
22858 + kdb_serial.ioreg_shift = device->port.regshift;
22861 + kdb_serial.iobase = device->port.iobase;
22862 + kdb_serial.ioreg_shift = 0;
22866 +#endif /* CONFIG_KDB */
22871 @@ -218,7 +250,7 @@ int __init early_serial_console_init(cha
22874 options = strchr(cmdline, ',') + 1;
22875 - if ((err = early_uart_setup(NULL, options)) < 0)
22876 + if ((err = early_uart_setup(&early_uart_console, options)) < 0)
22878 return early_uart_console_init();
22880 diff -Nurp linux-2.6.22-590/drivers/serial/sn_console.c linux-2.6.22-600/drivers/serial/sn_console.c
22881 --- linux-2.6.22-590/drivers/serial/sn_console.c 2007-07-09 01:32:17.000000000 +0200
22882 +++ linux-2.6.22-600/drivers/serial/sn_console.c 2008-04-09 18:14:28.000000000 +0200
22884 #include <linux/delay.h> /* for mdelay */
22885 #include <linux/miscdevice.h>
22886 #include <linux/serial_core.h>
22888 +#include <linux/kdb.h>
22889 +#include <linux/kdbprivate.h>
22890 +#include <linux/serial_reg.h>
22892 + * kdb_serial_line records the serial line number of the first serial console.
22893 + * NOTE: The kernel ignores characters on the serial line unless a user space
22894 + * program has opened the line first. To enter kdb before user space has opened
22895 + * the serial line, you can use the 'kdb=early' flag to lilo and set the
22896 + * appropriate breakpoints.
22899 +static int kdb_serial_line = -1;
22900 +static char *kdb_serial_ptr = (char *)kdb_serial_str;
22901 +#endif /* CONFIG_KDB */
22904 #include <asm/io.h>
22905 #include <asm/sn/simulator.h>
22906 @@ -485,6 +501,26 @@ sn_receive_chars(struct sn_cons_port *po
22907 "obtaining data from the console (0x%0x)\n", ch);
22911 + if (kdb_on == 1) {
22912 + if (ch == *kdb_serial_ptr) {
22913 + if (!(*++kdb_serial_ptr)) {
22914 + spin_unlock_irqrestore(&port->sc_port.lock, flags);
22915 + if (!get_irq_regs()) {
22916 + KDB_STATE_SET(KEYBOARD);
22917 + KDB_ENTER(); /* to get some registers */
22919 + kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
22920 + kdb_serial_ptr = (char *)kdb_serial_str;
22921 + spin_lock_irqsave(&port->sc_port.lock, flags);
22926 + kdb_serial_ptr = (char *)kdb_serial_str;
22928 +#endif /* CONFIG_KDB */
22930 #ifdef CONFIG_MAGIC_SYSRQ
22931 if (sysrq_requested) {
22932 unsigned long sysrq_timeout = sysrq_requested + HZ*5;
22933 @@ -1008,6 +1044,15 @@ sn_sal_console_write(struct console *co,
22935 static int __init sn_sal_console_setup(struct console *co, char *options)
22939 + * Remember the line number of the first serial
22940 + * console. We'll make this the kdb serial console too.
22942 + if (kdb_serial_line == -1) {
22943 + kdb_serial_line = co->index;
22945 +#endif /* CONFIG_KDB */
22949 @@ -1083,3 +1128,31 @@ static int __init sn_sal_serial_console_
22952 console_initcall(sn_sal_serial_console_init);
22956 +l1_control_in_polled(int offset)
22958 + int sal_call_status = 0, input;
22960 + if (offset == UART_LSR) {
22961 + ret = (UART_LSR_THRE | UART_LSR_TEMT); /* can send anytime */
22962 + sal_call_status = ia64_sn_console_check(&input);
22963 + if (!sal_call_status && input) {
22964 + /* input pending */
22965 + ret |= UART_LSR_DR;
22972 +l1_serial_in_polled(void)
22975 + if (!ia64_sn_console_getc(&ch))
22980 +#endif /* CONFIG_KDB */
22981 diff -Nurp linux-2.6.22-590/drivers/usb/host/ohci-hcd.c linux-2.6.22-600/drivers/usb/host/ohci-hcd.c
22982 --- linux-2.6.22-590/drivers/usb/host/ohci-hcd.c 2007-07-09 01:32:17.000000000 +0200
22983 +++ linux-2.6.22-600/drivers/usb/host/ohci-hcd.c 2008-04-09 18:14:28.000000000 +0200
22984 @@ -843,6 +843,53 @@ static int ohci_restart (struct ohci_hcd
22986 /*-------------------------------------------------------------------------*/
22988 +#ifdef CONFIG_KDB_USB
22991 +ohci_kdb_poll (void * __ohci, struct urb *urb)
22993 + struct ohci_hcd *ohci;
22994 + struct ohci_regs * regs;
22997 + * NOTE - we use the ohci_hcd from the urb rather than the
22998 + * __ohci parameter (which is NULL anyway). This ensures
22999 + * that we will process the proper controller for the urb.
23002 + if (!urb) /* can happen if no keyboard attached */
23005 + ohci = (struct ohci_hcd *) hcd_to_ohci(bus_to_hcd(urb->dev->bus));
23006 + regs = ohci->regs;
23008 + /* if the urb is not currently in progress resubmit it */
23009 + if (urb->status != -EINPROGRESS) {
23011 + if (usb_submit_urb (urb, GFP_ATOMIC))
23014 + /* make sure the HC registers are set correctly */
23015 + writel (OHCI_INTR_WDH, ®s->intrenable);
23016 + writel (OHCI_INTR_WDH, ®s->intrstatus);
23017 + writel (OHCI_INTR_MIE, ®s->intrenable);
23019 + // flush those pci writes
23020 + (void) readl (&ohci->regs->control);
23023 + if (ohci->hcca->done_head) {
23024 + dl_done_list_kdb (ohci, urb);
23025 + writel (OHCI_INTR_WDH, ®s->intrstatus);
23026 + // flush the pci write
23027 + (void) readl (&ohci->regs->control);
23031 +#endif /* CONFIG_KDB_USB */
23033 +/*-------------------------------------------------------------------------*/
23035 #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
23037 MODULE_AUTHOR (DRIVER_AUTHOR);
23038 diff -Nurp linux-2.6.22-590/drivers/usb/host/ohci-pci.c linux-2.6.22-600/drivers/usb/host/ohci-pci.c
23039 --- linux-2.6.22-590/drivers/usb/host/ohci-pci.c 2007-07-09 01:32:17.000000000 +0200
23040 +++ linux-2.6.22-600/drivers/usb/host/ohci-pci.c 2008-04-09 18:14:28.000000000 +0200
23042 #error "This file is PCI bus glue. CONFIG_PCI must be defined."
23045 +#ifdef CONFIG_KDB_USB
23046 +#include <linux/kdb.h>
23049 /*-------------------------------------------------------------------------*/
23051 static int broken_suspend(struct usb_hcd *hcd)
23052 @@ -199,6 +203,12 @@ static int __devinit ohci_pci_start (str
23053 ohci_err (ohci, "can't start\n");
23056 +#ifdef CONFIG_KDB_USB
23058 + kdb_usb_infos.poll_func = ohci_kdb_poll;
23059 + kdb_usb_infos.uhci = NULL; /* not used */
23065 diff -Nurp linux-2.6.22-590/drivers/usb/host/ohci-q.c linux-2.6.22-600/drivers/usb/host/ohci-q.c
23066 --- linux-2.6.22-590/drivers/usb/host/ohci-q.c 2007-07-09 01:32:17.000000000 +0200
23067 +++ linux-2.6.22-600/drivers/usb/host/ohci-q.c 2008-04-09 18:14:28.000000000 +0200
23068 @@ -1115,3 +1115,65 @@ dl_done_list (struct ohci_hcd *ohci)
23074 +/*-------------------------------------------------------------------------*/
23076 +#ifdef CONFIG_KDB_USB
23078 +dl_done_list_kdb (struct ohci_hcd *ohci, struct urb *kdburb)
23080 + struct td *td = dl_reverse_done_list (ohci);
23083 + struct td *td_next = td->next_dl_td;
23084 + struct urb *urb = td->urb;
23085 + urb_priv_t *urb_priv = urb->hcpriv;
23086 + struct ed *ed = td->ed;
23088 + if (urb != kdburb) {
23093 + /* update URB's length and status from TD */
23094 + td_done (ohci, urb, td);
23095 + urb_priv->td_cnt++;
23097 + /* If all this urb's TDs are done, just resubmit it */
23098 + if (urb_priv->td_cnt == urb_priv->length) {
23099 + urb->actual_length = 0;
23100 + urb->status = -EINPROGRESS;
23101 + td_submit_urb (ohci, urb);
23104 + /* clean schedule: unlink EDs that are no longer busy */
23105 + if (list_empty (&ed->td_list)) {
23106 + if (ed->state == ED_OPER)
23107 + start_ed_unlink (ohci, ed);
23109 + /* ... reenabling halted EDs only after fault cleanup */
23110 + } else if ((ed->hwINFO & cpu_to_hc32 (ohci, ED_SKIP | ED_DEQUEUE))
23111 + == cpu_to_hc32 (ohci, ED_SKIP)) {
23112 + td = list_entry (ed->td_list.next, struct td, td_list);
23113 + if (!(td->hwINFO & cpu_to_hc32 (ohci, TD_DONE))) {
23114 + ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP);
23115 + /* ... hc may need waking-up */
23116 + switch (ed->type) {
23117 + case PIPE_CONTROL:
23118 + ohci_writel (ohci, OHCI_CLF,
23119 + &ohci->regs->cmdstatus);
23122 + ohci_writel (ohci, OHCI_BLF,
23123 + &ohci->regs->cmdstatus);
23133 +#endif /* CONFIG_KDB_USB */
23134 diff -Nurp linux-2.6.22-590/fs/proc/mmu.c linux-2.6.22-600/fs/proc/mmu.c
23135 --- linux-2.6.22-590/fs/proc/mmu.c 2007-07-09 01:32:17.000000000 +0200
23136 +++ linux-2.6.22-600/fs/proc/mmu.c 2008-04-09 18:14:28.000000000 +0200
23137 @@ -31,11 +31,21 @@
23138 #include <asm/div64.h>
23139 #include "internal.h"
23142 +#include <linux/kdb.h>
23145 void get_vmalloc_info(struct vmalloc_info *vmi)
23147 struct vm_struct *vma;
23148 unsigned long free_area_size;
23149 unsigned long prev_end;
23151 + int get_lock = !KDB_IS_RUNNING();
23153 +#define get_lock 1
23159 @@ -47,7 +57,8 @@ void get_vmalloc_info(struct vmalloc_inf
23161 prev_end = VMALLOC_START;
23163 - read_lock(&vmlist_lock);
23165 + read_lock(&vmlist_lock);
23167 for (vma = vmlist; vma; vma = vma->next) {
23168 unsigned long addr = (unsigned long) vma->addr;
23169 @@ -72,6 +83,7 @@ void get_vmalloc_info(struct vmalloc_inf
23170 if (VMALLOC_END - prev_end > vmi->largest_chunk)
23171 vmi->largest_chunk = VMALLOC_END - prev_end;
23173 - read_unlock(&vmlist_lock);
23175 + read_unlock(&vmlist_lock);
23178 diff -Nurp linux-2.6.22-590/fs/proc/proc_misc.c linux-2.6.22-600/fs/proc/proc_misc.c
23179 --- linux-2.6.22-590/fs/proc/proc_misc.c 2008-04-09 18:10:53.000000000 +0200
23180 +++ linux-2.6.22-600/fs/proc/proc_misc.c 2008-04-09 18:14:28.000000000 +0200
23181 @@ -235,6 +235,120 @@ static int meminfo_read_proc(char *page,
23186 +#include <linux/kdb.h>
23187 +#include <linux/kdbprivate.h>
23188 +/* Like meminfo_read_proc() but without the locks and using kdb_printf() */
23190 +kdb_meminfo_read_proc(void)
23192 + struct sysinfo i;
23193 + unsigned long committed;
23194 + unsigned long allowed;
23195 + struct vmalloc_info vmi;
23199 + * display in kilobytes.
23201 +#define K(x) ((x) << (PAGE_SHIFT - 10))
23203 + kdb_si_swapinfo(&i);
23204 + committed = atomic_read(&vm_committed_space);
23205 + allowed = ((totalram_pages - hugetlb_total_pages())
23206 + * sysctl_overcommit_ratio / 100) + total_swap_pages;
23208 + cached = global_page_state(NR_FILE_PAGES) -
23209 + total_swapcache_pages - i.bufferram;
23213 + get_vmalloc_info(&vmi);
23216 + "MemTotal: %8lu kB\n"
23217 + "MemFree: %8lu kB\n"
23218 + "Buffers: %8lu kB\n",
23224 + "Cached: %8lu kB\n"
23225 + "SwapCached: %8lu kB\n"
23226 + "Active: %8lu kB\n"
23227 + "Inactive: %8lu kB\n",
23229 + K(total_swapcache_pages),
23230 + K(global_page_state(NR_ACTIVE)),
23231 + K(global_page_state(NR_INACTIVE))
23233 +#ifdef CONFIG_HIGHMEM
23235 + "HighTotal: %8lu kB\n"
23236 + "HighFree: %8lu kB\n"
23237 + "LowTotal: %8lu kB\n"
23238 + "LowFree: %8lu kB\n",
23241 + K(i.totalram-i.totalhigh),
23242 + K(i.freeram-i.freehigh)
23246 + "SwapTotal: %8lu kB\n"
23247 + "SwapFree: %8lu kB\n"
23248 + "Dirty: %8lu kB\n",
23251 + K(global_page_state(NR_FILE_DIRTY))
23254 + "Writeback: %8lu kB\n"
23255 + "AnonPages: %8lu kB\n"
23256 + "Mapped: %8lu kB\n",
23257 + K(global_page_state(NR_WRITEBACK)),
23258 + K(global_page_state(NR_ANON_PAGES)),
23259 + K(global_page_state(NR_FILE_MAPPED))
23262 + "Slab: %8lu kB\n"
23263 + "SReclaimable: %8lu kB\n"
23264 + "SUnreclaim: %8lu kB\n",
23265 + K(global_page_state(NR_SLAB_RECLAIMABLE) +
23266 + global_page_state(NR_SLAB_UNRECLAIMABLE)),
23267 + K(global_page_state(NR_SLAB_RECLAIMABLE)),
23268 + K(global_page_state(NR_SLAB_UNRECLAIMABLE))
23271 + "PageTables: %8lu kB\n"
23272 + "NFS_Unstable: %8lu kB\n"
23273 + "Bounce: %8lu kB\n",
23274 + K(global_page_state(NR_PAGETABLE)),
23275 + K(global_page_state(NR_UNSTABLE_NFS)),
23276 + K(global_page_state(NR_BOUNCE))
23279 + "CommitLimit: %8lu kB\n"
23280 + "Committed_AS: %8lu kB\n"
23281 + "VmallocTotal: %8lu kB\n",
23284 + (unsigned long)VMALLOC_TOTAL >> 10
23287 + "VmallocUsed: %8lu kB\n"
23288 + "VmallocChunk: %8lu kB\n",
23290 + vmi.largest_chunk >> 10
23293 +#ifdef CONFIG_HUGETLBFS
23294 + kdb_hugetlb_report_meminfo();
23297 +#endif /* CONFIG_KDB */
23299 extern struct seq_operations fragmentation_op;
23300 static int fragmentation_open(struct inode *inode, struct file *file)
23302 diff -Nurp linux-2.6.22-590/include/asm-i386/ansidecl.h linux-2.6.22-600/include/asm-i386/ansidecl.h
23303 --- linux-2.6.22-590/include/asm-i386/ansidecl.h 1970-01-01 01:00:00.000000000 +0100
23304 +++ linux-2.6.22-600/include/asm-i386/ansidecl.h 2008-04-09 18:16:14.000000000 +0200
23306 +/* ANSI and traditional C compatability macros
23307 + Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
23308 + Free Software Foundation, Inc.
23309 + This file is part of the GNU C Library.
23311 +This program is free software; you can redistribute it and/or modify
23312 +it under the terms of the GNU General Public License as published by
23313 +the Free Software Foundation; either version 2 of the License, or
23314 +(at your option) any later version.
23316 +This program is distributed in the hope that it will be useful,
23317 +but WITHOUT ANY WARRANTY; without even the implied warranty of
23318 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23319 +GNU General Public License for more details.
23321 +You should have received a copy of the GNU General Public License
23322 +along with this program; if not, write to the Free Software
23323 +Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
23325 +/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
23326 + * Any trailing whitespace was removed and #ifdef/ifndef __KERNEL__ added as
23328 + * Keith Owens <kaos@sgi.com> 15 May 2006
23331 +/* ANSI and traditional C compatibility macros
23333 + ANSI C is assumed if __STDC__ is #defined.
23335 + Macro ANSI C definition Traditional C definition
23336 + ----- ---- - ---------- ----------- - ----------
23337 + ANSI_PROTOTYPES 1 not defined
23338 + PTR `void *' `char *'
23339 + PTRCONST `void *const' `char *'
23340 + LONG_DOUBLE `long double' `double'
23341 + const not defined `'
23342 + volatile not defined `'
23343 + signed not defined `'
23344 + VA_START(ap, var) va_start(ap, var) va_start(ap)
23346 + Note that it is safe to write "void foo();" indicating a function
23347 + with no return value, in all K+R compilers we have been able to test.
23349 + For declaring functions with prototypes, we also provide these:
23351 + PARAMS ((prototype))
23352 + -- for functions which take a fixed number of arguments. Use this
23353 + when declaring the function. When defining the function, write a
23354 + K+R style argument list. For example:
23356 + char *strcpy PARAMS ((char *dest, char *source));
23359 + strcpy (dest, source)
23365 + VPARAMS ((prototype, ...))
23366 + -- for functions which take a variable number of arguments. Use
23367 + PARAMS to declare the function, VPARAMS to define it. For example:
23369 + int printf PARAMS ((const char *format, ...));
23372 + printf VPARAMS ((const char *format, ...))
23377 + For writing functions which take variable numbers of arguments, we
23378 + also provide the VA_OPEN, VA_CLOSE, and VA_FIXEDARG macros. These
23379 + hide the differences between K+R <varargs.h> and C89 <stdarg.h> more
23380 + thoroughly than the simple VA_START() macro mentioned above.
23382 + VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end.
23383 + Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls
23384 + corresponding to the list of fixed arguments. Then use va_arg
23385 + normally to get the variable arguments, or pass your va_list object
23386 + around. You do not declare the va_list yourself; VA_OPEN does it
23389 + Here is a complete example:
23392 + printf VPARAMS ((const char *format, ...))
23396 + VA_OPEN (ap, format);
23397 + VA_FIXEDARG (ap, const char *, format);
23399 + result = vfprintf (stdout, format, ap);
23406 + You can declare variables either before or after the VA_OPEN,
23407 + VA_FIXEDARG sequence. Also, VA_OPEN and VA_CLOSE are the beginning
23408 + and end of a block. They must appear at the same nesting level,
23409 + and any variables declared after VA_OPEN go out of scope at
23410 + VA_CLOSE. Unfortunately, with a K+R compiler, that includes the
23411 + argument list. You can have multiple instances of VA_OPEN/VA_CLOSE
23412 + pairs in a single function in case you need to traverse the
23413 + argument list more than once.
23415 + For ease of writing code which uses GCC extensions but needs to be
23416 + portable to other compilers, we provide the GCC_VERSION macro that
23417 + simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
23418 + wrappers around __attribute__. Also, __extension__ will be #defined
23419 + to nothing if it doesn't work. See below.
23421 + This header also defines a lot of obsolete macros:
23422 + CONST, VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID,
23423 + AND, DOTS, NOARGS. Don't use them. */
23425 +#ifndef _ANSIDECL_H
23426 +#define _ANSIDECL_H 1
23428 +/* Every source file includes this file,
23429 + so they will all get the switch for lint. */
23432 +/* Using MACRO(x,y) in cpp #if conditionals does not work with some
23433 + older preprocessors. Thus we can't define something like this:
23435 +#define HAVE_GCC_VERSION(MAJOR, MINOR) \
23436 + (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
23438 +and then test "#if HAVE_GCC_VERSION(2,7)".
23440 +So instead we use the macro below and test it against specific values. */
23442 +/* This macro simplifies testing whether we are using gcc, and if it
23443 + is of a particular minimum version. (Both major & minor numbers are
23444 + significant.) This macro will evaluate to 0 if we are not using
23446 +#ifndef GCC_VERSION
23447 +#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
23448 +#endif /* GCC_VERSION */
23450 +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) || (defined(__alpha) && defined(__cplusplus))
23451 +/* All known AIX compilers implement these things (but don't always
23452 + define __STDC__). The RISC/OS MIPS compiler defines these things
23453 + in SVR4 mode, but does not define __STDC__. */
23454 +/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
23455 + C++ compilers, does not define __STDC__, though it acts as if this
23456 + was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
23458 +#define ANSI_PROTOTYPES 1
23459 +#define PTR void *
23460 +#define PTRCONST void *const
23461 +#define LONG_DOUBLE long double
23463 +/* PARAMS is often defined elsewhere (e.g. by libintl.h), so wrap it in
23466 +#define PARAMS(ARGS) ARGS
23469 +#define VPARAMS(ARGS) ARGS
23470 +#define VA_START(VA_LIST, VAR) va_start(VA_LIST, VAR)
23472 +/* variadic function helper macros */
23473 +/* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's
23474 + use without inhibiting further decls and without declaring an
23475 + actual variable. */
23476 +#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP, VAR); { struct Qdmy
23477 +#define VA_CLOSE(AP) } va_end(AP); }
23478 +#define VA_FIXEDARG(AP, T, N) struct Qdmy
23485 +#ifndef __STDC_VERSION__
23486 +#define __STDC_VERSION__ 0
23488 +#endif /* __KERNEL__ */
23490 +/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
23491 + it too, but it's not in C89. */
23493 +#if __STDC_VERSION__ > 199901L
23494 +/* it's a keyword */
23496 +# if GCC_VERSION >= 2007
23497 +# define inline __inline__ /* __inline__ prevents -pedantic warnings */
23499 +# define inline /* nothing */
23503 +/* These are obsolete. Do not use. */
23505 +#define CONST const
23506 +#define VOLATILE volatile
23507 +#define SIGNED signed
23509 +#define PROTO(type, name, arglist) type name arglist
23510 +#define EXFUN(name, proto) name proto
23511 +#define DEFUN(name, arglist, args) name(args)
23512 +#define DEFUN_VOID(name) name(void)
23514 +#define DOTS , ...
23515 +#define NOARGS void
23516 +#endif /* ! IN_GCC */
23518 +#else /* Not ANSI C. */
23520 +#undef ANSI_PROTOTYPES
23521 +#define PTR char *
23522 +#define PTRCONST PTR
23523 +#define LONG_DOUBLE double
23525 +#define PARAMS(args) ()
23526 +#define VPARAMS(args) (va_alist) va_dcl
23527 +#define VA_START(va_list, var) va_start(va_list)
23529 +#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP); { struct Qdmy
23530 +#define VA_CLOSE(AP) } va_end(AP); }
23531 +#define VA_FIXEDARG(AP, TYPE, NAME) TYPE NAME = va_arg(AP, TYPE)
23533 +/* some systems define these in header files for non-ansi mode */
23548 +#define PROTO(type, name, arglist) type name ()
23549 +#define EXFUN(name, proto) name()
23550 +#define DEFUN(name, arglist, args) name arglist args;
23551 +#define DEFUN_VOID(name) name()
23555 +#endif /* ! IN_GCC */
23557 +#endif /* ANSI C. */
23559 +/* Define macros for some gcc attributes. This permits us to use the
23560 + macros freely, and know that they will come into play for the
23561 + version of gcc in which they are supported. */
23563 +#if (GCC_VERSION < 2007)
23564 +# define __attribute__(x)
23567 +/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
23568 +#ifndef ATTRIBUTE_MALLOC
23569 +# if (GCC_VERSION >= 2096)
23570 +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
23572 +# define ATTRIBUTE_MALLOC
23573 +# endif /* GNUC >= 2.96 */
23574 +#endif /* ATTRIBUTE_MALLOC */
23576 +/* Attributes on labels were valid as of gcc 2.93. */
23577 +#ifndef ATTRIBUTE_UNUSED_LABEL
23578 +# if (!defined (__cplusplus) && GCC_VERSION >= 2093)
23579 +# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
23581 +# define ATTRIBUTE_UNUSED_LABEL
23582 +# endif /* !__cplusplus && GNUC >= 2.93 */
23583 +#endif /* ATTRIBUTE_UNUSED_LABEL */
23585 +#ifndef ATTRIBUTE_UNUSED
23586 +#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
23587 +#endif /* ATTRIBUTE_UNUSED */
23589 +/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
23590 + identifier name. */
23591 +#if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
23592 +# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
23593 +#else /* !__cplusplus || GNUC >= 3.4 */
23594 +# define ARG_UNUSED(NAME) NAME
23595 +#endif /* !__cplusplus || GNUC >= 3.4 */
23597 +#ifndef ATTRIBUTE_NORETURN
23598 +#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
23599 +#endif /* ATTRIBUTE_NORETURN */
23601 +/* Attribute `nonnull' was valid as of gcc 3.3. */
23602 +#ifndef ATTRIBUTE_NONNULL
23603 +# if (GCC_VERSION >= 3003)
23604 +# define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
23606 +# define ATTRIBUTE_NONNULL(m)
23607 +# endif /* GNUC >= 3.3 */
23608 +#endif /* ATTRIBUTE_NONNULL */
23610 +/* Attribute `pure' was valid as of gcc 3.0. */
23611 +#ifndef ATTRIBUTE_PURE
23612 +# if (GCC_VERSION >= 3000)
23613 +# define ATTRIBUTE_PURE __attribute__ ((__pure__))
23615 +# define ATTRIBUTE_PURE
23616 +# endif /* GNUC >= 3.0 */
23617 +#endif /* ATTRIBUTE_PURE */
23619 +/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
23620 + This was the case for the `printf' format attribute by itself
23621 + before GCC 3.3, but as of 3.3 we need to add the `nonnull'
23622 + attribute to retain this behavior. */
23623 +#ifndef ATTRIBUTE_PRINTF
23624 +#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
23625 +#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
23626 +#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
23627 +#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
23628 +#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
23629 +#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
23630 +#endif /* ATTRIBUTE_PRINTF */
23632 +/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
23633 + a function pointer. Format attributes were allowed on function
23634 + pointers as of gcc 3.1. */
23635 +#ifndef ATTRIBUTE_FPTR_PRINTF
23636 +# if (GCC_VERSION >= 3001)
23637 +# define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
23639 +# define ATTRIBUTE_FPTR_PRINTF(m, n)
23640 +# endif /* GNUC >= 3.1 */
23641 +# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
23642 +# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
23643 +# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
23644 +# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
23645 +# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
23646 +#endif /* ATTRIBUTE_FPTR_PRINTF */
23648 +/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL. A
23649 + NULL format specifier was allowed as of gcc 3.3. */
23650 +#ifndef ATTRIBUTE_NULL_PRINTF
23651 +# if (GCC_VERSION >= 3003)
23652 +# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
23654 +# define ATTRIBUTE_NULL_PRINTF(m, n)
23655 +# endif /* GNUC >= 3.3 */
23656 +# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
23657 +# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
23658 +# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
23659 +# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
23660 +# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
23661 +#endif /* ATTRIBUTE_NULL_PRINTF */
23663 +/* Attribute `sentinel' was valid as of gcc 3.5. */
23664 +#ifndef ATTRIBUTE_SENTINEL
23665 +# if (GCC_VERSION >= 3005)
23666 +# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
23668 +# define ATTRIBUTE_SENTINEL
23669 +# endif /* GNUC >= 3.5 */
23670 +#endif /* ATTRIBUTE_SENTINEL */
23673 +#ifndef ATTRIBUTE_ALIGNED_ALIGNOF
23674 +# if (GCC_VERSION >= 3000)
23675 +# define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
23677 +# define ATTRIBUTE_ALIGNED_ALIGNOF(m)
23678 +# endif /* GNUC >= 3.0 */
23679 +#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
23681 +/* We use __extension__ in some places to suppress -pedantic warnings
23682 + about GCC extensions. This feature didn't work properly before
23684 +#if GCC_VERSION < 2008
23685 +#define __extension__
23688 +#endif /* ansidecl.h */
23689 diff -Nurp linux-2.6.22-590/include/asm-i386/bfd.h linux-2.6.22-600/include/asm-i386/bfd.h
23690 --- linux-2.6.22-590/include/asm-i386/bfd.h 1970-01-01 01:00:00.000000000 +0100
23691 +++ linux-2.6.22-600/include/asm-i386/bfd.h 2008-04-09 18:16:14.000000000 +0200
23693 +/* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically
23694 + generated from "bfd-in.h", "init.c", "opncls.c", "libbfd.c",
23695 + "bfdio.c", "bfdwin.c", "section.c", "archures.c", "reloc.c",
23696 + "syms.c", "bfd.c", "archive.c", "corefile.c", "targets.c", "format.c",
23697 + "linker.c" and "simple.c".
23698 + Run "make headers" in your build bfd/ to regenerate. */
23700 +/* Main header file for the bfd library -- portable access to object files.
23702 + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
23703 + 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
23705 + Contributed by Cygnus Support.
23707 + This file is part of BFD, the Binary File Descriptor library.
23709 + This program is free software; you can redistribute it and/or modify
23710 + it under the terms of the GNU General Public License as published by
23711 + the Free Software Foundation; either version 2 of the License, or
23712 + (at your option) any later version.
23714 + This program is distributed in the hope that it will be useful,
23715 + but WITHOUT ANY WARRANTY; without even the implied warranty of
23716 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23717 + GNU General Public License for more details.
23719 + You should have received a copy of the GNU General Public License
23720 + along with this program; if not, write to the Free Software
23721 + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
23723 +/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
23724 + * Any trailing whitespace was removed and #ifdef/ifndef __KERNEL__ added as
23726 + * Keith Owens <kaos@sgi.com> 15 May 2006
23729 +#ifndef __BFD_H_SEEN__
23730 +#define __BFD_H_SEEN__
23732 +#ifdef __cplusplus
23737 +#include <asm/ansidecl.h>
23738 +#else /* __KERNEL__ */
23739 +#include "ansidecl.h"
23740 +#include "symcat.h"
23741 +#endif /* __KERNEL__ */
23742 +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
23744 +/* This hack is to avoid a problem with some strict ANSI C preprocessors.
23745 + The problem is, "32_" is not a valid preprocessing token, and we don't
23746 + want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will
23747 + cause the inner CONCAT2 macros to be evaluated first, producing
23748 + still-valid pp-tokens. Then the final concatenation can be done. */
23750 +#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
23754 +/* The word size used by BFD on the host. This may be 64 with a 32
23755 + bit target if the host is 64 bit, or if other 64 bit targets have
23756 + been selected with --enable-targets, or if --enable-64-bit-bfd. */
23758 +#define BFD_ARCH_SIZE 32
23759 +#else /* __KERNEL__ */
23760 +#define BFD_ARCH_SIZE 64
23761 +#endif /* __KERNEL__ */
23763 +/* The word size of the default bfd target. */
23764 +#define BFD_DEFAULT_TARGET_SIZE 32
23766 +#define BFD_HOST_64BIT_LONG 0
23767 +#define BFD_HOST_LONG_LONG 1
23769 +#define BFD_HOST_64_BIT long long
23770 +#define BFD_HOST_U_64_BIT unsigned long long
23771 +typedef BFD_HOST_64_BIT bfd_int64_t;
23772 +typedef BFD_HOST_U_64_BIT bfd_uint64_t;
23775 +#if BFD_ARCH_SIZE >= 64
23781 +#define INLINE __inline__
23787 +/* Forward declaration. */
23788 +typedef struct bfd bfd;
23790 +/* Boolean type used in bfd. Too many systems define their own
23791 + versions of "boolean" for us to safely typedef a "boolean" of
23792 + our own. Using an enum for "bfd_boolean" has its own set of
23793 + problems, with strange looking casts required to avoid warnings
23794 + on some older compilers. Thus we just use an int.
23796 + General rule: Functions which are bfd_boolean return TRUE on
23797 + success and FALSE on failure (unless they're a predicate). */
23799 +typedef int bfd_boolean;
23807 +#ifndef BFD_HOST_64_BIT
23808 + #error No 64 bit integer type available
23809 +#endif /* ! defined (BFD_HOST_64_BIT) */
23811 +typedef BFD_HOST_U_64_BIT bfd_vma;
23812 +typedef BFD_HOST_64_BIT bfd_signed_vma;
23813 +typedef BFD_HOST_U_64_BIT bfd_size_type;
23814 +typedef BFD_HOST_U_64_BIT symvalue;
23816 +#ifndef fprintf_vma
23817 +#if BFD_HOST_64BIT_LONG
23818 +#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
23819 +#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
23821 +#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
23822 +#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
23823 +#define fprintf_vma(s,x) \
23824 + fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
23825 +#define sprintf_vma(s,x) \
23826 + sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
23830 +#else /* not BFD64 */
23832 +/* Represent a target address. Also used as a generic unsigned type
23833 + which is guaranteed to be big enough to hold any arithmetic types
23834 + we need to deal with. */
23835 +typedef unsigned long bfd_vma;
23837 +/* A generic signed type which is guaranteed to be big enough to hold any
23838 + arithmetic types we need to deal with. Can be assumed to be compatible
23839 + with bfd_vma in the same way that signed and unsigned ints are compatible
23840 + (as parameters, in assignment, etc). */
23841 +typedef long bfd_signed_vma;
23843 +typedef unsigned long symvalue;
23844 +typedef unsigned long bfd_size_type;
23846 +/* Print a bfd_vma x on stream s. */
23847 +#define fprintf_vma(s,x) fprintf (s, "%08lx", x)
23848 +#define sprintf_vma(s,x) sprintf (s, "%08lx", x)
23850 +#endif /* not BFD64 */
23852 +#define HALF_BFD_SIZE_TYPE \
23853 + (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))
23855 +#ifndef BFD_HOST_64_BIT
23856 +/* Fall back on a 32 bit type. The idea is to make these types always
23857 + available for function return types, but in the case that
23858 + BFD_HOST_64_BIT is undefined such a function should abort or
23859 + otherwise signal an error. */
23860 +typedef bfd_signed_vma bfd_int64_t;
23861 +typedef bfd_vma bfd_uint64_t;
23864 +/* An offset into a file. BFD always uses the largest possible offset
23865 + based on the build time availability of fseek, fseeko, or fseeko64. */
23866 +typedef BFD_HOST_64_BIT file_ptr;
23867 +typedef unsigned BFD_HOST_64_BIT ufile_ptr;
23869 +extern void bfd_sprintf_vma (bfd *, char *, bfd_vma);
23870 +extern void bfd_fprintf_vma (bfd *, void *, bfd_vma);
23872 +#define printf_vma(x) fprintf_vma(stdout,x)
23873 +#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
23875 +typedef unsigned int flagword; /* 32 bits of flags */
23876 +typedef unsigned char bfd_byte;
23878 +/* File formats. */
23880 +typedef enum bfd_format
23882 + bfd_unknown = 0, /* File format is unknown. */
23883 + bfd_object, /* Linker/assembler/compiler output. */
23884 + bfd_archive, /* Object archive file. */
23885 + bfd_core, /* Core dump. */
23886 + bfd_type_end /* Marks the end; don't use it! */
23890 +/* Values that may appear in the flags field of a BFD. These also
23891 + appear in the object_flags field of the bfd_target structure, where
23892 + they indicate the set of flags used by that backend (not all flags
23893 + are meaningful for all object file formats) (FIXME: at the moment,
23894 + the object_flags values have mostly just been copied from backend
23895 + to another, and are not necessarily correct). */
23898 +#define BFD_NO_FLAGS 0x00
23900 +/* BFD contains relocation entries. */
23901 +#define HAS_RELOC 0x01
23903 +/* BFD is directly executable. */
23904 +#define EXEC_P 0x02
23906 +/* BFD has line number information (basically used for F_LNNO in a
23908 +#define HAS_LINENO 0x04
23910 +/* BFD has debugging information. */
23911 +#define HAS_DEBUG 0x08
23913 +/* BFD has symbols. */
23914 +#define HAS_SYMS 0x10
23916 +/* BFD has local symbols (basically used for F_LSYMS in a COFF
23918 +#define HAS_LOCALS 0x20
23920 +/* BFD is a dynamic object. */
23921 +#define DYNAMIC 0x40
23923 +/* Text section is write protected (if D_PAGED is not set, this is
23924 + like an a.out NMAGIC file) (the linker sets this by default, but
23925 + clears it for -r or -N). */
23926 +#define WP_TEXT 0x80
23928 +/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
23929 + linker sets this by default, but clears it for -r or -n or -N). */
23930 +#define D_PAGED 0x100
23932 +/* BFD is relaxable (this means that bfd_relax_section may be able to
23933 + do something) (sometimes bfd_relax_section can do something even if
23934 + this is not set). */
23935 +#define BFD_IS_RELAXABLE 0x200
23937 +/* This may be set before writing out a BFD to request using a
23938 + traditional format. For example, this is used to request that when
23939 + writing out an a.out object the symbols not be hashed to eliminate
23941 +#define BFD_TRADITIONAL_FORMAT 0x400
23943 +/* This flag indicates that the BFD contents are actually cached in
23944 + memory. If this is set, iostream points to a bfd_in_memory struct. */
23945 +#define BFD_IN_MEMORY 0x800
23947 +/* The sections in this BFD specify a memory page. */
23948 +#define HAS_LOAD_PAGE 0x1000
23950 +/* This BFD has been created by the linker and doesn't correspond
23951 + to any input file. */
23952 +#define BFD_LINKER_CREATED 0x2000
23954 +/* Symbols and relocation. */
23956 +/* A count of carsyms (canonical archive symbols). */
23957 +typedef unsigned long symindex;
23959 +/* How to perform a relocation. */
23960 +typedef const struct reloc_howto_struct reloc_howto_type;
23962 +#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
23964 +/* General purpose part of a symbol X;
23965 + target specific parts are in libcoff.h, libaout.h, etc. */
23967 +#define bfd_get_section(x) ((x)->section)
23968 +#define bfd_get_output_section(x) ((x)->section->output_section)
23969 +#define bfd_set_section(x,y) ((x)->section) = (y)
23970 +#define bfd_asymbol_base(x) ((x)->section->vma)
23971 +#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
23972 +#define bfd_asymbol_name(x) ((x)->name)
23973 +/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
23974 +#define bfd_asymbol_bfd(x) ((x)->the_bfd)
23975 +#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
23977 +/* A canonical archive symbol. */
23978 +/* This is a type pun with struct ranlib on purpose! */
23979 +typedef struct carsym
23982 + file_ptr file_offset; /* Look here to find the file. */
23984 +carsym; /* To make these you call a carsymogen. */
23986 +/* Used in generating armaps (archive tables of contents).
23987 + Perhaps just a forward definition would do? */
23988 +struct orl /* Output ranlib. */
23990 + char **name; /* Symbol name. */
23995 + } u; /* bfd* or file position. */
23996 + int namidx; /* Index into string table. */
23999 +/* Linenumber stuff. */
24000 +typedef struct lineno_cache_entry
24002 + unsigned int line_number; /* Linenumber from start of function. */
24005 + struct bfd_symbol *sym; /* Function name. */
24006 + bfd_vma offset; /* Offset into section. */
24011 +/* Object and core file sections. */
24013 +#define align_power(addr, align) \
24014 + (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
24016 +typedef struct bfd_section *sec_ptr;
24018 +#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
24019 +#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
24020 +#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
24021 +#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
24022 +#define bfd_section_name(bfd, ptr) ((ptr)->name)
24023 +#define bfd_section_size(bfd, ptr) ((ptr)->size)
24024 +#define bfd_get_section_size(ptr) ((ptr)->size)
24025 +#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
24026 +#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
24027 +#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
24028 +#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
24029 +#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
24031 +#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
24033 +#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
24034 +#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
24035 +#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
24036 +/* Find the address one past the end of SEC. */
24037 +#define bfd_get_section_limit(bfd, sec) \
24038 + (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
24039 + / bfd_octets_per_byte (bfd))
24041 +typedef struct stat stat_type;
24043 +typedef enum bfd_print_symbol
24045 + bfd_print_symbol_name,
24046 + bfd_print_symbol_more,
24047 + bfd_print_symbol_all
24048 +} bfd_print_symbol_type;
24050 +/* Information about a symbol that nm needs. */
24052 +typedef struct _symbol_info
24056 + const char *name; /* Symbol name. */
24057 + unsigned char stab_type; /* Stab type. */
24058 + char stab_other; /* Stab other. */
24059 + short stab_desc; /* Stab desc. */
24060 + const char *stab_name; /* String for stab type. */
24063 +/* Get the name of a stabs type code. */
24065 +extern const char *bfd_get_stab_name (int);
24067 +/* Hash table routines. There is no way to free up a hash table. */
24069 +/* An element in the hash table. Most uses will actually use a larger
24070 + structure, and an instance of this will be the first field. */
24072 +struct bfd_hash_entry
24074 + /* Next entry for this hash code. */
24075 + struct bfd_hash_entry *next;
24076 + /* String being hashed. */
24077 + const char *string;
24078 + /* Hash code. This is the full hash code, not the index into the
24080 + unsigned long hash;
24083 +/* A hash table. */
24085 +struct bfd_hash_table
24087 + /* The hash array. */
24088 + struct bfd_hash_entry **table;
24089 + /* The number of slots in the hash table. */
24090 + unsigned int size;
24091 + /* A function used to create new elements in the hash table. The
24092 + first entry is itself a pointer to an element. When this
24093 + function is first invoked, this pointer will be NULL. However,
24094 + having the pointer permits a hierarchy of method functions to be
24095 + built each of which calls the function in the superclass. Thus
24096 + each function should be written to allocate a new block of memory
24097 + only if the argument is NULL. */
24098 + struct bfd_hash_entry *(*newfunc)
24099 + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
24100 + /* An objalloc for this hash table. This is a struct objalloc *,
24101 + but we use void * to avoid requiring the inclusion of objalloc.h. */
24105 +/* Initialize a hash table. */
24106 +extern bfd_boolean bfd_hash_table_init
24107 + (struct bfd_hash_table *,
24108 + struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
24109 + struct bfd_hash_table *,
24112 +/* Initialize a hash table specifying a size. */
24113 +extern bfd_boolean bfd_hash_table_init_n
24114 + (struct bfd_hash_table *,
24115 + struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
24116 + struct bfd_hash_table *,
24118 + unsigned int size);
24120 +/* Free up a hash table. */
24121 +extern void bfd_hash_table_free
24122 + (struct bfd_hash_table *);
24124 +/* Look up a string in a hash table. If CREATE is TRUE, a new entry
24125 + will be created for this string if one does not already exist. The
24126 + COPY argument must be TRUE if this routine should copy the string
24127 + into newly allocated memory when adding an entry. */
24128 +extern struct bfd_hash_entry *bfd_hash_lookup
24129 + (struct bfd_hash_table *, const char *, bfd_boolean create,
24130 + bfd_boolean copy);
24132 +/* Replace an entry in a hash table. */
24133 +extern void bfd_hash_replace
24134 + (struct bfd_hash_table *, struct bfd_hash_entry *old,
24135 + struct bfd_hash_entry *nw);
24137 +/* Base method for creating a hash table entry. */
24138 +extern struct bfd_hash_entry *bfd_hash_newfunc
24139 + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
24141 +/* Grab some space for a hash table entry. */
24142 +extern void *bfd_hash_allocate
24143 + (struct bfd_hash_table *, unsigned int);
24145 +/* Traverse a hash table in a random order, calling a function on each
24146 + element. If the function returns FALSE, the traversal stops. The
24147 + INFO argument is passed to the function. */
24148 +extern void bfd_hash_traverse
24149 + (struct bfd_hash_table *,
24150 + bfd_boolean (*) (struct bfd_hash_entry *, void *),
24153 +/* Allows the default size of a hash table to be configured. New hash
24154 + tables allocated using bfd_hash_table_init will be created with
24156 +extern void bfd_hash_set_default_size (bfd_size_type);
24158 +/* This structure is used to keep track of stabs in sections
24159 + information while linking. */
24163 + /* A hash table used to hold stabs strings. */
24164 + struct bfd_strtab_hash *strings;
24165 + /* The header file hash table. */
24166 + struct bfd_hash_table includes;
24167 + /* The first .stabstr section. */
24168 + struct bfd_section *stabstr;
24171 +#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
24173 +/* User program access to BFD facilities. */
24175 +/* Direct I/O routines, for programs which know more about the object
24176 + file than BFD does. Use higher level routines if possible. */
24178 +extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
24179 +extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
24180 +extern int bfd_seek (bfd *, file_ptr, int);
24181 +extern file_ptr bfd_tell (bfd *);
24182 +extern int bfd_flush (bfd *);
24183 +extern int bfd_stat (bfd *, struct stat *);
24185 +/* Deprecated old routines. */
24187 +#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
24188 + (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
24189 + bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
24190 +#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
24191 + (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
24192 + bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
24194 +#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
24195 + (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
24196 + bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
24197 +#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
24198 + (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
24199 + bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
24201 +extern void warn_deprecated (const char *, const char *, int, const char *);
24203 +/* Cast from const char * to char * so that caller can assign to
24204 + a char * without a warning. */
24205 +#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
24206 +#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
24207 +#define bfd_get_format(abfd) ((abfd)->format)
24208 +#define bfd_get_target(abfd) ((abfd)->xvec->name)
24209 +#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
24210 +#define bfd_family_coff(abfd) \
24211 + (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
24212 + bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
24213 +#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
24214 +#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
24215 +#define bfd_header_big_endian(abfd) \
24216 + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
24217 +#define bfd_header_little_endian(abfd) \
24218 + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
24219 +#define bfd_get_file_flags(abfd) ((abfd)->flags)
24220 +#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
24221 +#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
24222 +#define bfd_my_archive(abfd) ((abfd)->my_archive)
24223 +#define bfd_has_map(abfd) ((abfd)->has_armap)
24225 +#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
24226 +#define bfd_usrdata(abfd) ((abfd)->usrdata)
24228 +#define bfd_get_start_address(abfd) ((abfd)->start_address)
24229 +#define bfd_get_symcount(abfd) ((abfd)->symcount)
24230 +#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
24231 +#define bfd_count_sections(abfd) ((abfd)->section_count)
24233 +#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
24235 +#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
24237 +#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
24239 +extern bfd_boolean bfd_cache_close
24241 +/* NB: This declaration should match the autogenerated one in libbfd.h. */
24243 +extern bfd_boolean bfd_cache_close_all (void);
24245 +extern bfd_boolean bfd_record_phdr
24246 + (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
24247 + bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
24249 +/* Byte swapping routines. */
24251 +bfd_uint64_t bfd_getb64 (const void *);
24252 +bfd_uint64_t bfd_getl64 (const void *);
24253 +bfd_int64_t bfd_getb_signed_64 (const void *);
24254 +bfd_int64_t bfd_getl_signed_64 (const void *);
24255 +bfd_vma bfd_getb32 (const void *);
24256 +bfd_vma bfd_getl32 (const void *);
24257 +bfd_signed_vma bfd_getb_signed_32 (const void *);
24258 +bfd_signed_vma bfd_getl_signed_32 (const void *);
24259 +bfd_vma bfd_getb16 (const void *);
24260 +bfd_vma bfd_getl16 (const void *);
24261 +bfd_signed_vma bfd_getb_signed_16 (const void *);
24262 +bfd_signed_vma bfd_getl_signed_16 (const void *);
24263 +void bfd_putb64 (bfd_uint64_t, void *);
24264 +void bfd_putl64 (bfd_uint64_t, void *);
24265 +void bfd_putb32 (bfd_vma, void *);
24266 +void bfd_putl32 (bfd_vma, void *);
24267 +void bfd_putb16 (bfd_vma, void *);
24268 +void bfd_putl16 (bfd_vma, void *);
24270 +/* Byte swapping routines which take size and endiannes as arguments. */
24272 +bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean);
24273 +void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean);
24275 +extern bfd_boolean bfd_section_already_linked_table_init (void);
24276 +extern void bfd_section_already_linked_table_free (void);
24278 +/* Externally visible ECOFF routines. */
24280 +#if defined(__STDC__) || defined(ALMOST_STDC)
24281 +struct ecoff_debug_info;
24282 +struct ecoff_debug_swap;
24283 +struct ecoff_extr;
24284 +struct bfd_symbol;
24285 +struct bfd_link_info;
24286 +struct bfd_link_hash_entry;
24287 +struct bfd_elf_version_tree;
24289 +extern bfd_vma bfd_ecoff_get_gp_value
24291 +extern bfd_boolean bfd_ecoff_set_gp_value
24292 + (bfd *abfd, bfd_vma gp_value);
24293 +extern bfd_boolean bfd_ecoff_set_regmasks
24294 + (bfd *abfd, unsigned long gprmask, unsigned long fprmask,
24295 + unsigned long *cprmask);
24296 +extern void *bfd_ecoff_debug_init
24297 + (bfd *output_bfd, struct ecoff_debug_info *output_debug,
24298 + const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
24299 +extern void bfd_ecoff_debug_free
24300 + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
24301 + const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
24302 +extern bfd_boolean bfd_ecoff_debug_accumulate
24303 + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
24304 + const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
24305 + struct ecoff_debug_info *input_debug,
24306 + const struct ecoff_debug_swap *input_swap, struct bfd_link_info *);
24307 +extern bfd_boolean bfd_ecoff_debug_accumulate_other
24308 + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
24309 + const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
24310 + struct bfd_link_info *);
24311 +extern bfd_boolean bfd_ecoff_debug_externals
24312 + (bfd *abfd, struct ecoff_debug_info *debug,
24313 + const struct ecoff_debug_swap *swap, bfd_boolean relocatable,
24314 + bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *),
24315 + void (*set_index) (struct bfd_symbol *, bfd_size_type));
24316 +extern bfd_boolean bfd_ecoff_debug_one_external
24317 + (bfd *abfd, struct ecoff_debug_info *debug,
24318 + const struct ecoff_debug_swap *swap, const char *name,
24319 + struct ecoff_extr *esym);
24320 +extern bfd_size_type bfd_ecoff_debug_size
24321 + (bfd *abfd, struct ecoff_debug_info *debug,
24322 + const struct ecoff_debug_swap *swap);
24323 +extern bfd_boolean bfd_ecoff_write_debug
24324 + (bfd *abfd, struct ecoff_debug_info *debug,
24325 + const struct ecoff_debug_swap *swap, file_ptr where);
24326 +extern bfd_boolean bfd_ecoff_write_accumulated_debug
24327 + (void *handle, bfd *abfd, struct ecoff_debug_info *debug,
24328 + const struct ecoff_debug_swap *swap,
24329 + struct bfd_link_info *info, file_ptr where);
24331 +/* Externally visible ELF routines. */
24333 +struct bfd_link_needed_list
24335 + struct bfd_link_needed_list *next;
24337 + const char *name;
24340 +enum dynamic_lib_link_class {
24342 + DYN_AS_NEEDED = 1,
24343 + DYN_DT_NEEDED = 2,
24344 + DYN_NO_ADD_NEEDED = 4,
24345 + DYN_NO_NEEDED = 8
24348 +extern bfd_boolean bfd_elf_record_link_assignment
24349 + (struct bfd_link_info *, const char *, bfd_boolean);
24350 +extern struct bfd_link_needed_list *bfd_elf_get_needed_list
24351 + (bfd *, struct bfd_link_info *);
24352 +extern bfd_boolean bfd_elf_get_bfd_needed_list
24353 + (bfd *, struct bfd_link_needed_list **);
24354 +extern bfd_boolean bfd_elf_size_dynamic_sections
24355 + (bfd *, const char *, const char *, const char *, const char * const *,
24356 + struct bfd_link_info *, struct bfd_section **,
24357 + struct bfd_elf_version_tree *);
24358 +extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr
24359 + (bfd *, struct bfd_link_info *);
24360 +extern void bfd_elf_set_dt_needed_name
24361 + (bfd *, const char *);
24362 +extern const char *bfd_elf_get_dt_soname
24364 +extern void bfd_elf_set_dyn_lib_class
24366 +extern int bfd_elf_get_dyn_lib_class
24368 +extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
24369 + (bfd *, struct bfd_link_info *);
24370 +extern bfd_boolean bfd_elf_discard_info
24371 + (bfd *, struct bfd_link_info *);
24372 +extern unsigned int _bfd_elf_default_action_discarded
24373 + (struct bfd_section *);
24375 +/* Return an upper bound on the number of bytes required to store a
24376 + copy of ABFD's program header table entries. Return -1 if an error
24377 + occurs; bfd_get_error will return an appropriate code. */
24378 +extern long bfd_get_elf_phdr_upper_bound
24381 +/* Copy ABFD's program header table entries to *PHDRS. The entries
24382 + will be stored as an array of Elf_Internal_Phdr structures, as
24383 + defined in include/elf/internal.h. To find out how large the
24384 + buffer needs to be, call bfd_get_elf_phdr_upper_bound.
24386 + Return the number of program header table entries read, or -1 if an
24387 + error occurs; bfd_get_error will return an appropriate code. */
24388 +extern int bfd_get_elf_phdrs
24389 + (bfd *abfd, void *phdrs);
24391 +/* Create a new BFD as if by bfd_openr. Rather than opening a file,
24392 + reconstruct an ELF file by reading the segments out of remote memory
24393 + based on the ELF file header at EHDR_VMA and the ELF program headers it
24394 + points to. If not null, *LOADBASEP is filled in with the difference
24395 + between the VMAs from which the segments were read, and the VMAs the
24396 + file headers (and hence BFD's idea of each section's VMA) put them at.
24398 + The function TARGET_READ_MEMORY is called to copy LEN bytes from the
24399 + remote memory at target address VMA into the local buffer at MYADDR; it
24400 + should return zero on success or an `errno' code on failure. TEMPL must
24401 + be a BFD for an ELF target with the word size and byte order found in
24402 + the remote memory. */
24403 +extern bfd *bfd_elf_bfd_from_remote_memory
24404 + (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
24405 + int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
24407 +/* Return the arch_size field of an elf bfd, or -1 if not elf. */
24408 +extern int bfd_get_arch_size
24411 +/* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
24412 +extern int bfd_get_sign_extend_vma
24415 +extern struct bfd_section *_bfd_elf_tls_setup
24416 + (bfd *, struct bfd_link_info *);
24418 +extern void _bfd_elf_provide_symbol
24419 + (struct bfd_link_info *, const char *, bfd_vma, struct bfd_section *);
24421 +extern void _bfd_elf_provide_section_bound_symbols
24422 + (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
24424 +extern void _bfd_elf_fix_excluded_sec_syms
24425 + (bfd *, struct bfd_link_info *);
24427 +extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
24428 + (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
24431 +/* SunOS shared library support routines for the linker. */
24433 +extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
24434 + (bfd *, struct bfd_link_info *);
24435 +extern bfd_boolean bfd_sunos_record_link_assignment
24436 + (bfd *, struct bfd_link_info *, const char *);
24437 +extern bfd_boolean bfd_sunos_size_dynamic_sections
24438 + (bfd *, struct bfd_link_info *, struct bfd_section **,
24439 + struct bfd_section **, struct bfd_section **);
24441 +/* Linux shared library support routines for the linker. */
24443 +extern bfd_boolean bfd_i386linux_size_dynamic_sections
24444 + (bfd *, struct bfd_link_info *);
24445 +extern bfd_boolean bfd_m68klinux_size_dynamic_sections
24446 + (bfd *, struct bfd_link_info *);
24447 +extern bfd_boolean bfd_sparclinux_size_dynamic_sections
24448 + (bfd *, struct bfd_link_info *);
24452 +struct _bfd_window_internal;
24453 +typedef struct _bfd_window_internal bfd_window_internal;
24455 +typedef struct _bfd_window
24457 + /* What the user asked for. */
24459 + bfd_size_type size;
24460 + /* The actual window used by BFD. Small user-requested read-only
24461 + regions sharing a page may share a single window into the object
24462 + file. Read-write versions shouldn't until I've fixed things to
24463 + keep track of which portions have been claimed by the
24464 + application; don't want to give the same region back when the
24465 + application wants two writable copies! */
24466 + struct _bfd_window_internal *i;
24470 +extern void bfd_init_window
24472 +extern void bfd_free_window
24474 +extern bfd_boolean bfd_get_file_window
24475 + (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
24477 +/* XCOFF support routines for the linker. */
24479 +extern bfd_boolean bfd_xcoff_link_record_set
24480 + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
24481 +extern bfd_boolean bfd_xcoff_import_symbol
24482 + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
24483 + const char *, const char *, const char *, unsigned int);
24484 +extern bfd_boolean bfd_xcoff_export_symbol
24485 + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
24486 +extern bfd_boolean bfd_xcoff_link_count_reloc
24487 + (bfd *, struct bfd_link_info *, const char *);
24488 +extern bfd_boolean bfd_xcoff_record_link_assignment
24489 + (bfd *, struct bfd_link_info *, const char *);
24490 +extern bfd_boolean bfd_xcoff_size_dynamic_sections
24491 + (bfd *, struct bfd_link_info *, const char *, const char *,
24492 + unsigned long, unsigned long, unsigned long, bfd_boolean,
24493 + int, bfd_boolean, bfd_boolean, struct bfd_section **, bfd_boolean);
24494 +extern bfd_boolean bfd_xcoff_link_generate_rtinit
24495 + (bfd *, const char *, const char *, bfd_boolean);
24497 +/* XCOFF support routines for ar. */
24498 +extern bfd_boolean bfd_xcoff_ar_archive_set_magic
24501 +/* Externally visible COFF routines. */
24503 +#if defined(__STDC__) || defined(ALMOST_STDC)
24504 +struct internal_syment;
24505 +union internal_auxent;
24508 +extern bfd_boolean bfd_coff_get_syment
24509 + (bfd *, struct bfd_symbol *, struct internal_syment *);
24511 +extern bfd_boolean bfd_coff_get_auxent
24512 + (bfd *, struct bfd_symbol *, int, union internal_auxent *);
24514 +extern bfd_boolean bfd_coff_set_symbol_class
24515 + (bfd *, struct bfd_symbol *, unsigned int);
24517 +extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
24518 + (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
24520 +/* ARM Interworking support. Called from linker. */
24521 +extern bfd_boolean bfd_arm_allocate_interworking_sections
24522 + (struct bfd_link_info *);
24524 +extern bfd_boolean bfd_arm_process_before_allocation
24525 + (bfd *, struct bfd_link_info *, int);
24527 +extern bfd_boolean bfd_arm_get_bfd_for_interworking
24528 + (bfd *, struct bfd_link_info *);
24530 +/* PE ARM Interworking support. Called from linker. */
24531 +extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
24532 + (struct bfd_link_info *);
24534 +extern bfd_boolean bfd_arm_pe_process_before_allocation
24535 + (bfd *, struct bfd_link_info *, int);
24537 +extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
24538 + (bfd *, struct bfd_link_info *);
24540 +/* ELF ARM Interworking support. Called from linker. */
24541 +extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
24542 + (struct bfd_link_info *);
24544 +extern bfd_boolean bfd_elf32_arm_process_before_allocation
24545 + (bfd *, struct bfd_link_info *, int);
24547 +void bfd_elf32_arm_set_target_relocs
24548 + (struct bfd_link_info *, int, char *, int, int);
24550 +extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
24551 + (bfd *, struct bfd_link_info *);
24553 +extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
24554 + (bfd *, struct bfd_link_info *);
24556 +/* ELF ARM mapping symbol support */
24557 +extern bfd_boolean bfd_is_arm_mapping_symbol_name
24558 + (const char * name);
24560 +/* ARM Note section processing. */
24561 +extern bfd_boolean bfd_arm_merge_machines
24564 +extern bfd_boolean bfd_arm_update_notes
24565 + (bfd *, const char *);
24567 +extern unsigned int bfd_arm_get_mach_from_notes
24568 + (bfd *, const char *);
24570 +/* TI COFF load page support. */
24571 +extern void bfd_ticoff_set_section_load_page
24572 + (struct bfd_section *, int);
24574 +extern int bfd_ticoff_get_section_load_page
24575 + (struct bfd_section *);
24577 +/* H8/300 functions. */
24578 +extern bfd_vma bfd_h8300_pad_address
24579 + (bfd *, bfd_vma);
24581 +/* IA64 Itanium code generation. Called from linker. */
24582 +extern void bfd_elf32_ia64_after_parse
24585 +extern void bfd_elf64_ia64_after_parse
24588 +/* This structure is used for a comdat section, as in PE. A comdat
24589 + section is associated with a particular symbol. When the linker
24590 + sees a comdat section, it keeps only one of the sections with a
24591 + given name and associated with a given symbol. */
24593 +struct coff_comdat_info
24595 + /* The name of the symbol associated with a comdat section. */
24596 + const char *name;
24598 + /* The local symbol table index of the symbol associated with a
24599 + comdat section. This is only meaningful to the object file format
24600 + specific code; it is not an index into the list returned by
24601 + bfd_canonicalize_symtab. */
24605 +extern struct coff_comdat_info *bfd_coff_get_comdat_section
24606 + (bfd *, struct bfd_section *);
24608 +/* Extracted from init.c. */
24609 +void bfd_init (void);
24611 +/* Extracted from opncls.c. */
24612 +bfd *bfd_fopen (const char *filename, const char *target,
24613 + const char *mode, int fd);
24615 +bfd *bfd_openr (const char *filename, const char *target);
24617 +bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
24619 +bfd *bfd_openstreamr (const char *, const char *, void *);
24621 +bfd *bfd_openr_iovec (const char *filename, const char *target,
24622 + void *(*open) (struct bfd *nbfd,
24623 + void *open_closure),
24624 + void *open_closure,
24625 + file_ptr (*pread) (struct bfd *nbfd,
24629 + file_ptr offset),
24630 + int (*close) (struct bfd *nbfd,
24633 +bfd *bfd_openw (const char *filename, const char *target);
24635 +bfd_boolean bfd_close (bfd *abfd);
24637 +bfd_boolean bfd_close_all_done (bfd *);
24639 +bfd *bfd_create (const char *filename, bfd *templ);
24641 +bfd_boolean bfd_make_writable (bfd *abfd);
24643 +bfd_boolean bfd_make_readable (bfd *abfd);
24645 +unsigned long bfd_calc_gnu_debuglink_crc32
24646 + (unsigned long crc, const unsigned char *buf, bfd_size_type len);
24648 +char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir);
24650 +struct bfd_section *bfd_create_gnu_debuglink_section
24651 + (bfd *abfd, const char *filename);
24653 +bfd_boolean bfd_fill_in_gnu_debuglink_section
24654 + (bfd *abfd, struct bfd_section *sect, const char *filename);
24656 +/* Extracted from libbfd.c. */
24658 +/* Byte swapping macros for user section data. */
24660 +#define bfd_put_8(abfd, val, ptr) \
24661 + ((void) (*((unsigned char *) (ptr)) = (val) & 0xff))
24662 +#define bfd_put_signed_8 \
24664 +#define bfd_get_8(abfd, ptr) \
24665 + (*(unsigned char *) (ptr) & 0xff)
24666 +#define bfd_get_signed_8(abfd, ptr) \
24667 + (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
24669 +#define bfd_put_16(abfd, val, ptr) \
24670 + BFD_SEND (abfd, bfd_putx16, ((val),(ptr)))
24671 +#define bfd_put_signed_16 \
24673 +#define bfd_get_16(abfd, ptr) \
24674 + BFD_SEND (abfd, bfd_getx16, (ptr))
24675 +#define bfd_get_signed_16(abfd, ptr) \
24676 + BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
24678 +#define bfd_put_32(abfd, val, ptr) \
24679 + BFD_SEND (abfd, bfd_putx32, ((val),(ptr)))
24680 +#define bfd_put_signed_32 \
24682 +#define bfd_get_32(abfd, ptr) \
24683 + BFD_SEND (abfd, bfd_getx32, (ptr))
24684 +#define bfd_get_signed_32(abfd, ptr) \
24685 + BFD_SEND (abfd, bfd_getx_signed_32, (ptr))
24687 +#define bfd_put_64(abfd, val, ptr) \
24688 + BFD_SEND (abfd, bfd_putx64, ((val), (ptr)))
24689 +#define bfd_put_signed_64 \
24691 +#define bfd_get_64(abfd, ptr) \
24692 + BFD_SEND (abfd, bfd_getx64, (ptr))
24693 +#define bfd_get_signed_64(abfd, ptr) \
24694 + BFD_SEND (abfd, bfd_getx_signed_64, (ptr))
24696 +#define bfd_get(bits, abfd, ptr) \
24697 + ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \
24698 + : (bits) == 16 ? bfd_get_16 (abfd, ptr) \
24699 + : (bits) == 32 ? bfd_get_32 (abfd, ptr) \
24700 + : (bits) == 64 ? bfd_get_64 (abfd, ptr) \
24701 + : (abort (), (bfd_vma) - 1))
24703 +#define bfd_put(bits, abfd, val, ptr) \
24704 + ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \
24705 + : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \
24706 + : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \
24707 + : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \
24708 + : (abort (), (void) 0))
24711 +/* Byte swapping macros for file header data. */
24713 +#define bfd_h_put_8(abfd, val, ptr) \
24714 + bfd_put_8 (abfd, val, ptr)
24715 +#define bfd_h_put_signed_8(abfd, val, ptr) \
24716 + bfd_put_8 (abfd, val, ptr)
24717 +#define bfd_h_get_8(abfd, ptr) \
24718 + bfd_get_8 (abfd, ptr)
24719 +#define bfd_h_get_signed_8(abfd, ptr) \
24720 + bfd_get_signed_8 (abfd, ptr)
24722 +#define bfd_h_put_16(abfd, val, ptr) \
24723 + BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
24724 +#define bfd_h_put_signed_16 \
24726 +#define bfd_h_get_16(abfd, ptr) \
24727 + BFD_SEND (abfd, bfd_h_getx16, (ptr))
24728 +#define bfd_h_get_signed_16(abfd, ptr) \
24729 + BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
24731 +#define bfd_h_put_32(abfd, val, ptr) \
24732 + BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
24733 +#define bfd_h_put_signed_32 \
24735 +#define bfd_h_get_32(abfd, ptr) \
24736 + BFD_SEND (abfd, bfd_h_getx32, (ptr))
24737 +#define bfd_h_get_signed_32(abfd, ptr) \
24738 + BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
24740 +#define bfd_h_put_64(abfd, val, ptr) \
24741 + BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
24742 +#define bfd_h_put_signed_64 \
24744 +#define bfd_h_get_64(abfd, ptr) \
24745 + BFD_SEND (abfd, bfd_h_getx64, (ptr))
24746 +#define bfd_h_get_signed_64(abfd, ptr) \
24747 + BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
24749 +/* Aliases for the above, which should eventually go away. */
24751 +#define H_PUT_64 bfd_h_put_64
24752 +#define H_PUT_32 bfd_h_put_32
24753 +#define H_PUT_16 bfd_h_put_16
24754 +#define H_PUT_8 bfd_h_put_8
24755 +#define H_PUT_S64 bfd_h_put_signed_64
24756 +#define H_PUT_S32 bfd_h_put_signed_32
24757 +#define H_PUT_S16 bfd_h_put_signed_16
24758 +#define H_PUT_S8 bfd_h_put_signed_8
24759 +#define H_GET_64 bfd_h_get_64
24760 +#define H_GET_32 bfd_h_get_32
24761 +#define H_GET_16 bfd_h_get_16
24762 +#define H_GET_8 bfd_h_get_8
24763 +#define H_GET_S64 bfd_h_get_signed_64
24764 +#define H_GET_S32 bfd_h_get_signed_32
24765 +#define H_GET_S16 bfd_h_get_signed_16
24766 +#define H_GET_S8 bfd_h_get_signed_8
24769 +/* Extracted from bfdio.c. */
24770 +long bfd_get_mtime (bfd *abfd);
24772 +long bfd_get_size (bfd *abfd);
24774 +/* Extracted from bfdwin.c. */
24775 +/* Extracted from section.c. */
24776 +typedef struct bfd_section
24778 + /* The name of the section; the name isn't a copy, the pointer is
24779 + the same as that passed to bfd_make_section. */
24780 + const char *name;
24782 + /* A unique sequence number. */
24785 + /* Which section in the bfd; 0..n-1 as sections are created in a bfd. */
24788 + /* The next section in the list belonging to the BFD, or NULL. */
24789 + struct bfd_section *next;
24791 + /* The previous section in the list belonging to the BFD, or NULL. */
24792 + struct bfd_section *prev;
24794 + /* The field flags contains attributes of the section. Some
24795 + flags are read in from the object file, and some are
24796 + synthesized from other information. */
24799 +#define SEC_NO_FLAGS 0x000
24801 + /* Tells the OS to allocate space for this section when loading.
24802 + This is clear for a section containing debug information only. */
24803 +#define SEC_ALLOC 0x001
24805 + /* Tells the OS to load the section from the file when loading.
24806 + This is clear for a .bss section. */
24807 +#define SEC_LOAD 0x002
24809 + /* The section contains data still to be relocated, so there is
24810 + some relocation information too. */
24811 +#define SEC_RELOC 0x004
24813 + /* A signal to the OS that the section contains read only data. */
24814 +#define SEC_READONLY 0x008
24816 + /* The section contains code only. */
24817 +#define SEC_CODE 0x010
24819 + /* The section contains data only. */
24820 +#define SEC_DATA 0x020
24822 + /* The section will reside in ROM. */
24823 +#define SEC_ROM 0x040
24825 + /* The section contains constructor information. This section
24826 + type is used by the linker to create lists of constructors and
24827 + destructors used by <<g++>>. When a back end sees a symbol
24828 + which should be used in a constructor list, it creates a new
24829 + section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
24830 + the symbol to it, and builds a relocation. To build the lists
24831 + of constructors, all the linker has to do is catenate all the
24832 + sections called <<__CTOR_LIST__>> and relocate the data
24833 + contained within - exactly the operations it would peform on
24834 + standard data. */
24835 +#define SEC_CONSTRUCTOR 0x080
24837 + /* The section has contents - a data section could be
24838 + <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
24839 + <<SEC_HAS_CONTENTS>> */
24840 +#define SEC_HAS_CONTENTS 0x100
24842 + /* An instruction to the linker to not output the section
24843 + even if it has information which would normally be written. */
24844 +#define SEC_NEVER_LOAD 0x200
24846 + /* The section contains thread local data. */
24847 +#define SEC_THREAD_LOCAL 0x400
24849 + /* The section has GOT references. This flag is only for the
24850 + linker, and is currently only used by the elf32-hppa back end.
24851 + It will be set if global offset table references were detected
24852 + in this section, which indicate to the linker that the section
24853 + contains PIC code, and must be handled specially when doing a
24855 +#define SEC_HAS_GOT_REF 0x800
24857 + /* The section contains common symbols (symbols may be defined
24858 + multiple times, the value of a symbol is the amount of
24859 + space it requires, and the largest symbol value is the one
24860 + used). Most targets have exactly one of these (which we
24861 + translate to bfd_com_section_ptr), but ECOFF has two. */
24862 +#define SEC_IS_COMMON 0x1000
24864 + /* The section contains only debugging information. For
24865 + example, this is set for ELF .debug and .stab sections.
24866 + strip tests this flag to see if a section can be
24868 +#define SEC_DEBUGGING 0x2000
24870 + /* The contents of this section are held in memory pointed to
24871 + by the contents field. This is checked by bfd_get_section_contents,
24872 + and the data is retrieved from memory if appropriate. */
24873 +#define SEC_IN_MEMORY 0x4000
24875 + /* The contents of this section are to be excluded by the
24876 + linker for executable and shared objects unless those
24877 + objects are to be further relocated. */
24878 +#define SEC_EXCLUDE 0x8000
24880 + /* The contents of this section are to be sorted based on the sum of
24881 + the symbol and addend values specified by the associated relocation
24882 + entries. Entries without associated relocation entries will be
24883 + appended to the end of the section in an unspecified order. */
24884 +#define SEC_SORT_ENTRIES 0x10000
24886 + /* When linking, duplicate sections of the same name should be
24887 + discarded, rather than being combined into a single section as
24888 + is usually done. This is similar to how common symbols are
24889 + handled. See SEC_LINK_DUPLICATES below. */
24890 +#define SEC_LINK_ONCE 0x20000
24892 + /* If SEC_LINK_ONCE is set, this bitfield describes how the linker
24893 + should handle duplicate sections. */
24894 +#define SEC_LINK_DUPLICATES 0x40000
24896 + /* This value for SEC_LINK_DUPLICATES means that duplicate
24897 + sections with the same name should simply be discarded. */
24898 +#define SEC_LINK_DUPLICATES_DISCARD 0x0
24900 + /* This value for SEC_LINK_DUPLICATES means that the linker
24901 + should warn if there are any duplicate sections, although
24902 + it should still only link one copy. */
24903 +#define SEC_LINK_DUPLICATES_ONE_ONLY 0x80000
24905 + /* This value for SEC_LINK_DUPLICATES means that the linker
24906 + should warn if any duplicate sections are a different size. */
24907 +#define SEC_LINK_DUPLICATES_SAME_SIZE 0x100000
24909 + /* This value for SEC_LINK_DUPLICATES means that the linker
24910 + should warn if any duplicate sections contain different
24912 +#define SEC_LINK_DUPLICATES_SAME_CONTENTS \
24913 + (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE)
24915 + /* This section was created by the linker as part of dynamic
24916 + relocation or other arcane processing. It is skipped when
24917 + going through the first-pass output, trusting that someone
24918 + else up the line will take care of it later. */
24919 +#define SEC_LINKER_CREATED 0x200000
24921 + /* This section should not be subject to garbage collection. */
24922 +#define SEC_KEEP 0x400000
24924 + /* This section contains "short" data, and should be placed
24925 + "near" the GP. */
24926 +#define SEC_SMALL_DATA 0x800000
24928 + /* Attempt to merge identical entities in the section.
24929 + Entity size is given in the entsize field. */
24930 +#define SEC_MERGE 0x1000000
24932 + /* If given with SEC_MERGE, entities to merge are zero terminated
24933 + strings where entsize specifies character size instead of fixed
24935 +#define SEC_STRINGS 0x2000000
24937 + /* This section contains data about section groups. */
24938 +#define SEC_GROUP 0x4000000
24940 + /* The section is a COFF shared library section. This flag is
24941 + only for the linker. If this type of section appears in
24942 + the input file, the linker must copy it to the output file
24943 + without changing the vma or size. FIXME: Although this
24944 + was originally intended to be general, it really is COFF
24945 + specific (and the flag was renamed to indicate this). It
24946 + might be cleaner to have some more general mechanism to
24947 + allow the back end to control what the linker does with
24949 +#define SEC_COFF_SHARED_LIBRARY 0x10000000
24951 + /* This section contains data which may be shared with other
24952 + executables or shared objects. This is for COFF only. */
24953 +#define SEC_COFF_SHARED 0x20000000
24955 + /* When a section with this flag is being linked, then if the size of
24956 + the input section is less than a page, it should not cross a page
24957 + boundary. If the size of the input section is one page or more,
24958 + it should be aligned on a page boundary. This is for TI
24959 + TMS320C54X only. */
24960 +#define SEC_TIC54X_BLOCK 0x40000000
24962 + /* Conditionally link this section; do not link if there are no
24963 + references found to any symbol in the section. This is for TI
24964 + TMS320C54X only. */
24965 +#define SEC_TIC54X_CLINK 0x80000000
24967 + /* End of section flags. */
24969 + /* Some internal packed boolean fields. */
24971 + /* See the vma field. */
24972 + unsigned int user_set_vma : 1;
24974 + /* A mark flag used by some of the linker backends. */
24975 + unsigned int linker_mark : 1;
24977 + /* Another mark flag used by some of the linker backends. Set for
24978 + output sections that have an input section. */
24979 + unsigned int linker_has_input : 1;
24981 + /* Mark flags used by some linker backends for garbage collection. */
24982 + unsigned int gc_mark : 1;
24983 + unsigned int gc_mark_from_eh : 1;
24985 + /* The following flags are used by the ELF linker. */
24987 + /* Mark sections which have been allocated to segments. */
24988 + unsigned int segment_mark : 1;
24990 + /* Type of sec_info information. */
24991 + unsigned int sec_info_type:3;
24992 +#define ELF_INFO_TYPE_NONE 0
24993 +#define ELF_INFO_TYPE_STABS 1
24994 +#define ELF_INFO_TYPE_MERGE 2
24995 +#define ELF_INFO_TYPE_EH_FRAME 3
24996 +#define ELF_INFO_TYPE_JUST_SYMS 4
24998 + /* Nonzero if this section uses RELA relocations, rather than REL. */
24999 + unsigned int use_rela_p:1;
25001 + /* Bits used by various backends. The generic code doesn't touch
25004 + /* Nonzero if this section has TLS related relocations. */
25005 + unsigned int has_tls_reloc:1;
25007 + /* Nonzero if this section has a gp reloc. */
25008 + unsigned int has_gp_reloc:1;
25010 + /* Nonzero if this section needs the relax finalize pass. */
25011 + unsigned int need_finalize_relax:1;
25013 + /* Whether relocations have been processed. */
25014 + unsigned int reloc_done : 1;
25016 + /* End of internal packed boolean fields. */
25018 + /* The virtual memory address of the section - where it will be
25019 + at run time. The symbols are relocated against this. The
25020 + user_set_vma flag is maintained by bfd; if it's not set, the
25021 + backend can assign addresses (for example, in <<a.out>>, where
25022 + the default address for <<.data>> is dependent on the specific
25023 + target and various flags). */
25026 + /* The load address of the section - where it would be in a
25027 + rom image; really only used for writing section header
25031 + /* The size of the section in octets, as it will be output.
25032 + Contains a value even if the section has no contents (e.g., the
25033 + size of <<.bss>>). */
25034 + bfd_size_type size;
25036 + /* For input sections, the original size on disk of the section, in
25037 + octets. This field is used by the linker relaxation code. It is
25038 + currently only set for sections where the linker relaxation scheme
25039 + doesn't cache altered section and reloc contents (stabs, eh_frame,
25040 + SEC_MERGE, some coff relaxing targets), and thus the original size
25041 + needs to be kept to read the section multiple times.
25042 + For output sections, rawsize holds the section size calculated on
25043 + a previous linker relaxation pass. */
25044 + bfd_size_type rawsize;
25046 + /* If this section is going to be output, then this value is the
25047 + offset in *bytes* into the output section of the first byte in the
25048 + input section (byte ==> smallest addressable unit on the
25049 + target). In most cases, if this was going to start at the
25050 + 100th octet (8-bit quantity) in the output section, this value
25051 + would be 100. However, if the target byte size is 16 bits
25052 + (bfd_octets_per_byte is "2"), this value would be 50. */
25053 + bfd_vma output_offset;
25055 + /* The output section through which to map on output. */
25056 + struct bfd_section *output_section;
25058 + /* The alignment requirement of the section, as an exponent of 2 -
25059 + e.g., 3 aligns to 2^3 (or 8). */
25060 + unsigned int alignment_power;
25062 + /* If an input section, a pointer to a vector of relocation
25063 + records for the data in this section. */
25064 + struct reloc_cache_entry *relocation;
25066 + /* If an output section, a pointer to a vector of pointers to
25067 + relocation records for the data in this section. */
25068 + struct reloc_cache_entry **orelocation;
25070 + /* The number of relocation records in one of the above. */
25071 + unsigned reloc_count;
25073 + /* Information below is back end specific - and not always used
25076 + /* File position of section data. */
25077 + file_ptr filepos;
25079 + /* File position of relocation info. */
25080 + file_ptr rel_filepos;
25082 + /* File position of line data. */
25083 + file_ptr line_filepos;
25085 + /* Pointer to data for applications. */
25088 + /* If the SEC_IN_MEMORY flag is set, this points to the actual
25090 + unsigned char *contents;
25092 + /* Attached line number information. */
25095 + /* Number of line number records. */
25096 + unsigned int lineno_count;
25098 + /* Entity size for merging purposes. */
25099 + unsigned int entsize;
25101 + /* Points to the kept section if this section is a link-once section,
25102 + and is discarded. */
25103 + struct bfd_section *kept_section;
25105 + /* When a section is being output, this value changes as more
25106 + linenumbers are written out. */
25107 + file_ptr moving_line_filepos;
25109 + /* What the section number is in the target world. */
25110 + int target_index;
25112 + void *used_by_bfd;
25114 + /* If this is a constructor section then here is a list of the
25115 + relocations created to relocate items within it. */
25116 + struct relent_chain *constructor_chain;
25118 + /* The BFD which owns the section. */
25121 + /* A symbol which points at this section only. */
25122 + struct bfd_symbol *symbol;
25123 + struct bfd_symbol **symbol_ptr_ptr;
25125 + /* Early in the link process, map_head and map_tail are used to build
25126 + a list of input sections attached to an output section. Later,
25127 + output sections use these fields for a list of bfd_link_order
25130 + struct bfd_link_order *link_order;
25131 + struct bfd_section *s;
25132 + } map_head, map_tail;
25135 +/* These sections are global, and are managed by BFD. The application
25136 + and target back end are not permitted to change the values in
25137 + these sections. New code should use the section_ptr macros rather
25138 + than referring directly to the const sections. The const sections
25139 + may eventually vanish. */
25140 +#define BFD_ABS_SECTION_NAME "*ABS*"
25141 +#define BFD_UND_SECTION_NAME "*UND*"
25142 +#define BFD_COM_SECTION_NAME "*COM*"
25143 +#define BFD_IND_SECTION_NAME "*IND*"
25145 +/* The absolute section. */
25146 +extern asection bfd_abs_section;
25147 +#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
25148 +#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
25149 +/* Pointer to the undefined section. */
25150 +extern asection bfd_und_section;
25151 +#define bfd_und_section_ptr ((asection *) &bfd_und_section)
25152 +#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
25153 +/* Pointer to the common section. */
25154 +extern asection bfd_com_section;
25155 +#define bfd_com_section_ptr ((asection *) &bfd_com_section)
25156 +/* Pointer to the indirect section. */
25157 +extern asection bfd_ind_section;
25158 +#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
25159 +#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
25161 +#define bfd_is_const_section(SEC) \
25162 + ( ((SEC) == bfd_abs_section_ptr) \
25163 + || ((SEC) == bfd_und_section_ptr) \
25164 + || ((SEC) == bfd_com_section_ptr) \
25165 + || ((SEC) == bfd_ind_section_ptr))
25167 +extern const struct bfd_symbol * const bfd_abs_symbol;
25168 +extern const struct bfd_symbol * const bfd_com_symbol;
25169 +extern const struct bfd_symbol * const bfd_und_symbol;
25170 +extern const struct bfd_symbol * const bfd_ind_symbol;
25172 +/* Macros to handle insertion and deletion of a bfd's sections. These
25173 + only handle the list pointers, ie. do not adjust section_count,
25174 + target_index etc. */
25175 +#define bfd_section_list_remove(ABFD, S) \
25178 + asection *_s = S; \
25179 + asection *_next = _s->next; \
25180 + asection *_prev = _s->prev; \
25182 + _prev->next = _next; \
25184 + (ABFD)->sections = _next; \
25186 + _next->prev = _prev; \
25188 + (ABFD)->section_last = _prev; \
25191 +#define bfd_section_list_append(ABFD, S) \
25194 + asection *_s = S; \
25195 + bfd *_abfd = ABFD; \
25196 + _s->next = NULL; \
25197 + if (_abfd->section_last) \
25199 + _s->prev = _abfd->section_last; \
25200 + _abfd->section_last->next = _s; \
25204 + _s->prev = NULL; \
25205 + _abfd->sections = _s; \
25207 + _abfd->section_last = _s; \
25210 +#define bfd_section_list_prepend(ABFD, S) \
25213 + asection *_s = S; \
25214 + bfd *_abfd = ABFD; \
25215 + _s->prev = NULL; \
25216 + if (_abfd->sections) \
25218 + _s->next = _abfd->sections; \
25219 + _abfd->sections->prev = _s; \
25223 + _s->next = NULL; \
25224 + _abfd->section_last = _s; \
25226 + _abfd->sections = _s; \
25229 +#define bfd_section_list_insert_after(ABFD, A, S) \
25232 + asection *_a = A; \
25233 + asection *_s = S; \
25234 + asection *_next = _a->next; \
25235 + _s->next = _next; \
25239 + _next->prev = _s; \
25241 + (ABFD)->section_last = _s; \
25244 +#define bfd_section_list_insert_before(ABFD, B, S) \
25247 + asection *_b = B; \
25248 + asection *_s = S; \
25249 + asection *_prev = _b->prev; \
25250 + _s->prev = _prev; \
25254 + _prev->next = _s; \
25256 + (ABFD)->sections = _s; \
25259 +#define bfd_section_removed_from_list(ABFD, S) \
25260 + ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S))
25262 +void bfd_section_list_clear (bfd *);
25264 +asection *bfd_get_section_by_name (bfd *abfd, const char *name);
25266 +asection *bfd_get_section_by_name_if
25268 + const char *name,
25269 + bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj),
25272 +char *bfd_get_unique_section_name
25273 + (bfd *abfd, const char *templat, int *count);
25275 +asection *bfd_make_section_old_way (bfd *abfd, const char *name);
25277 +asection *bfd_make_section_anyway_with_flags
25278 + (bfd *abfd, const char *name, flagword flags);
25280 +asection *bfd_make_section_anyway (bfd *abfd, const char *name);
25282 +asection *bfd_make_section_with_flags
25283 + (bfd *, const char *name, flagword flags);
25285 +asection *bfd_make_section (bfd *, const char *name);
25287 +bfd_boolean bfd_set_section_flags
25288 + (bfd *abfd, asection *sec, flagword flags);
25290 +void bfd_map_over_sections
25292 + void (*func) (bfd *abfd, asection *sect, void *obj),
25295 +asection *bfd_sections_find_if
25297 + bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj),
25300 +bfd_boolean bfd_set_section_size
25301 + (bfd *abfd, asection *sec, bfd_size_type val);
25303 +bfd_boolean bfd_set_section_contents
25304 + (bfd *abfd, asection *section, const void *data,
25305 + file_ptr offset, bfd_size_type count);
25307 +bfd_boolean bfd_get_section_contents
25308 + (bfd *abfd, asection *section, void *location, file_ptr offset,
25309 + bfd_size_type count);
25311 +bfd_boolean bfd_malloc_and_get_section
25312 + (bfd *abfd, asection *section, bfd_byte **buf);
25314 +bfd_boolean bfd_copy_private_section_data
25315 + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
25317 +#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
25318 + BFD_SEND (obfd, _bfd_copy_private_section_data, \
25319 + (ibfd, isection, obfd, osection))
25320 +bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec);
25322 +bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group);
25324 +/* Extracted from archures.c. */
25325 +enum bfd_architecture
25327 + bfd_arch_unknown, /* File arch not known. */
25328 + bfd_arch_obscure, /* Arch known, not one of these. */
25329 + bfd_arch_m68k, /* Motorola 68xxx */
25330 +#define bfd_mach_m68000 1
25331 +#define bfd_mach_m68008 2
25332 +#define bfd_mach_m68010 3
25333 +#define bfd_mach_m68020 4
25334 +#define bfd_mach_m68030 5
25335 +#define bfd_mach_m68040 6
25336 +#define bfd_mach_m68060 7
25337 +#define bfd_mach_cpu32 8
25338 +#define bfd_mach_mcf5200 9
25339 +#define bfd_mach_mcf5206e 10
25340 +#define bfd_mach_mcf5307 11
25341 +#define bfd_mach_mcf5407 12
25342 +#define bfd_mach_mcf528x 13
25343 +#define bfd_mach_mcfv4e 14
25344 +#define bfd_mach_mcf521x 15
25345 +#define bfd_mach_mcf5249 16
25346 +#define bfd_mach_mcf547x 17
25347 +#define bfd_mach_mcf548x 18
25348 + bfd_arch_vax, /* DEC Vax */
25349 + bfd_arch_i960, /* Intel 960 */
25350 + /* The order of the following is important.
25351 + lower number indicates a machine type that
25352 + only accepts a subset of the instructions
25353 + available to machines with higher numbers.
25354 + The exception is the "ca", which is
25355 + incompatible with all other machines except
25358 +#define bfd_mach_i960_core 1
25359 +#define bfd_mach_i960_ka_sa 2
25360 +#define bfd_mach_i960_kb_sb 3
25361 +#define bfd_mach_i960_mc 4
25362 +#define bfd_mach_i960_xa 5
25363 +#define bfd_mach_i960_ca 6
25364 +#define bfd_mach_i960_jx 7
25365 +#define bfd_mach_i960_hx 8
25367 + bfd_arch_or32, /* OpenRISC 32 */
25369 + bfd_arch_a29k, /* AMD 29000 */
25370 + bfd_arch_sparc, /* SPARC */
25371 +#define bfd_mach_sparc 1
25372 +/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */
25373 +#define bfd_mach_sparc_sparclet 2
25374 +#define bfd_mach_sparc_sparclite 3
25375 +#define bfd_mach_sparc_v8plus 4
25376 +#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns. */
25377 +#define bfd_mach_sparc_sparclite_le 6
25378 +#define bfd_mach_sparc_v9 7
25379 +#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns. */
25380 +#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns. */
25381 +#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns. */
25382 +/* Nonzero if MACH has the v9 instruction set. */
25383 +#define bfd_mach_sparc_v9_p(mach) \
25384 + ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \
25385 + && (mach) != bfd_mach_sparc_sparclite_le)
25386 +/* Nonzero if MACH is a 64 bit sparc architecture. */
25387 +#define bfd_mach_sparc_64bit_p(mach) \
25388 + ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb)
25389 + bfd_arch_mips, /* MIPS Rxxxx */
25390 +#define bfd_mach_mips3000 3000
25391 +#define bfd_mach_mips3900 3900
25392 +#define bfd_mach_mips4000 4000
25393 +#define bfd_mach_mips4010 4010
25394 +#define bfd_mach_mips4100 4100
25395 +#define bfd_mach_mips4111 4111
25396 +#define bfd_mach_mips4120 4120
25397 +#define bfd_mach_mips4300 4300
25398 +#define bfd_mach_mips4400 4400
25399 +#define bfd_mach_mips4600 4600
25400 +#define bfd_mach_mips4650 4650
25401 +#define bfd_mach_mips5000 5000
25402 +#define bfd_mach_mips5400 5400
25403 +#define bfd_mach_mips5500 5500
25404 +#define bfd_mach_mips6000 6000
25405 +#define bfd_mach_mips7000 7000
25406 +#define bfd_mach_mips8000 8000
25407 +#define bfd_mach_mips9000 9000
25408 +#define bfd_mach_mips10000 10000
25409 +#define bfd_mach_mips12000 12000
25410 +#define bfd_mach_mips16 16
25411 +#define bfd_mach_mips5 5
25412 +#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01 */
25413 +#define bfd_mach_mipsisa32 32
25414 +#define bfd_mach_mipsisa32r2 33
25415 +#define bfd_mach_mipsisa64 64
25416 +#define bfd_mach_mipsisa64r2 65
25417 + bfd_arch_i386, /* Intel 386 */
25418 +#define bfd_mach_i386_i386 1
25419 +#define bfd_mach_i386_i8086 2
25420 +#define bfd_mach_i386_i386_intel_syntax 3
25421 +#define bfd_mach_x86_64 64
25422 +#define bfd_mach_x86_64_intel_syntax 65
25423 + bfd_arch_we32k, /* AT&T WE32xxx */
25424 + bfd_arch_tahoe, /* CCI/Harris Tahoe */
25425 + bfd_arch_i860, /* Intel 860 */
25426 + bfd_arch_i370, /* IBM 360/370 Mainframes */
25427 + bfd_arch_romp, /* IBM ROMP PC/RT */
25428 + bfd_arch_alliant, /* Alliant */
25429 + bfd_arch_convex, /* Convex */
25430 + bfd_arch_m88k, /* Motorola 88xxx */
25431 + bfd_arch_m98k, /* Motorola 98xxx */
25432 + bfd_arch_pyramid, /* Pyramid Technology */
25433 + bfd_arch_h8300, /* Renesas H8/300 (formerly Hitachi H8/300) */
25434 +#define bfd_mach_h8300 1
25435 +#define bfd_mach_h8300h 2
25436 +#define bfd_mach_h8300s 3
25437 +#define bfd_mach_h8300hn 4
25438 +#define bfd_mach_h8300sn 5
25439 +#define bfd_mach_h8300sx 6
25440 +#define bfd_mach_h8300sxn 7
25441 + bfd_arch_pdp11, /* DEC PDP-11 */
25442 + bfd_arch_powerpc, /* PowerPC */
25443 +#define bfd_mach_ppc 32
25444 +#define bfd_mach_ppc64 64
25445 +#define bfd_mach_ppc_403 403
25446 +#define bfd_mach_ppc_403gc 4030
25447 +#define bfd_mach_ppc_505 505
25448 +#define bfd_mach_ppc_601 601
25449 +#define bfd_mach_ppc_602 602
25450 +#define bfd_mach_ppc_603 603
25451 +#define bfd_mach_ppc_ec603e 6031
25452 +#define bfd_mach_ppc_604 604
25453 +#define bfd_mach_ppc_620 620
25454 +#define bfd_mach_ppc_630 630
25455 +#define bfd_mach_ppc_750 750
25456 +#define bfd_mach_ppc_860 860
25457 +#define bfd_mach_ppc_a35 35
25458 +#define bfd_mach_ppc_rs64ii 642
25459 +#define bfd_mach_ppc_rs64iii 643
25460 +#define bfd_mach_ppc_7400 7400
25461 +#define bfd_mach_ppc_e500 500
25462 + bfd_arch_rs6000, /* IBM RS/6000 */
25463 +#define bfd_mach_rs6k 6000
25464 +#define bfd_mach_rs6k_rs1 6001
25465 +#define bfd_mach_rs6k_rsc 6003
25466 +#define bfd_mach_rs6k_rs2 6002
25467 + bfd_arch_hppa, /* HP PA RISC */
25468 +#define bfd_mach_hppa10 10
25469 +#define bfd_mach_hppa11 11
25470 +#define bfd_mach_hppa20 20
25471 +#define bfd_mach_hppa20w 25
25472 + bfd_arch_d10v, /* Mitsubishi D10V */
25473 +#define bfd_mach_d10v 1
25474 +#define bfd_mach_d10v_ts2 2
25475 +#define bfd_mach_d10v_ts3 3
25476 + bfd_arch_d30v, /* Mitsubishi D30V */
25477 + bfd_arch_dlx, /* DLX */
25478 + bfd_arch_m68hc11, /* Motorola 68HC11 */
25479 + bfd_arch_m68hc12, /* Motorola 68HC12 */
25480 +#define bfd_mach_m6812_default 0
25481 +#define bfd_mach_m6812 1
25482 +#define bfd_mach_m6812s 2
25483 + bfd_arch_z8k, /* Zilog Z8000 */
25484 +#define bfd_mach_z8001 1
25485 +#define bfd_mach_z8002 2
25486 + bfd_arch_h8500, /* Renesas H8/500 (formerly Hitachi H8/500) */
25487 + bfd_arch_sh, /* Renesas / SuperH SH (formerly Hitachi SH) */
25488 +#define bfd_mach_sh 1
25489 +#define bfd_mach_sh2 0x20
25490 +#define bfd_mach_sh_dsp 0x2d
25491 +#define bfd_mach_sh2a 0x2a
25492 +#define bfd_mach_sh2a_nofpu 0x2b
25493 +#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1
25494 +#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2
25495 +#define bfd_mach_sh2a_or_sh4 0x2a3
25496 +#define bfd_mach_sh2a_or_sh3e 0x2a4
25497 +#define bfd_mach_sh2e 0x2e
25498 +#define bfd_mach_sh3 0x30
25499 +#define bfd_mach_sh3_nommu 0x31
25500 +#define bfd_mach_sh3_dsp 0x3d
25501 +#define bfd_mach_sh3e 0x3e
25502 +#define bfd_mach_sh4 0x40
25503 +#define bfd_mach_sh4_nofpu 0x41
25504 +#define bfd_mach_sh4_nommu_nofpu 0x42
25505 +#define bfd_mach_sh4a 0x4a
25506 +#define bfd_mach_sh4a_nofpu 0x4b
25507 +#define bfd_mach_sh4al_dsp 0x4d
25508 +#define bfd_mach_sh5 0x50
25509 + bfd_arch_alpha, /* Dec Alpha */
25510 +#define bfd_mach_alpha_ev4 0x10
25511 +#define bfd_mach_alpha_ev5 0x20
25512 +#define bfd_mach_alpha_ev6 0x30
25513 + bfd_arch_arm, /* Advanced Risc Machines ARM. */
25514 +#define bfd_mach_arm_unknown 0
25515 +#define bfd_mach_arm_2 1
25516 +#define bfd_mach_arm_2a 2
25517 +#define bfd_mach_arm_3 3
25518 +#define bfd_mach_arm_3M 4
25519 +#define bfd_mach_arm_4 5
25520 +#define bfd_mach_arm_4T 6
25521 +#define bfd_mach_arm_5 7
25522 +#define bfd_mach_arm_5T 8
25523 +#define bfd_mach_arm_5TE 9
25524 +#define bfd_mach_arm_XScale 10
25525 +#define bfd_mach_arm_ep9312 11
25526 +#define bfd_mach_arm_iWMMXt 12
25527 + bfd_arch_ns32k, /* National Semiconductors ns32000 */
25528 + bfd_arch_w65, /* WDC 65816 */
25529 + bfd_arch_tic30, /* Texas Instruments TMS320C30 */
25530 + bfd_arch_tic4x, /* Texas Instruments TMS320C3X/4X */
25531 +#define bfd_mach_tic3x 30
25532 +#define bfd_mach_tic4x 40
25533 + bfd_arch_tic54x, /* Texas Instruments TMS320C54X */
25534 + bfd_arch_tic80, /* TI TMS320c80 (MVP) */
25535 + bfd_arch_v850, /* NEC V850 */
25536 +#define bfd_mach_v850 1
25537 +#define bfd_mach_v850e 'E'
25538 +#define bfd_mach_v850e1 '1'
25539 + bfd_arch_arc, /* ARC Cores */
25540 +#define bfd_mach_arc_5 5
25541 +#define bfd_mach_arc_6 6
25542 +#define bfd_mach_arc_7 7
25543 +#define bfd_mach_arc_8 8
25544 + bfd_arch_m32c, /* Renesas M16C/M32C. */
25545 +#define bfd_mach_m16c 0x75
25546 +#define bfd_mach_m32c 0x78
25547 + bfd_arch_m32r, /* Renesas M32R (formerly Mitsubishi M32R/D) */
25548 +#define bfd_mach_m32r 1 /* For backwards compatibility. */
25549 +#define bfd_mach_m32rx 'x'
25550 +#define bfd_mach_m32r2 '2'
25551 + bfd_arch_mn10200, /* Matsushita MN10200 */
25552 + bfd_arch_mn10300, /* Matsushita MN10300 */
25553 +#define bfd_mach_mn10300 300
25554 +#define bfd_mach_am33 330
25555 +#define bfd_mach_am33_2 332
25557 +#define bfd_mach_fr30 0x46523330
25559 +#define bfd_mach_frv 1
25560 +#define bfd_mach_frvsimple 2
25561 +#define bfd_mach_fr300 300
25562 +#define bfd_mach_fr400 400
25563 +#define bfd_mach_fr450 450
25564 +#define bfd_mach_frvtomcat 499 /* fr500 prototype */
25565 +#define bfd_mach_fr500 500
25566 +#define bfd_mach_fr550 550
25568 + bfd_arch_ia64, /* HP/Intel ia64 */
25569 +#define bfd_mach_ia64_elf64 64
25570 +#define bfd_mach_ia64_elf32 32
25571 + bfd_arch_ip2k, /* Ubicom IP2K microcontrollers. */
25572 +#define bfd_mach_ip2022 1
25573 +#define bfd_mach_ip2022ext 2
25574 + bfd_arch_iq2000, /* Vitesse IQ2000. */
25575 +#define bfd_mach_iq2000 1
25576 +#define bfd_mach_iq10 2
25578 +#define bfd_mach_ms1 1
25579 +#define bfd_mach_mrisc2 2
25581 + bfd_arch_avr, /* Atmel AVR microcontrollers. */
25582 +#define bfd_mach_avr1 1
25583 +#define bfd_mach_avr2 2
25584 +#define bfd_mach_avr3 3
25585 +#define bfd_mach_avr4 4
25586 +#define bfd_mach_avr5 5
25587 + bfd_arch_cr16c, /* National Semiconductor CompactRISC. */
25588 +#define bfd_mach_cr16c 1
25589 + bfd_arch_crx, /* National Semiconductor CRX. */
25590 +#define bfd_mach_crx 1
25591 + bfd_arch_cris, /* Axis CRIS */
25592 +#define bfd_mach_cris_v0_v10 255
25593 +#define bfd_mach_cris_v32 32
25594 +#define bfd_mach_cris_v10_v32 1032
25595 + bfd_arch_s390, /* IBM s390 */
25596 +#define bfd_mach_s390_31 31
25597 +#define bfd_mach_s390_64 64
25598 + bfd_arch_openrisc, /* OpenRISC */
25599 + bfd_arch_mmix, /* Donald Knuth's educational processor. */
25600 + bfd_arch_xstormy16,
25601 +#define bfd_mach_xstormy16 1
25602 + bfd_arch_msp430, /* Texas Instruments MSP430 architecture. */
25603 +#define bfd_mach_msp11 11
25604 +#define bfd_mach_msp110 110
25605 +#define bfd_mach_msp12 12
25606 +#define bfd_mach_msp13 13
25607 +#define bfd_mach_msp14 14
25608 +#define bfd_mach_msp15 15
25609 +#define bfd_mach_msp16 16
25610 +#define bfd_mach_msp31 31
25611 +#define bfd_mach_msp32 32
25612 +#define bfd_mach_msp33 33
25613 +#define bfd_mach_msp41 41
25614 +#define bfd_mach_msp42 42
25615 +#define bfd_mach_msp43 43
25616 +#define bfd_mach_msp44 44
25617 + bfd_arch_xtensa, /* Tensilica's Xtensa cores. */
25618 +#define bfd_mach_xtensa 1
25619 + bfd_arch_maxq, /* Dallas MAXQ 10/20 */
25620 +#define bfd_mach_maxq10 10
25621 +#define bfd_mach_maxq20 20
25625 +typedef struct bfd_arch_info
25627 + int bits_per_word;
25628 + int bits_per_address;
25629 + int bits_per_byte;
25630 + enum bfd_architecture arch;
25631 + unsigned long mach;
25632 + const char *arch_name;
25633 + const char *printable_name;
25634 + unsigned int section_align_power;
25635 + /* TRUE if this is the default machine for the architecture.
25636 + The default arch should be the first entry for an arch so that
25637 + all the entries for that arch can be accessed via <<next>>. */
25638 + bfd_boolean the_default;
25639 + const struct bfd_arch_info * (*compatible)
25640 + (const struct bfd_arch_info *a, const struct bfd_arch_info *b);
25642 + bfd_boolean (*scan) (const struct bfd_arch_info *, const char *);
25644 + const struct bfd_arch_info *next;
25646 +bfd_arch_info_type;
25648 +const char *bfd_printable_name (bfd *abfd);
25650 +const bfd_arch_info_type *bfd_scan_arch (const char *string);
25652 +const char **bfd_arch_list (void);
25654 +const bfd_arch_info_type *bfd_arch_get_compatible
25655 + (const bfd *abfd, const bfd *bbfd, bfd_boolean accept_unknowns);
25657 +void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg);
25659 +enum bfd_architecture bfd_get_arch (bfd *abfd);
25661 +unsigned long bfd_get_mach (bfd *abfd);
25663 +unsigned int bfd_arch_bits_per_byte (bfd *abfd);
25665 +unsigned int bfd_arch_bits_per_address (bfd *abfd);
25667 +const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd);
25669 +const bfd_arch_info_type *bfd_lookup_arch
25670 + (enum bfd_architecture arch, unsigned long machine);
25672 +const char *bfd_printable_arch_mach
25673 + (enum bfd_architecture arch, unsigned long machine);
25675 +unsigned int bfd_octets_per_byte (bfd *abfd);
25677 +unsigned int bfd_arch_mach_octets_per_byte
25678 + (enum bfd_architecture arch, unsigned long machine);
25680 +/* Extracted from reloc.c. */
25681 +typedef enum bfd_reloc_status
25683 + /* No errors detected. */
25686 + /* The relocation was performed, but there was an overflow. */
25687 + bfd_reloc_overflow,
25689 + /* The address to relocate was not within the section supplied. */
25690 + bfd_reloc_outofrange,
25692 + /* Used by special functions. */
25693 + bfd_reloc_continue,
25695 + /* Unsupported relocation size requested. */
25696 + bfd_reloc_notsupported,
25701 + /* The symbol to relocate against was undefined. */
25702 + bfd_reloc_undefined,
25704 + /* The relocation was performed, but may not be ok - presently
25705 + generated only when linking i960 coff files with i960 b.out
25706 + symbols. If this type is returned, the error_message argument
25707 + to bfd_perform_relocation will be set. */
25708 + bfd_reloc_dangerous
25710 + bfd_reloc_status_type;
25713 +typedef struct reloc_cache_entry
25715 + /* A pointer into the canonical table of pointers. */
25716 + struct bfd_symbol **sym_ptr_ptr;
25718 + /* offset in section. */
25719 + bfd_size_type address;
25721 + /* addend for relocation value. */
25724 + /* Pointer to how to perform the required relocation. */
25725 + reloc_howto_type *howto;
25730 +enum complain_overflow
25732 + /* Do not complain on overflow. */
25733 + complain_overflow_dont,
25735 + /* Complain if the bitfield overflows, whether it is considered
25736 + as signed or unsigned. */
25737 + complain_overflow_bitfield,
25739 + /* Complain if the value overflows when considered as signed
25741 + complain_overflow_signed,
25743 + /* Complain if the value overflows when considered as an
25744 + unsigned number. */
25745 + complain_overflow_unsigned
25748 +struct reloc_howto_struct
25750 + /* The type field has mainly a documentary use - the back end can
25751 + do what it wants with it, though normally the back end's
25752 + external idea of what a reloc number is stored
25753 + in this field. For example, a PC relative word relocation
25754 + in a coff environment has the type 023 - because that's
25755 + what the outside world calls a R_PCRWORD reloc. */
25756 + unsigned int type;
25758 + /* The value the final relocation is shifted right by. This drops
25759 + unwanted data from the relocation. */
25760 + unsigned int rightshift;
25762 + /* The size of the item to be relocated. This is *not* a
25763 + power-of-two measure. To get the number of bytes operated
25764 + on by a type of relocation, use bfd_get_reloc_size. */
25767 + /* The number of bits in the item to be relocated. This is used
25768 + when doing overflow checking. */
25769 + unsigned int bitsize;
25771 + /* Notes that the relocation is relative to the location in the
25772 + data section of the addend. The relocation function will
25773 + subtract from the relocation value the address of the location
25774 + being relocated. */
25775 + bfd_boolean pc_relative;
25777 + /* The bit position of the reloc value in the destination.
25778 + The relocated value is left shifted by this amount. */
25779 + unsigned int bitpos;
25781 + /* What type of overflow error should be checked for when
25783 + enum complain_overflow complain_on_overflow;
25785 + /* If this field is non null, then the supplied function is
25786 + called rather than the normal function. This allows really
25787 + strange relocation methods to be accommodated (e.g., i960 callj
25788 + instructions). */
25789 + bfd_reloc_status_type (*special_function)
25790 + (bfd *, arelent *, struct bfd_symbol *, void *, asection *,
25793 + /* The textual name of the relocation type. */
25796 + /* Some formats record a relocation addend in the section contents
25797 + rather than with the relocation. For ELF formats this is the
25798 + distinction between USE_REL and USE_RELA (though the code checks
25799 + for USE_REL == 1/0). The value of this field is TRUE if the
25800 + addend is recorded with the section contents; when performing a
25801 + partial link (ld -r) the section contents (the data) will be
25802 + modified. The value of this field is FALSE if addends are
25803 + recorded with the relocation (in arelent.addend); when performing
25804 + a partial link the relocation will be modified.
25805 + All relocations for all ELF USE_RELA targets should set this field
25806 + to FALSE (values of TRUE should be looked on with suspicion).
25807 + However, the converse is not true: not all relocations of all ELF
25808 + USE_REL targets set this field to TRUE. Why this is so is peculiar
25809 + to each particular target. For relocs that aren't used in partial
25810 + links (e.g. GOT stuff) it doesn't matter what this is set to. */
25811 + bfd_boolean partial_inplace;
25813 + /* src_mask selects the part of the instruction (or data) to be used
25814 + in the relocation sum. If the target relocations don't have an
25815 + addend in the reloc, eg. ELF USE_REL, src_mask will normally equal
25816 + dst_mask to extract the addend from the section contents. If
25817 + relocations do have an addend in the reloc, eg. ELF USE_RELA, this
25818 + field should be zero. Non-zero values for ELF USE_RELA targets are
25819 + bogus as in those cases the value in the dst_mask part of the
25820 + section contents should be treated as garbage. */
25821 + bfd_vma src_mask;
25823 + /* dst_mask selects which parts of the instruction (or data) are
25824 + replaced with a relocated value. */
25825 + bfd_vma dst_mask;
25827 + /* When some formats create PC relative instructions, they leave
25828 + the value of the pc of the place being relocated in the offset
25829 + slot of the instruction, so that a PC relative relocation can
25830 + be made just by adding in an ordinary offset (e.g., sun3 a.out).
25831 + Some formats leave the displacement part of an instruction
25832 + empty (e.g., m88k bcs); this flag signals the fact. */
25833 + bfd_boolean pcrel_offset;
25836 +#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
25837 + { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC }
25838 +#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \
25839 + HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \
25840 + NAME, FALSE, 0, 0, IN)
25842 +#define EMPTY_HOWTO(C) \
25843 + HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \
25844 + NULL, FALSE, 0, 0, FALSE)
25846 +#define HOWTO_PREPARE(relocation, symbol) \
25848 + if (symbol != NULL) \
25850 + if (bfd_is_com_section (symbol->section)) \
25852 + relocation = 0; \
25856 + relocation = symbol->value; \
25861 +unsigned int bfd_get_reloc_size (reloc_howto_type *);
25863 +typedef struct relent_chain
25866 + struct relent_chain *next;
25870 +bfd_reloc_status_type bfd_check_overflow
25871 + (enum complain_overflow how,
25872 + unsigned int bitsize,
25873 + unsigned int rightshift,
25874 + unsigned int addrsize,
25875 + bfd_vma relocation);
25877 +bfd_reloc_status_type bfd_perform_relocation
25879 + arelent *reloc_entry,
25881 + asection *input_section,
25883 + char **error_message);
25885 +bfd_reloc_status_type bfd_install_relocation
25887 + arelent *reloc_entry,
25888 + void *data, bfd_vma data_start,
25889 + asection *input_section,
25890 + char **error_message);
25892 +enum bfd_reloc_code_real {
25893 + _dummy_first_bfd_reloc_code_real,
25896 +/* Basic absolute relocations of N bits. */
25905 +/* PC-relative relocations. Sometimes these are relative to the address
25906 +of the relocation itself; sometimes they are relative to the start of
25907 +the section containing the relocation. It depends on the specific target.
25909 +The 24-bit relocation is used in some Intel 960 configurations. */
25910 + BFD_RELOC_64_PCREL,
25911 + BFD_RELOC_32_PCREL,
25912 + BFD_RELOC_24_PCREL,
25913 + BFD_RELOC_16_PCREL,
25914 + BFD_RELOC_12_PCREL,
25915 + BFD_RELOC_8_PCREL,
25917 +/* Section relative relocations. Some targets need this for DWARF2. */
25918 + BFD_RELOC_32_SECREL,
25921 + BFD_RELOC_32_GOT_PCREL,
25922 + BFD_RELOC_16_GOT_PCREL,
25923 + BFD_RELOC_8_GOT_PCREL,
25924 + BFD_RELOC_32_GOTOFF,
25925 + BFD_RELOC_16_GOTOFF,
25926 + BFD_RELOC_LO16_GOTOFF,
25927 + BFD_RELOC_HI16_GOTOFF,
25928 + BFD_RELOC_HI16_S_GOTOFF,
25929 + BFD_RELOC_8_GOTOFF,
25930 + BFD_RELOC_64_PLT_PCREL,
25931 + BFD_RELOC_32_PLT_PCREL,
25932 + BFD_RELOC_24_PLT_PCREL,
25933 + BFD_RELOC_16_PLT_PCREL,
25934 + BFD_RELOC_8_PLT_PCREL,
25935 + BFD_RELOC_64_PLTOFF,
25936 + BFD_RELOC_32_PLTOFF,
25937 + BFD_RELOC_16_PLTOFF,
25938 + BFD_RELOC_LO16_PLTOFF,
25939 + BFD_RELOC_HI16_PLTOFF,
25940 + BFD_RELOC_HI16_S_PLTOFF,
25941 + BFD_RELOC_8_PLTOFF,
25943 +/* Relocations used by 68K ELF. */
25944 + BFD_RELOC_68K_GLOB_DAT,
25945 + BFD_RELOC_68K_JMP_SLOT,
25946 + BFD_RELOC_68K_RELATIVE,
25948 +/* Linkage-table relative. */
25949 + BFD_RELOC_32_BASEREL,
25950 + BFD_RELOC_16_BASEREL,
25951 + BFD_RELOC_LO16_BASEREL,
25952 + BFD_RELOC_HI16_BASEREL,
25953 + BFD_RELOC_HI16_S_BASEREL,
25954 + BFD_RELOC_8_BASEREL,
25957 +/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */
25958 + BFD_RELOC_8_FFnn,
25960 +/* These PC-relative relocations are stored as word displacements --
25961 +i.e., byte displacements shifted right two bits. The 30-bit word
25962 +displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
25963 +SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
25964 +signed 16-bit displacement is used on the MIPS, and the 23-bit
25965 +displacement is used on the Alpha. */
25966 + BFD_RELOC_32_PCREL_S2,
25967 + BFD_RELOC_16_PCREL_S2,
25968 + BFD_RELOC_23_PCREL_S2,
25970 +/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
25971 +the target word. These are used on the SPARC. */
25975 +/* For systems that allocate a Global Pointer register, these are
25976 +displacements off that register. These relocation types are
25977 +handled specially, because the value the register will have is
25978 +decided relatively late. */
25979 + BFD_RELOC_GPREL16,
25980 + BFD_RELOC_GPREL32,
25982 +/* Reloc types used for i960/b.out. */
25983 + BFD_RELOC_I960_CALLJ,
25985 +/* SPARC ELF relocations. There is probably some overlap with other
25986 +relocation types already defined. */
25988 + BFD_RELOC_SPARC_WDISP22,
25989 + BFD_RELOC_SPARC22,
25990 + BFD_RELOC_SPARC13,
25991 + BFD_RELOC_SPARC_GOT10,
25992 + BFD_RELOC_SPARC_GOT13,
25993 + BFD_RELOC_SPARC_GOT22,
25994 + BFD_RELOC_SPARC_PC10,
25995 + BFD_RELOC_SPARC_PC22,
25996 + BFD_RELOC_SPARC_WPLT30,
25997 + BFD_RELOC_SPARC_COPY,
25998 + BFD_RELOC_SPARC_GLOB_DAT,
25999 + BFD_RELOC_SPARC_JMP_SLOT,
26000 + BFD_RELOC_SPARC_RELATIVE,
26001 + BFD_RELOC_SPARC_UA16,
26002 + BFD_RELOC_SPARC_UA32,
26003 + BFD_RELOC_SPARC_UA64,
26005 +/* I think these are specific to SPARC a.out (e.g., Sun 4). */
26006 + BFD_RELOC_SPARC_BASE13,
26007 + BFD_RELOC_SPARC_BASE22,
26009 +/* SPARC64 relocations */
26010 +#define BFD_RELOC_SPARC_64 BFD_RELOC_64
26011 + BFD_RELOC_SPARC_10,
26012 + BFD_RELOC_SPARC_11,
26013 + BFD_RELOC_SPARC_OLO10,
26014 + BFD_RELOC_SPARC_HH22,
26015 + BFD_RELOC_SPARC_HM10,
26016 + BFD_RELOC_SPARC_LM22,
26017 + BFD_RELOC_SPARC_PC_HH22,
26018 + BFD_RELOC_SPARC_PC_HM10,
26019 + BFD_RELOC_SPARC_PC_LM22,
26020 + BFD_RELOC_SPARC_WDISP16,
26021 + BFD_RELOC_SPARC_WDISP19,
26022 + BFD_RELOC_SPARC_7,
26023 + BFD_RELOC_SPARC_6,
26024 + BFD_RELOC_SPARC_5,
26025 +#define BFD_RELOC_SPARC_DISP64 BFD_RELOC_64_PCREL
26026 + BFD_RELOC_SPARC_PLT32,
26027 + BFD_RELOC_SPARC_PLT64,
26028 + BFD_RELOC_SPARC_HIX22,
26029 + BFD_RELOC_SPARC_LOX10,
26030 + BFD_RELOC_SPARC_H44,
26031 + BFD_RELOC_SPARC_M44,
26032 + BFD_RELOC_SPARC_L44,
26033 + BFD_RELOC_SPARC_REGISTER,
26035 +/* SPARC little endian relocation */
26036 + BFD_RELOC_SPARC_REV32,
26038 +/* SPARC TLS relocations */
26039 + BFD_RELOC_SPARC_TLS_GD_HI22,
26040 + BFD_RELOC_SPARC_TLS_GD_LO10,
26041 + BFD_RELOC_SPARC_TLS_GD_ADD,
26042 + BFD_RELOC_SPARC_TLS_GD_CALL,
26043 + BFD_RELOC_SPARC_TLS_LDM_HI22,
26044 + BFD_RELOC_SPARC_TLS_LDM_LO10,
26045 + BFD_RELOC_SPARC_TLS_LDM_ADD,
26046 + BFD_RELOC_SPARC_TLS_LDM_CALL,
26047 + BFD_RELOC_SPARC_TLS_LDO_HIX22,
26048 + BFD_RELOC_SPARC_TLS_LDO_LOX10,
26049 + BFD_RELOC_SPARC_TLS_LDO_ADD,
26050 + BFD_RELOC_SPARC_TLS_IE_HI22,
26051 + BFD_RELOC_SPARC_TLS_IE_LO10,
26052 + BFD_RELOC_SPARC_TLS_IE_LD,
26053 + BFD_RELOC_SPARC_TLS_IE_LDX,
26054 + BFD_RELOC_SPARC_TLS_IE_ADD,
26055 + BFD_RELOC_SPARC_TLS_LE_HIX22,
26056 + BFD_RELOC_SPARC_TLS_LE_LOX10,
26057 + BFD_RELOC_SPARC_TLS_DTPMOD32,
26058 + BFD_RELOC_SPARC_TLS_DTPMOD64,
26059 + BFD_RELOC_SPARC_TLS_DTPOFF32,
26060 + BFD_RELOC_SPARC_TLS_DTPOFF64,
26061 + BFD_RELOC_SPARC_TLS_TPOFF32,
26062 + BFD_RELOC_SPARC_TLS_TPOFF64,
26064 +/* Alpha ECOFF and ELF relocations. Some of these treat the symbol or
26065 +"addend" in some special way.
26066 +For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
26067 +writing; when reading, it will be the absolute section symbol. The
26068 +addend is the displacement in bytes of the "lda" instruction from
26069 +the "ldah" instruction (which is at the address of this reloc). */
26070 + BFD_RELOC_ALPHA_GPDISP_HI16,
26072 +/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
26073 +with GPDISP_HI16 relocs. The addend is ignored when writing the
26074 +relocations out, and is filled in with the file's GP value on
26075 +reading, for convenience. */
26076 + BFD_RELOC_ALPHA_GPDISP_LO16,
26078 +/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
26079 +relocation except that there is no accompanying GPDISP_LO16
26081 + BFD_RELOC_ALPHA_GPDISP,
26083 +/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
26084 +the assembler turns it into a LDQ instruction to load the address of
26085 +the symbol, and then fills in a register in the real instruction.
26087 +The LITERAL reloc, at the LDQ instruction, refers to the .lita
26088 +section symbol. The addend is ignored when writing, but is filled
26089 +in with the file's GP value on reading, for convenience, as with the
26090 +GPDISP_LO16 reloc.
26092 +The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
26093 +It should refer to the symbol to be referenced, as with 16_GOTOFF,
26094 +but it generates output not based on the position within the .got
26095 +section, but relative to the GP value chosen for the file during the
26098 +The LITUSE reloc, on the instruction using the loaded address, gives
26099 +information to the linker that it might be able to use to optimize
26100 +away some literal section references. The symbol is ignored (read
26101 +as the absolute section symbol), and the "addend" indicates the type
26102 +of instruction using the register:
26103 +1 - "memory" fmt insn
26104 +2 - byte-manipulation (byte offset reg)
26105 +3 - jsr (target of branch) */
26106 + BFD_RELOC_ALPHA_LITERAL,
26107 + BFD_RELOC_ALPHA_ELF_LITERAL,
26108 + BFD_RELOC_ALPHA_LITUSE,
26110 +/* The HINT relocation indicates a value that should be filled into the
26111 +"hint" field of a jmp/jsr/ret instruction, for possible branch-
26112 +prediction logic which may be provided on some processors. */
26113 + BFD_RELOC_ALPHA_HINT,
26115 +/* The LINKAGE relocation outputs a linkage pair in the object file,
26116 +which is filled by the linker. */
26117 + BFD_RELOC_ALPHA_LINKAGE,
26119 +/* The CODEADDR relocation outputs a STO_CA in the object file,
26120 +which is filled by the linker. */
26121 + BFD_RELOC_ALPHA_CODEADDR,
26123 +/* The GPREL_HI/LO relocations together form a 32-bit offset from the
26125 + BFD_RELOC_ALPHA_GPREL_HI16,
26126 + BFD_RELOC_ALPHA_GPREL_LO16,
26128 +/* Like BFD_RELOC_23_PCREL_S2, except that the source and target must
26129 +share a common GP, and the target address is adjusted for
26130 +STO_ALPHA_STD_GPLOAD. */
26131 + BFD_RELOC_ALPHA_BRSGP,
26133 +/* Alpha thread-local storage relocations. */
26134 + BFD_RELOC_ALPHA_TLSGD,
26135 + BFD_RELOC_ALPHA_TLSLDM,
26136 + BFD_RELOC_ALPHA_DTPMOD64,
26137 + BFD_RELOC_ALPHA_GOTDTPREL16,
26138 + BFD_RELOC_ALPHA_DTPREL64,
26139 + BFD_RELOC_ALPHA_DTPREL_HI16,
26140 + BFD_RELOC_ALPHA_DTPREL_LO16,
26141 + BFD_RELOC_ALPHA_DTPREL16,
26142 + BFD_RELOC_ALPHA_GOTTPREL16,
26143 + BFD_RELOC_ALPHA_TPREL64,
26144 + BFD_RELOC_ALPHA_TPREL_HI16,
26145 + BFD_RELOC_ALPHA_TPREL_LO16,
26146 + BFD_RELOC_ALPHA_TPREL16,
26148 +/* Bits 27..2 of the relocation address shifted right 2 bits;
26149 +simple reloc otherwise. */
26150 + BFD_RELOC_MIPS_JMP,
26152 +/* The MIPS16 jump instruction. */
26153 + BFD_RELOC_MIPS16_JMP,
26155 +/* MIPS16 GP relative reloc. */
26156 + BFD_RELOC_MIPS16_GPREL,
26158 +/* High 16 bits of 32-bit value; simple reloc. */
26161 +/* High 16 bits of 32-bit value but the low 16 bits will be sign
26162 +extended and added to form the final result. If the low 16
26163 +bits form a negative number, we need to add one to the high value
26164 +to compensate for the borrow when the low bits are added. */
26165 + BFD_RELOC_HI16_S,
26167 +/* Low 16 bits. */
26170 +/* High 16 bits of 32-bit pc-relative value */
26171 + BFD_RELOC_HI16_PCREL,
26173 +/* High 16 bits of 32-bit pc-relative value, adjusted */
26174 + BFD_RELOC_HI16_S_PCREL,
26176 +/* Low 16 bits of pc-relative value */
26177 + BFD_RELOC_LO16_PCREL,
26179 +/* MIPS16 high 16 bits of 32-bit value. */
26180 + BFD_RELOC_MIPS16_HI16,
26182 +/* MIPS16 high 16 bits of 32-bit value but the low 16 bits will be sign
26183 +extended and added to form the final result. If the low 16
26184 +bits form a negative number, we need to add one to the high value
26185 +to compensate for the borrow when the low bits are added. */
26186 + BFD_RELOC_MIPS16_HI16_S,
26188 +/* MIPS16 low 16 bits. */
26189 + BFD_RELOC_MIPS16_LO16,
26191 +/* Relocation against a MIPS literal section. */
26192 + BFD_RELOC_MIPS_LITERAL,
26194 +/* MIPS ELF relocations. */
26195 + BFD_RELOC_MIPS_GOT16,
26196 + BFD_RELOC_MIPS_CALL16,
26197 + BFD_RELOC_MIPS_GOT_HI16,
26198 + BFD_RELOC_MIPS_GOT_LO16,
26199 + BFD_RELOC_MIPS_CALL_HI16,
26200 + BFD_RELOC_MIPS_CALL_LO16,
26201 + BFD_RELOC_MIPS_SUB,
26202 + BFD_RELOC_MIPS_GOT_PAGE,
26203 + BFD_RELOC_MIPS_GOT_OFST,
26204 + BFD_RELOC_MIPS_GOT_DISP,
26205 + BFD_RELOC_MIPS_SHIFT5,
26206 + BFD_RELOC_MIPS_SHIFT6,
26207 + BFD_RELOC_MIPS_INSERT_A,
26208 + BFD_RELOC_MIPS_INSERT_B,
26209 + BFD_RELOC_MIPS_DELETE,
26210 + BFD_RELOC_MIPS_HIGHEST,
26211 + BFD_RELOC_MIPS_HIGHER,
26212 + BFD_RELOC_MIPS_SCN_DISP,
26213 + BFD_RELOC_MIPS_REL16,
26214 + BFD_RELOC_MIPS_RELGOT,
26215 + BFD_RELOC_MIPS_JALR,
26216 + BFD_RELOC_MIPS_TLS_DTPMOD32,
26217 + BFD_RELOC_MIPS_TLS_DTPREL32,
26218 + BFD_RELOC_MIPS_TLS_DTPMOD64,
26219 + BFD_RELOC_MIPS_TLS_DTPREL64,
26220 + BFD_RELOC_MIPS_TLS_GD,
26221 + BFD_RELOC_MIPS_TLS_LDM,
26222 + BFD_RELOC_MIPS_TLS_DTPREL_HI16,
26223 + BFD_RELOC_MIPS_TLS_DTPREL_LO16,
26224 + BFD_RELOC_MIPS_TLS_GOTTPREL,
26225 + BFD_RELOC_MIPS_TLS_TPREL32,
26226 + BFD_RELOC_MIPS_TLS_TPREL64,
26227 + BFD_RELOC_MIPS_TLS_TPREL_HI16,
26228 + BFD_RELOC_MIPS_TLS_TPREL_LO16,
26231 +/* Fujitsu Frv Relocations. */
26232 + BFD_RELOC_FRV_LABEL16,
26233 + BFD_RELOC_FRV_LABEL24,
26234 + BFD_RELOC_FRV_LO16,
26235 + BFD_RELOC_FRV_HI16,
26236 + BFD_RELOC_FRV_GPREL12,
26237 + BFD_RELOC_FRV_GPRELU12,
26238 + BFD_RELOC_FRV_GPREL32,
26239 + BFD_RELOC_FRV_GPRELHI,
26240 + BFD_RELOC_FRV_GPRELLO,
26241 + BFD_RELOC_FRV_GOT12,
26242 + BFD_RELOC_FRV_GOTHI,
26243 + BFD_RELOC_FRV_GOTLO,
26244 + BFD_RELOC_FRV_FUNCDESC,
26245 + BFD_RELOC_FRV_FUNCDESC_GOT12,
26246 + BFD_RELOC_FRV_FUNCDESC_GOTHI,
26247 + BFD_RELOC_FRV_FUNCDESC_GOTLO,
26248 + BFD_RELOC_FRV_FUNCDESC_VALUE,
26249 + BFD_RELOC_FRV_FUNCDESC_GOTOFF12,
26250 + BFD_RELOC_FRV_FUNCDESC_GOTOFFHI,
26251 + BFD_RELOC_FRV_FUNCDESC_GOTOFFLO,
26252 + BFD_RELOC_FRV_GOTOFF12,
26253 + BFD_RELOC_FRV_GOTOFFHI,
26254 + BFD_RELOC_FRV_GOTOFFLO,
26255 + BFD_RELOC_FRV_GETTLSOFF,
26256 + BFD_RELOC_FRV_TLSDESC_VALUE,
26257 + BFD_RELOC_FRV_GOTTLSDESC12,
26258 + BFD_RELOC_FRV_GOTTLSDESCHI,
26259 + BFD_RELOC_FRV_GOTTLSDESCLO,
26260 + BFD_RELOC_FRV_TLSMOFF12,
26261 + BFD_RELOC_FRV_TLSMOFFHI,
26262 + BFD_RELOC_FRV_TLSMOFFLO,
26263 + BFD_RELOC_FRV_GOTTLSOFF12,
26264 + BFD_RELOC_FRV_GOTTLSOFFHI,
26265 + BFD_RELOC_FRV_GOTTLSOFFLO,
26266 + BFD_RELOC_FRV_TLSOFF,
26267 + BFD_RELOC_FRV_TLSDESC_RELAX,
26268 + BFD_RELOC_FRV_GETTLSOFF_RELAX,
26269 + BFD_RELOC_FRV_TLSOFF_RELAX,
26270 + BFD_RELOC_FRV_TLSMOFF,
26273 +/* This is a 24bit GOT-relative reloc for the mn10300. */
26274 + BFD_RELOC_MN10300_GOTOFF24,
26276 +/* This is a 32bit GOT-relative reloc for the mn10300, offset by two bytes
26277 +in the instruction. */
26278 + BFD_RELOC_MN10300_GOT32,
26280 +/* This is a 24bit GOT-relative reloc for the mn10300, offset by two bytes
26281 +in the instruction. */
26282 + BFD_RELOC_MN10300_GOT24,
26284 +/* This is a 16bit GOT-relative reloc for the mn10300, offset by two bytes
26285 +in the instruction. */
26286 + BFD_RELOC_MN10300_GOT16,
26288 +/* Copy symbol at runtime. */
26289 + BFD_RELOC_MN10300_COPY,
26291 +/* Create GOT entry. */
26292 + BFD_RELOC_MN10300_GLOB_DAT,
26294 +/* Create PLT entry. */
26295 + BFD_RELOC_MN10300_JMP_SLOT,
26297 +/* Adjust by program base. */
26298 + BFD_RELOC_MN10300_RELATIVE,
26301 +/* i386/elf relocations */
26302 + BFD_RELOC_386_GOT32,
26303 + BFD_RELOC_386_PLT32,
26304 + BFD_RELOC_386_COPY,
26305 + BFD_RELOC_386_GLOB_DAT,
26306 + BFD_RELOC_386_JUMP_SLOT,
26307 + BFD_RELOC_386_RELATIVE,
26308 + BFD_RELOC_386_GOTOFF,
26309 + BFD_RELOC_386_GOTPC,
26310 + BFD_RELOC_386_TLS_TPOFF,
26311 + BFD_RELOC_386_TLS_IE,
26312 + BFD_RELOC_386_TLS_GOTIE,
26313 + BFD_RELOC_386_TLS_LE,
26314 + BFD_RELOC_386_TLS_GD,
26315 + BFD_RELOC_386_TLS_LDM,
26316 + BFD_RELOC_386_TLS_LDO_32,
26317 + BFD_RELOC_386_TLS_IE_32,
26318 + BFD_RELOC_386_TLS_LE_32,
26319 + BFD_RELOC_386_TLS_DTPMOD32,
26320 + BFD_RELOC_386_TLS_DTPOFF32,
26321 + BFD_RELOC_386_TLS_TPOFF32,
26323 +/* x86-64/elf relocations */
26324 + BFD_RELOC_X86_64_GOT32,
26325 + BFD_RELOC_X86_64_PLT32,
26326 + BFD_RELOC_X86_64_COPY,
26327 + BFD_RELOC_X86_64_GLOB_DAT,
26328 + BFD_RELOC_X86_64_JUMP_SLOT,
26329 + BFD_RELOC_X86_64_RELATIVE,
26330 + BFD_RELOC_X86_64_GOTPCREL,
26331 + BFD_RELOC_X86_64_32S,
26332 + BFD_RELOC_X86_64_DTPMOD64,
26333 + BFD_RELOC_X86_64_DTPOFF64,
26334 + BFD_RELOC_X86_64_TPOFF64,
26335 + BFD_RELOC_X86_64_TLSGD,
26336 + BFD_RELOC_X86_64_TLSLD,
26337 + BFD_RELOC_X86_64_DTPOFF32,
26338 + BFD_RELOC_X86_64_GOTTPOFF,
26339 + BFD_RELOC_X86_64_TPOFF32,
26340 + BFD_RELOC_X86_64_GOTOFF64,
26341 + BFD_RELOC_X86_64_GOTPC32,
26343 +/* ns32k relocations */
26344 + BFD_RELOC_NS32K_IMM_8,
26345 + BFD_RELOC_NS32K_IMM_16,
26346 + BFD_RELOC_NS32K_IMM_32,
26347 + BFD_RELOC_NS32K_IMM_8_PCREL,
26348 + BFD_RELOC_NS32K_IMM_16_PCREL,
26349 + BFD_RELOC_NS32K_IMM_32_PCREL,
26350 + BFD_RELOC_NS32K_DISP_8,
26351 + BFD_RELOC_NS32K_DISP_16,
26352 + BFD_RELOC_NS32K_DISP_32,
26353 + BFD_RELOC_NS32K_DISP_8_PCREL,
26354 + BFD_RELOC_NS32K_DISP_16_PCREL,
26355 + BFD_RELOC_NS32K_DISP_32_PCREL,
26357 +/* PDP11 relocations */
26358 + BFD_RELOC_PDP11_DISP_8_PCREL,
26359 + BFD_RELOC_PDP11_DISP_6_PCREL,
26361 +/* Picojava relocs. Not all of these appear in object files. */
26362 + BFD_RELOC_PJ_CODE_HI16,
26363 + BFD_RELOC_PJ_CODE_LO16,
26364 + BFD_RELOC_PJ_CODE_DIR16,
26365 + BFD_RELOC_PJ_CODE_DIR32,
26366 + BFD_RELOC_PJ_CODE_REL16,
26367 + BFD_RELOC_PJ_CODE_REL32,
26369 +/* Power(rs6000) and PowerPC relocations. */
26370 + BFD_RELOC_PPC_B26,
26371 + BFD_RELOC_PPC_BA26,
26372 + BFD_RELOC_PPC_TOC16,
26373 + BFD_RELOC_PPC_B16,
26374 + BFD_RELOC_PPC_B16_BRTAKEN,
26375 + BFD_RELOC_PPC_B16_BRNTAKEN,
26376 + BFD_RELOC_PPC_BA16,
26377 + BFD_RELOC_PPC_BA16_BRTAKEN,
26378 + BFD_RELOC_PPC_BA16_BRNTAKEN,
26379 + BFD_RELOC_PPC_COPY,
26380 + BFD_RELOC_PPC_GLOB_DAT,
26381 + BFD_RELOC_PPC_JMP_SLOT,
26382 + BFD_RELOC_PPC_RELATIVE,
26383 + BFD_RELOC_PPC_LOCAL24PC,
26384 + BFD_RELOC_PPC_EMB_NADDR32,
26385 + BFD_RELOC_PPC_EMB_NADDR16,
26386 + BFD_RELOC_PPC_EMB_NADDR16_LO,
26387 + BFD_RELOC_PPC_EMB_NADDR16_HI,
26388 + BFD_RELOC_PPC_EMB_NADDR16_HA,
26389 + BFD_RELOC_PPC_EMB_SDAI16,
26390 + BFD_RELOC_PPC_EMB_SDA2I16,
26391 + BFD_RELOC_PPC_EMB_SDA2REL,
26392 + BFD_RELOC_PPC_EMB_SDA21,
26393 + BFD_RELOC_PPC_EMB_MRKREF,
26394 + BFD_RELOC_PPC_EMB_RELSEC16,
26395 + BFD_RELOC_PPC_EMB_RELST_LO,
26396 + BFD_RELOC_PPC_EMB_RELST_HI,
26397 + BFD_RELOC_PPC_EMB_RELST_HA,
26398 + BFD_RELOC_PPC_EMB_BIT_FLD,
26399 + BFD_RELOC_PPC_EMB_RELSDA,
26400 + BFD_RELOC_PPC64_HIGHER,
26401 + BFD_RELOC_PPC64_HIGHER_S,
26402 + BFD_RELOC_PPC64_HIGHEST,
26403 + BFD_RELOC_PPC64_HIGHEST_S,
26404 + BFD_RELOC_PPC64_TOC16_LO,
26405 + BFD_RELOC_PPC64_TOC16_HI,
26406 + BFD_RELOC_PPC64_TOC16_HA,
26407 + BFD_RELOC_PPC64_TOC,
26408 + BFD_RELOC_PPC64_PLTGOT16,
26409 + BFD_RELOC_PPC64_PLTGOT16_LO,
26410 + BFD_RELOC_PPC64_PLTGOT16_HI,
26411 + BFD_RELOC_PPC64_PLTGOT16_HA,
26412 + BFD_RELOC_PPC64_ADDR16_DS,
26413 + BFD_RELOC_PPC64_ADDR16_LO_DS,
26414 + BFD_RELOC_PPC64_GOT16_DS,
26415 + BFD_RELOC_PPC64_GOT16_LO_DS,
26416 + BFD_RELOC_PPC64_PLT16_LO_DS,
26417 + BFD_RELOC_PPC64_SECTOFF_DS,
26418 + BFD_RELOC_PPC64_SECTOFF_LO_DS,
26419 + BFD_RELOC_PPC64_TOC16_DS,
26420 + BFD_RELOC_PPC64_TOC16_LO_DS,
26421 + BFD_RELOC_PPC64_PLTGOT16_DS,
26422 + BFD_RELOC_PPC64_PLTGOT16_LO_DS,
26424 +/* PowerPC and PowerPC64 thread-local storage relocations. */
26425 + BFD_RELOC_PPC_TLS,
26426 + BFD_RELOC_PPC_DTPMOD,
26427 + BFD_RELOC_PPC_TPREL16,
26428 + BFD_RELOC_PPC_TPREL16_LO,
26429 + BFD_RELOC_PPC_TPREL16_HI,
26430 + BFD_RELOC_PPC_TPREL16_HA,
26431 + BFD_RELOC_PPC_TPREL,
26432 + BFD_RELOC_PPC_DTPREL16,
26433 + BFD_RELOC_PPC_DTPREL16_LO,
26434 + BFD_RELOC_PPC_DTPREL16_HI,
26435 + BFD_RELOC_PPC_DTPREL16_HA,
26436 + BFD_RELOC_PPC_DTPREL,
26437 + BFD_RELOC_PPC_GOT_TLSGD16,
26438 + BFD_RELOC_PPC_GOT_TLSGD16_LO,
26439 + BFD_RELOC_PPC_GOT_TLSGD16_HI,
26440 + BFD_RELOC_PPC_GOT_TLSGD16_HA,
26441 + BFD_RELOC_PPC_GOT_TLSLD16,
26442 + BFD_RELOC_PPC_GOT_TLSLD16_LO,
26443 + BFD_RELOC_PPC_GOT_TLSLD16_HI,
26444 + BFD_RELOC_PPC_GOT_TLSLD16_HA,
26445 + BFD_RELOC_PPC_GOT_TPREL16,
26446 + BFD_RELOC_PPC_GOT_TPREL16_LO,
26447 + BFD_RELOC_PPC_GOT_TPREL16_HI,
26448 + BFD_RELOC_PPC_GOT_TPREL16_HA,
26449 + BFD_RELOC_PPC_GOT_DTPREL16,
26450 + BFD_RELOC_PPC_GOT_DTPREL16_LO,
26451 + BFD_RELOC_PPC_GOT_DTPREL16_HI,
26452 + BFD_RELOC_PPC_GOT_DTPREL16_HA,
26453 + BFD_RELOC_PPC64_TPREL16_DS,
26454 + BFD_RELOC_PPC64_TPREL16_LO_DS,
26455 + BFD_RELOC_PPC64_TPREL16_HIGHER,
26456 + BFD_RELOC_PPC64_TPREL16_HIGHERA,
26457 + BFD_RELOC_PPC64_TPREL16_HIGHEST,
26458 + BFD_RELOC_PPC64_TPREL16_HIGHESTA,
26459 + BFD_RELOC_PPC64_DTPREL16_DS,
26460 + BFD_RELOC_PPC64_DTPREL16_LO_DS,
26461 + BFD_RELOC_PPC64_DTPREL16_HIGHER,
26462 + BFD_RELOC_PPC64_DTPREL16_HIGHERA,
26463 + BFD_RELOC_PPC64_DTPREL16_HIGHEST,
26464 + BFD_RELOC_PPC64_DTPREL16_HIGHESTA,
26466 +/* IBM 370/390 relocations */
26467 + BFD_RELOC_I370_D12,
26469 +/* The type of reloc used to build a constructor table - at the moment
26470 +probably a 32 bit wide absolute relocation, but the target can choose.
26471 +It generally does map to one of the other relocation types. */
26474 +/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
26475 +not stored in the instruction. */
26476 + BFD_RELOC_ARM_PCREL_BRANCH,
26478 +/* ARM 26 bit pc-relative branch. The lowest bit must be zero and is
26479 +not stored in the instruction. The 2nd lowest bit comes from a 1 bit
26480 +field in the instruction. */
26481 + BFD_RELOC_ARM_PCREL_BLX,
26483 +/* Thumb 22 bit pc-relative branch. The lowest bit must be zero and is
26484 +not stored in the instruction. The 2nd lowest bit comes from a 1 bit
26485 +field in the instruction. */
26486 + BFD_RELOC_THUMB_PCREL_BLX,
26488 +/* Thumb 7-, 9-, 12-, 20-, 23-, and 25-bit pc-relative branches.
26489 +The lowest bit must be zero and is not stored in the instruction.
26490 +Note that the corresponding ELF R_ARM_THM_JUMPnn constant has an
26491 +"nn" one smaller in all cases. Note further that BRANCH23
26492 +corresponds to R_ARM_THM_CALL. */
26493 + BFD_RELOC_THUMB_PCREL_BRANCH7,
26494 + BFD_RELOC_THUMB_PCREL_BRANCH9,
26495 + BFD_RELOC_THUMB_PCREL_BRANCH12,
26496 + BFD_RELOC_THUMB_PCREL_BRANCH20,
26497 + BFD_RELOC_THUMB_PCREL_BRANCH23,
26498 + BFD_RELOC_THUMB_PCREL_BRANCH25,
26500 +/* 12-bit immediate offset, used in ARM-format ldr and str instructions. */
26501 + BFD_RELOC_ARM_OFFSET_IMM,
26503 +/* 5-bit immediate offset, used in Thumb-format ldr and str instructions. */
26504 + BFD_RELOC_ARM_THUMB_OFFSET,
26506 +/* Pc-relative or absolute relocation depending on target. Used for
26507 +entries in .init_array sections. */
26508 + BFD_RELOC_ARM_TARGET1,
26510 +/* Read-only segment base relative address. */
26511 + BFD_RELOC_ARM_ROSEGREL32,
26513 +/* Data segment base relative address. */
26514 + BFD_RELOC_ARM_SBREL32,
26516 +/* This reloc is used for references to RTTI data from exception handling
26517 +tables. The actual definition depends on the target. It may be a
26518 +pc-relative or some form of GOT-indirect relocation. */
26519 + BFD_RELOC_ARM_TARGET2,
26521 +/* 31-bit PC relative address. */
26522 + BFD_RELOC_ARM_PREL31,
26524 +/* Relocations for setting up GOTs and PLTs for shared libraries. */
26525 + BFD_RELOC_ARM_JUMP_SLOT,
26526 + BFD_RELOC_ARM_GLOB_DAT,
26527 + BFD_RELOC_ARM_GOT32,
26528 + BFD_RELOC_ARM_PLT32,
26529 + BFD_RELOC_ARM_RELATIVE,
26530 + BFD_RELOC_ARM_GOTOFF,
26531 + BFD_RELOC_ARM_GOTPC,
26533 +/* ARM thread-local storage relocations. */
26534 + BFD_RELOC_ARM_TLS_GD32,
26535 + BFD_RELOC_ARM_TLS_LDO32,
26536 + BFD_RELOC_ARM_TLS_LDM32,
26537 + BFD_RELOC_ARM_TLS_DTPOFF32,
26538 + BFD_RELOC_ARM_TLS_DTPMOD32,
26539 + BFD_RELOC_ARM_TLS_TPOFF32,
26540 + BFD_RELOC_ARM_TLS_IE32,
26541 + BFD_RELOC_ARM_TLS_LE32,
26543 +/* These relocs are only used within the ARM assembler. They are not
26544 +(at present) written to any object files. */
26545 + BFD_RELOC_ARM_IMMEDIATE,
26546 + BFD_RELOC_ARM_ADRL_IMMEDIATE,
26547 + BFD_RELOC_ARM_T32_IMMEDIATE,
26548 + BFD_RELOC_ARM_SHIFT_IMM,
26549 + BFD_RELOC_ARM_SMI,
26550 + BFD_RELOC_ARM_SWI,
26551 + BFD_RELOC_ARM_MULTI,
26552 + BFD_RELOC_ARM_CP_OFF_IMM,
26553 + BFD_RELOC_ARM_CP_OFF_IMM_S2,
26554 + BFD_RELOC_ARM_ADR_IMM,
26555 + BFD_RELOC_ARM_LDR_IMM,
26556 + BFD_RELOC_ARM_LITERAL,
26557 + BFD_RELOC_ARM_IN_POOL,
26558 + BFD_RELOC_ARM_OFFSET_IMM8,
26559 + BFD_RELOC_ARM_T32_OFFSET_U8,
26560 + BFD_RELOC_ARM_T32_OFFSET_IMM,
26561 + BFD_RELOC_ARM_HWLITERAL,
26562 + BFD_RELOC_ARM_THUMB_ADD,
26563 + BFD_RELOC_ARM_THUMB_IMM,
26564 + BFD_RELOC_ARM_THUMB_SHIFT,
26566 +/* Renesas / SuperH SH relocs. Not all of these appear in object files. */
26567 + BFD_RELOC_SH_PCDISP8BY2,
26568 + BFD_RELOC_SH_PCDISP12BY2,
26569 + BFD_RELOC_SH_IMM3,
26570 + BFD_RELOC_SH_IMM3U,
26571 + BFD_RELOC_SH_DISP12,
26572 + BFD_RELOC_SH_DISP12BY2,
26573 + BFD_RELOC_SH_DISP12BY4,
26574 + BFD_RELOC_SH_DISP12BY8,
26575 + BFD_RELOC_SH_DISP20,
26576 + BFD_RELOC_SH_DISP20BY8,
26577 + BFD_RELOC_SH_IMM4,
26578 + BFD_RELOC_SH_IMM4BY2,
26579 + BFD_RELOC_SH_IMM4BY4,
26580 + BFD_RELOC_SH_IMM8,
26581 + BFD_RELOC_SH_IMM8BY2,
26582 + BFD_RELOC_SH_IMM8BY4,
26583 + BFD_RELOC_SH_PCRELIMM8BY2,
26584 + BFD_RELOC_SH_PCRELIMM8BY4,
26585 + BFD_RELOC_SH_SWITCH16,
26586 + BFD_RELOC_SH_SWITCH32,
26587 + BFD_RELOC_SH_USES,
26588 + BFD_RELOC_SH_COUNT,
26589 + BFD_RELOC_SH_ALIGN,
26590 + BFD_RELOC_SH_CODE,
26591 + BFD_RELOC_SH_DATA,
26592 + BFD_RELOC_SH_LABEL,
26593 + BFD_RELOC_SH_LOOP_START,
26594 + BFD_RELOC_SH_LOOP_END,
26595 + BFD_RELOC_SH_COPY,
26596 + BFD_RELOC_SH_GLOB_DAT,
26597 + BFD_RELOC_SH_JMP_SLOT,
26598 + BFD_RELOC_SH_RELATIVE,
26599 + BFD_RELOC_SH_GOTPC,
26600 + BFD_RELOC_SH_GOT_LOW16,
26601 + BFD_RELOC_SH_GOT_MEDLOW16,
26602 + BFD_RELOC_SH_GOT_MEDHI16,
26603 + BFD_RELOC_SH_GOT_HI16,
26604 + BFD_RELOC_SH_GOTPLT_LOW16,
26605 + BFD_RELOC_SH_GOTPLT_MEDLOW16,
26606 + BFD_RELOC_SH_GOTPLT_MEDHI16,
26607 + BFD_RELOC_SH_GOTPLT_HI16,
26608 + BFD_RELOC_SH_PLT_LOW16,
26609 + BFD_RELOC_SH_PLT_MEDLOW16,
26610 + BFD_RELOC_SH_PLT_MEDHI16,
26611 + BFD_RELOC_SH_PLT_HI16,
26612 + BFD_RELOC_SH_GOTOFF_LOW16,
26613 + BFD_RELOC_SH_GOTOFF_MEDLOW16,
26614 + BFD_RELOC_SH_GOTOFF_MEDHI16,
26615 + BFD_RELOC_SH_GOTOFF_HI16,
26616 + BFD_RELOC_SH_GOTPC_LOW16,
26617 + BFD_RELOC_SH_GOTPC_MEDLOW16,
26618 + BFD_RELOC_SH_GOTPC_MEDHI16,
26619 + BFD_RELOC_SH_GOTPC_HI16,
26620 + BFD_RELOC_SH_COPY64,
26621 + BFD_RELOC_SH_GLOB_DAT64,
26622 + BFD_RELOC_SH_JMP_SLOT64,
26623 + BFD_RELOC_SH_RELATIVE64,
26624 + BFD_RELOC_SH_GOT10BY4,
26625 + BFD_RELOC_SH_GOT10BY8,
26626 + BFD_RELOC_SH_GOTPLT10BY4,
26627 + BFD_RELOC_SH_GOTPLT10BY8,
26628 + BFD_RELOC_SH_GOTPLT32,
26629 + BFD_RELOC_SH_SHMEDIA_CODE,
26630 + BFD_RELOC_SH_IMMU5,
26631 + BFD_RELOC_SH_IMMS6,
26632 + BFD_RELOC_SH_IMMS6BY32,
26633 + BFD_RELOC_SH_IMMU6,
26634 + BFD_RELOC_SH_IMMS10,
26635 + BFD_RELOC_SH_IMMS10BY2,
26636 + BFD_RELOC_SH_IMMS10BY4,
26637 + BFD_RELOC_SH_IMMS10BY8,
26638 + BFD_RELOC_SH_IMMS16,
26639 + BFD_RELOC_SH_IMMU16,
26640 + BFD_RELOC_SH_IMM_LOW16,
26641 + BFD_RELOC_SH_IMM_LOW16_PCREL,
26642 + BFD_RELOC_SH_IMM_MEDLOW16,
26643 + BFD_RELOC_SH_IMM_MEDLOW16_PCREL,
26644 + BFD_RELOC_SH_IMM_MEDHI16,
26645 + BFD_RELOC_SH_IMM_MEDHI16_PCREL,
26646 + BFD_RELOC_SH_IMM_HI16,
26647 + BFD_RELOC_SH_IMM_HI16_PCREL,
26648 + BFD_RELOC_SH_PT_16,
26649 + BFD_RELOC_SH_TLS_GD_32,
26650 + BFD_RELOC_SH_TLS_LD_32,
26651 + BFD_RELOC_SH_TLS_LDO_32,
26652 + BFD_RELOC_SH_TLS_IE_32,
26653 + BFD_RELOC_SH_TLS_LE_32,
26654 + BFD_RELOC_SH_TLS_DTPMOD32,
26655 + BFD_RELOC_SH_TLS_DTPOFF32,
26656 + BFD_RELOC_SH_TLS_TPOFF32,
26658 +/* ARC Cores relocs.
26659 +ARC 22 bit pc-relative branch. The lowest two bits must be zero and are
26660 +not stored in the instruction. The high 20 bits are installed in bits 26
26661 +through 7 of the instruction. */
26662 + BFD_RELOC_ARC_B22_PCREL,
26664 +/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not
26665 +stored in the instruction. The high 24 bits are installed in bits 23
26667 + BFD_RELOC_ARC_B26,
26669 +/* Mitsubishi D10V relocs.
26670 +This is a 10-bit reloc with the right 2 bits
26671 +assumed to be 0. */
26672 + BFD_RELOC_D10V_10_PCREL_R,
26674 +/* Mitsubishi D10V relocs.
26675 +This is a 10-bit reloc with the right 2 bits
26676 +assumed to be 0. This is the same as the previous reloc
26677 +except it is in the left container, i.e.,
26678 +shifted left 15 bits. */
26679 + BFD_RELOC_D10V_10_PCREL_L,
26681 +/* This is an 18-bit reloc with the right 2 bits
26682 +assumed to be 0. */
26683 + BFD_RELOC_D10V_18,
26685 +/* This is an 18-bit reloc with the right 2 bits
26686 +assumed to be 0. */
26687 + BFD_RELOC_D10V_18_PCREL,
26689 +/* Mitsubishi D30V relocs.
26690 +This is a 6-bit absolute reloc. */
26691 + BFD_RELOC_D30V_6,
26693 +/* This is a 6-bit pc-relative reloc with
26694 +the right 3 bits assumed to be 0. */
26695 + BFD_RELOC_D30V_9_PCREL,
26697 +/* This is a 6-bit pc-relative reloc with
26698 +the right 3 bits assumed to be 0. Same
26699 +as the previous reloc but on the right side
26700 +of the container. */
26701 + BFD_RELOC_D30V_9_PCREL_R,
26703 +/* This is a 12-bit absolute reloc with the
26704 +right 3 bitsassumed to be 0. */
26705 + BFD_RELOC_D30V_15,
26707 +/* This is a 12-bit pc-relative reloc with
26708 +the right 3 bits assumed to be 0. */
26709 + BFD_RELOC_D30V_15_PCREL,
26711 +/* This is a 12-bit pc-relative reloc with
26712 +the right 3 bits assumed to be 0. Same
26713 +as the previous reloc but on the right side
26714 +of the container. */
26715 + BFD_RELOC_D30V_15_PCREL_R,
26717 +/* This is an 18-bit absolute reloc with
26718 +the right 3 bits assumed to be 0. */
26719 + BFD_RELOC_D30V_21,
26721 +/* This is an 18-bit pc-relative reloc with
26722 +the right 3 bits assumed to be 0. */
26723 + BFD_RELOC_D30V_21_PCREL,
26725 +/* This is an 18-bit pc-relative reloc with
26726 +the right 3 bits assumed to be 0. Same
26727 +as the previous reloc but on the right side
26728 +of the container. */
26729 + BFD_RELOC_D30V_21_PCREL_R,
26731 +/* This is a 32-bit absolute reloc. */
26732 + BFD_RELOC_D30V_32,
26734 +/* This is a 32-bit pc-relative reloc. */
26735 + BFD_RELOC_D30V_32_PCREL,
26738 + BFD_RELOC_DLX_HI16_S,
26741 + BFD_RELOC_DLX_LO16,
26744 + BFD_RELOC_DLX_JMP26,
26746 +/* Renesas M16C/M32C Relocations. */
26747 + BFD_RELOC_M16C_8_PCREL8,
26748 + BFD_RELOC_M16C_16_PCREL8,
26749 + BFD_RELOC_M16C_8_PCREL16,
26750 + BFD_RELOC_M16C_8_ELABEL24,
26751 + BFD_RELOC_M16C_8_ABS16,
26752 + BFD_RELOC_M16C_16_ABS16,
26753 + BFD_RELOC_M16C_16_ABS24,
26754 + BFD_RELOC_M16C_16_ABS32,
26755 + BFD_RELOC_M16C_24_ABS16,
26756 + BFD_RELOC_M16C_24_ABS24,
26757 + BFD_RELOC_M16C_24_ABS32,
26758 + BFD_RELOC_M16C_32_ABS16,
26759 + BFD_RELOC_M16C_32_ABS24,
26760 + BFD_RELOC_M16C_32_ABS32,
26761 + BFD_RELOC_M16C_40_ABS16,
26762 + BFD_RELOC_M16C_40_ABS24,
26763 + BFD_RELOC_M16C_40_ABS32,
26765 +/* Renesas M32R (formerly Mitsubishi M32R) relocs.
26766 +This is a 24 bit absolute address. */
26767 + BFD_RELOC_M32R_24,
26769 +/* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. */
26770 + BFD_RELOC_M32R_10_PCREL,
26772 +/* This is an 18-bit reloc with the right 2 bits assumed to be 0. */
26773 + BFD_RELOC_M32R_18_PCREL,
26775 +/* This is a 26-bit reloc with the right 2 bits assumed to be 0. */
26776 + BFD_RELOC_M32R_26_PCREL,
26778 +/* This is a 16-bit reloc containing the high 16 bits of an address
26779 +used when the lower 16 bits are treated as unsigned. */
26780 + BFD_RELOC_M32R_HI16_ULO,
26782 +/* This is a 16-bit reloc containing the high 16 bits of an address
26783 +used when the lower 16 bits are treated as signed. */
26784 + BFD_RELOC_M32R_HI16_SLO,
26786 +/* This is a 16-bit reloc containing the lower 16 bits of an address. */
26787 + BFD_RELOC_M32R_LO16,
26789 +/* This is a 16-bit reloc containing the small data area offset for use in
26790 +add3, load, and store instructions. */
26791 + BFD_RELOC_M32R_SDA16,
26794 + BFD_RELOC_M32R_GOT24,
26795 + BFD_RELOC_M32R_26_PLTREL,
26796 + BFD_RELOC_M32R_COPY,
26797 + BFD_RELOC_M32R_GLOB_DAT,
26798 + BFD_RELOC_M32R_JMP_SLOT,
26799 + BFD_RELOC_M32R_RELATIVE,
26800 + BFD_RELOC_M32R_GOTOFF,
26801 + BFD_RELOC_M32R_GOTOFF_HI_ULO,
26802 + BFD_RELOC_M32R_GOTOFF_HI_SLO,
26803 + BFD_RELOC_M32R_GOTOFF_LO,
26804 + BFD_RELOC_M32R_GOTPC24,
26805 + BFD_RELOC_M32R_GOT16_HI_ULO,
26806 + BFD_RELOC_M32R_GOT16_HI_SLO,
26807 + BFD_RELOC_M32R_GOT16_LO,
26808 + BFD_RELOC_M32R_GOTPC_HI_ULO,
26809 + BFD_RELOC_M32R_GOTPC_HI_SLO,
26810 + BFD_RELOC_M32R_GOTPC_LO,
26812 +/* This is a 9-bit reloc */
26813 + BFD_RELOC_V850_9_PCREL,
26815 +/* This is a 22-bit reloc */
26816 + BFD_RELOC_V850_22_PCREL,
26818 +/* This is a 16 bit offset from the short data area pointer. */
26819 + BFD_RELOC_V850_SDA_16_16_OFFSET,
26821 +/* This is a 16 bit offset (of which only 15 bits are used) from the
26822 +short data area pointer. */
26823 + BFD_RELOC_V850_SDA_15_16_OFFSET,
26825 +/* This is a 16 bit offset from the zero data area pointer. */
26826 + BFD_RELOC_V850_ZDA_16_16_OFFSET,
26828 +/* This is a 16 bit offset (of which only 15 bits are used) from the
26829 +zero data area pointer. */
26830 + BFD_RELOC_V850_ZDA_15_16_OFFSET,
26832 +/* This is an 8 bit offset (of which only 6 bits are used) from the
26833 +tiny data area pointer. */
26834 + BFD_RELOC_V850_TDA_6_8_OFFSET,
26836 +/* This is an 8bit offset (of which only 7 bits are used) from the tiny
26837 +data area pointer. */
26838 + BFD_RELOC_V850_TDA_7_8_OFFSET,
26840 +/* This is a 7 bit offset from the tiny data area pointer. */
26841 + BFD_RELOC_V850_TDA_7_7_OFFSET,
26843 +/* This is a 16 bit offset from the tiny data area pointer. */
26844 + BFD_RELOC_V850_TDA_16_16_OFFSET,
26846 +/* This is a 5 bit offset (of which only 4 bits are used) from the tiny
26847 +data area pointer. */
26848 + BFD_RELOC_V850_TDA_4_5_OFFSET,
26850 +/* This is a 4 bit offset from the tiny data area pointer. */
26851 + BFD_RELOC_V850_TDA_4_4_OFFSET,
26853 +/* This is a 16 bit offset from the short data area pointer, with the
26854 +bits placed non-contiguously in the instruction. */
26855 + BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET,
26857 +/* This is a 16 bit offset from the zero data area pointer, with the
26858 +bits placed non-contiguously in the instruction. */
26859 + BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET,
26861 +/* This is a 6 bit offset from the call table base pointer. */
26862 + BFD_RELOC_V850_CALLT_6_7_OFFSET,
26864 +/* This is a 16 bit offset from the call table base pointer. */
26865 + BFD_RELOC_V850_CALLT_16_16_OFFSET,
26867 +/* Used for relaxing indirect function calls. */
26868 + BFD_RELOC_V850_LONGCALL,
26870 +/* Used for relaxing indirect jumps. */
26871 + BFD_RELOC_V850_LONGJUMP,
26873 +/* Used to maintain alignment whilst relaxing. */
26874 + BFD_RELOC_V850_ALIGN,
26876 +/* This is a variation of BFD_RELOC_LO16 that can be used in v850e ld.bu
26878 + BFD_RELOC_V850_LO16_SPLIT_OFFSET,
26880 +/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
26882 + BFD_RELOC_MN10300_32_PCREL,
26884 +/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
26886 + BFD_RELOC_MN10300_16_PCREL,
26888 +/* This is a 8bit DP reloc for the tms320c30, where the most
26889 +significant 8 bits of a 24 bit word are placed into the least
26890 +significant 8 bits of the opcode. */
26891 + BFD_RELOC_TIC30_LDP,
26893 +/* This is a 7bit reloc for the tms320c54x, where the least
26894 +significant 7 bits of a 16 bit word are placed into the least
26895 +significant 7 bits of the opcode. */
26896 + BFD_RELOC_TIC54X_PARTLS7,
26898 +/* This is a 9bit DP reloc for the tms320c54x, where the most
26899 +significant 9 bits of a 16 bit word are placed into the least
26900 +significant 9 bits of the opcode. */
26901 + BFD_RELOC_TIC54X_PARTMS9,
26903 +/* This is an extended address 23-bit reloc for the tms320c54x. */
26904 + BFD_RELOC_TIC54X_23,
26906 +/* This is a 16-bit reloc for the tms320c54x, where the least
26907 +significant 16 bits of a 23-bit extended address are placed into
26909 + BFD_RELOC_TIC54X_16_OF_23,
26911 +/* This is a reloc for the tms320c54x, where the most
26912 +significant 7 bits of a 23-bit extended address are placed into
26914 + BFD_RELOC_TIC54X_MS7_OF_23,
26916 +/* This is a 48 bit reloc for the FR30 that stores 32 bits. */
26917 + BFD_RELOC_FR30_48,
26919 +/* This is a 32 bit reloc for the FR30 that stores 20 bits split up into
26921 + BFD_RELOC_FR30_20,
26923 +/* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
26925 + BFD_RELOC_FR30_6_IN_4,
26927 +/* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
26929 + BFD_RELOC_FR30_8_IN_8,
26931 +/* This is a 16 bit reloc for the FR30 that stores a 9 bit short offset
26933 + BFD_RELOC_FR30_9_IN_8,
26935 +/* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
26937 + BFD_RELOC_FR30_10_IN_8,
26939 +/* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
26940 +short offset into 8 bits. */
26941 + BFD_RELOC_FR30_9_PCREL,
26943 +/* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
26944 +short offset into 11 bits. */
26945 + BFD_RELOC_FR30_12_PCREL,
26947 +/* Motorola Mcore relocations. */
26948 + BFD_RELOC_MCORE_PCREL_IMM8BY4,
26949 + BFD_RELOC_MCORE_PCREL_IMM11BY2,
26950 + BFD_RELOC_MCORE_PCREL_IMM4BY2,
26951 + BFD_RELOC_MCORE_PCREL_32,
26952 + BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2,
26953 + BFD_RELOC_MCORE_RVA,
26955 +/* These are relocations for the GETA instruction. */
26956 + BFD_RELOC_MMIX_GETA,
26957 + BFD_RELOC_MMIX_GETA_1,
26958 + BFD_RELOC_MMIX_GETA_2,
26959 + BFD_RELOC_MMIX_GETA_3,
26961 +/* These are relocations for a conditional branch instruction. */
26962 + BFD_RELOC_MMIX_CBRANCH,
26963 + BFD_RELOC_MMIX_CBRANCH_J,
26964 + BFD_RELOC_MMIX_CBRANCH_1,
26965 + BFD_RELOC_MMIX_CBRANCH_2,
26966 + BFD_RELOC_MMIX_CBRANCH_3,
26968 +/* These are relocations for the PUSHJ instruction. */
26969 + BFD_RELOC_MMIX_PUSHJ,
26970 + BFD_RELOC_MMIX_PUSHJ_1,
26971 + BFD_RELOC_MMIX_PUSHJ_2,
26972 + BFD_RELOC_MMIX_PUSHJ_3,
26973 + BFD_RELOC_MMIX_PUSHJ_STUBBABLE,
26975 +/* These are relocations for the JMP instruction. */
26976 + BFD_RELOC_MMIX_JMP,
26977 + BFD_RELOC_MMIX_JMP_1,
26978 + BFD_RELOC_MMIX_JMP_2,
26979 + BFD_RELOC_MMIX_JMP_3,
26981 +/* This is a relocation for a relative address as in a GETA instruction or
26983 + BFD_RELOC_MMIX_ADDR19,
26985 +/* This is a relocation for a relative address as in a JMP instruction. */
26986 + BFD_RELOC_MMIX_ADDR27,
26988 +/* This is a relocation for an instruction field that may be a general
26989 +register or a value 0..255. */
26990 + BFD_RELOC_MMIX_REG_OR_BYTE,
26992 +/* This is a relocation for an instruction field that may be a general
26994 + BFD_RELOC_MMIX_REG,
26996 +/* This is a relocation for two instruction fields holding a register and
26997 +an offset, the equivalent of the relocation. */
26998 + BFD_RELOC_MMIX_BASE_PLUS_OFFSET,
27000 +/* This relocation is an assertion that the expression is not allocated as
27001 +a global register. It does not modify contents. */
27002 + BFD_RELOC_MMIX_LOCAL,
27004 +/* This is a 16 bit reloc for the AVR that stores 8 bit pc relative
27005 +short offset into 7 bits. */
27006 + BFD_RELOC_AVR_7_PCREL,
27008 +/* This is a 16 bit reloc for the AVR that stores 13 bit pc relative
27009 +short offset into 12 bits. */
27010 + BFD_RELOC_AVR_13_PCREL,
27012 +/* This is a 16 bit reloc for the AVR that stores 17 bit value (usually
27013 +program memory address) into 16 bits. */
27014 + BFD_RELOC_AVR_16_PM,
27016 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually
27017 +data memory address) into 8 bit immediate value of LDI insn. */
27018 + BFD_RELOC_AVR_LO8_LDI,
27020 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
27021 +of data memory address) into 8 bit immediate value of LDI insn. */
27022 + BFD_RELOC_AVR_HI8_LDI,
27024 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
27025 +of program memory address) into 8 bit immediate value of LDI insn. */
27026 + BFD_RELOC_AVR_HH8_LDI,
27028 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
27029 +(usually data memory address) into 8 bit immediate value of SUBI insn. */
27030 + BFD_RELOC_AVR_LO8_LDI_NEG,
27032 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
27033 +(high 8 bit of data memory address) into 8 bit immediate value of
27035 + BFD_RELOC_AVR_HI8_LDI_NEG,
27037 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
27038 +(most high 8 bit of program memory address) into 8 bit immediate value
27039 +of LDI or SUBI insn. */
27040 + BFD_RELOC_AVR_HH8_LDI_NEG,
27042 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually
27043 +command address) into 8 bit immediate value of LDI insn. */
27044 + BFD_RELOC_AVR_LO8_LDI_PM,
27046 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
27047 +of command address) into 8 bit immediate value of LDI insn. */
27048 + BFD_RELOC_AVR_HI8_LDI_PM,
27050 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
27051 +of command address) into 8 bit immediate value of LDI insn. */
27052 + BFD_RELOC_AVR_HH8_LDI_PM,
27054 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
27055 +(usually command address) into 8 bit immediate value of SUBI insn. */
27056 + BFD_RELOC_AVR_LO8_LDI_PM_NEG,
27058 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
27059 +(high 8 bit of 16 bit command address) into 8 bit immediate value
27061 + BFD_RELOC_AVR_HI8_LDI_PM_NEG,
27063 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
27064 +(high 6 bit of 22 bit command address) into 8 bit immediate
27065 +value of SUBI insn. */
27066 + BFD_RELOC_AVR_HH8_LDI_PM_NEG,
27068 +/* This is a 32 bit reloc for the AVR that stores 23 bit value
27070 + BFD_RELOC_AVR_CALL,
27072 +/* This is a 16 bit reloc for the AVR that stores all needed bits
27073 +for absolute addressing with ldi with overflow check to linktime */
27074 + BFD_RELOC_AVR_LDI,
27076 +/* This is a 6 bit reloc for the AVR that stores offset for ldd/std
27080 +/* This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw
27082 + BFD_RELOC_AVR_6_ADIW,
27084 +/* Direct 12 bit. */
27085 + BFD_RELOC_390_12,
27087 +/* 12 bit GOT offset. */
27088 + BFD_RELOC_390_GOT12,
27090 +/* 32 bit PC relative PLT address. */
27091 + BFD_RELOC_390_PLT32,
27093 +/* Copy symbol at runtime. */
27094 + BFD_RELOC_390_COPY,
27096 +/* Create GOT entry. */
27097 + BFD_RELOC_390_GLOB_DAT,
27099 +/* Create PLT entry. */
27100 + BFD_RELOC_390_JMP_SLOT,
27102 +/* Adjust by program base. */
27103 + BFD_RELOC_390_RELATIVE,
27105 +/* 32 bit PC relative offset to GOT. */
27106 + BFD_RELOC_390_GOTPC,
27108 +/* 16 bit GOT offset. */
27109 + BFD_RELOC_390_GOT16,
27111 +/* PC relative 16 bit shifted by 1. */
27112 + BFD_RELOC_390_PC16DBL,
27114 +/* 16 bit PC rel. PLT shifted by 1. */
27115 + BFD_RELOC_390_PLT16DBL,
27117 +/* PC relative 32 bit shifted by 1. */
27118 + BFD_RELOC_390_PC32DBL,
27120 +/* 32 bit PC rel. PLT shifted by 1. */
27121 + BFD_RELOC_390_PLT32DBL,
27123 +/* 32 bit PC rel. GOT shifted by 1. */
27124 + BFD_RELOC_390_GOTPCDBL,
27126 +/* 64 bit GOT offset. */
27127 + BFD_RELOC_390_GOT64,
27129 +/* 64 bit PC relative PLT address. */
27130 + BFD_RELOC_390_PLT64,
27132 +/* 32 bit rel. offset to GOT entry. */
27133 + BFD_RELOC_390_GOTENT,
27135 +/* 64 bit offset to GOT. */
27136 + BFD_RELOC_390_GOTOFF64,
27138 +/* 12-bit offset to symbol-entry within GOT, with PLT handling. */
27139 + BFD_RELOC_390_GOTPLT12,
27141 +/* 16-bit offset to symbol-entry within GOT, with PLT handling. */
27142 + BFD_RELOC_390_GOTPLT16,
27144 +/* 32-bit offset to symbol-entry within GOT, with PLT handling. */
27145 + BFD_RELOC_390_GOTPLT32,
27147 +/* 64-bit offset to symbol-entry within GOT, with PLT handling. */
27148 + BFD_RELOC_390_GOTPLT64,
27150 +/* 32-bit rel. offset to symbol-entry within GOT, with PLT handling. */
27151 + BFD_RELOC_390_GOTPLTENT,
27153 +/* 16-bit rel. offset from the GOT to a PLT entry. */
27154 + BFD_RELOC_390_PLTOFF16,
27156 +/* 32-bit rel. offset from the GOT to a PLT entry. */
27157 + BFD_RELOC_390_PLTOFF32,
27159 +/* 64-bit rel. offset from the GOT to a PLT entry. */
27160 + BFD_RELOC_390_PLTOFF64,
27162 +/* s390 tls relocations. */
27163 + BFD_RELOC_390_TLS_LOAD,
27164 + BFD_RELOC_390_TLS_GDCALL,
27165 + BFD_RELOC_390_TLS_LDCALL,
27166 + BFD_RELOC_390_TLS_GD32,
27167 + BFD_RELOC_390_TLS_GD64,
27168 + BFD_RELOC_390_TLS_GOTIE12,
27169 + BFD_RELOC_390_TLS_GOTIE32,
27170 + BFD_RELOC_390_TLS_GOTIE64,
27171 + BFD_RELOC_390_TLS_LDM32,
27172 + BFD_RELOC_390_TLS_LDM64,
27173 + BFD_RELOC_390_TLS_IE32,
27174 + BFD_RELOC_390_TLS_IE64,
27175 + BFD_RELOC_390_TLS_IEENT,
27176 + BFD_RELOC_390_TLS_LE32,
27177 + BFD_RELOC_390_TLS_LE64,
27178 + BFD_RELOC_390_TLS_LDO32,
27179 + BFD_RELOC_390_TLS_LDO64,
27180 + BFD_RELOC_390_TLS_DTPMOD,
27181 + BFD_RELOC_390_TLS_DTPOFF,
27182 + BFD_RELOC_390_TLS_TPOFF,
27184 +/* Long displacement extension. */
27185 + BFD_RELOC_390_20,
27186 + BFD_RELOC_390_GOT20,
27187 + BFD_RELOC_390_GOTPLT20,
27188 + BFD_RELOC_390_TLS_GOTIE20,
27190 +/* Scenix IP2K - 9-bit register number / data address */
27191 + BFD_RELOC_IP2K_FR9,
27193 +/* Scenix IP2K - 4-bit register/data bank number */
27194 + BFD_RELOC_IP2K_BANK,
27196 +/* Scenix IP2K - low 13 bits of instruction word address */
27197 + BFD_RELOC_IP2K_ADDR16CJP,
27199 +/* Scenix IP2K - high 3 bits of instruction word address */
27200 + BFD_RELOC_IP2K_PAGE3,
27202 +/* Scenix IP2K - ext/low/high 8 bits of data address */
27203 + BFD_RELOC_IP2K_LO8DATA,
27204 + BFD_RELOC_IP2K_HI8DATA,
27205 + BFD_RELOC_IP2K_EX8DATA,
27207 +/* Scenix IP2K - low/high 8 bits of instruction word address */
27208 + BFD_RELOC_IP2K_LO8INSN,
27209 + BFD_RELOC_IP2K_HI8INSN,
27211 +/* Scenix IP2K - even/odd PC modifier to modify snb pcl.0 */
27212 + BFD_RELOC_IP2K_PC_SKIP,
27214 +/* Scenix IP2K - 16 bit word address in text section. */
27215 + BFD_RELOC_IP2K_TEXT,
27217 +/* Scenix IP2K - 7-bit sp or dp offset */
27218 + BFD_RELOC_IP2K_FR_OFFSET,
27220 +/* Scenix VPE4K coprocessor - data/insn-space addressing */
27221 + BFD_RELOC_VPE4KMATH_DATA,
27222 + BFD_RELOC_VPE4KMATH_INSN,
27224 +/* These two relocations are used by the linker to determine which of
27225 +the entries in a C++ virtual function table are actually used. When
27226 +the --gc-sections option is given, the linker will zero out the entries
27227 +that are not used, so that the code for those functions need not be
27228 +included in the output.
27230 +VTABLE_INHERIT is a zero-space relocation used to describe to the
27231 +linker the inheritance tree of a C++ virtual function table. The
27232 +relocation's symbol should be the parent class' vtable, and the
27233 +relocation should be located at the child vtable.
27235 +VTABLE_ENTRY is a zero-space relocation that describes the use of a
27236 +virtual function table entry. The reloc's symbol should refer to the
27237 +table of the class mentioned in the code. Off of that base, an offset
27238 +describes the entry that is being used. For Rela hosts, this offset
27239 +is stored in the reloc's addend. For Rel hosts, we are forced to put
27240 +this offset in the reloc's section offset. */
27241 + BFD_RELOC_VTABLE_INHERIT,
27242 + BFD_RELOC_VTABLE_ENTRY,
27244 +/* Intel IA64 Relocations. */
27245 + BFD_RELOC_IA64_IMM14,
27246 + BFD_RELOC_IA64_IMM22,
27247 + BFD_RELOC_IA64_IMM64,
27248 + BFD_RELOC_IA64_DIR32MSB,
27249 + BFD_RELOC_IA64_DIR32LSB,
27250 + BFD_RELOC_IA64_DIR64MSB,
27251 + BFD_RELOC_IA64_DIR64LSB,
27252 + BFD_RELOC_IA64_GPREL22,
27253 + BFD_RELOC_IA64_GPREL64I,
27254 + BFD_RELOC_IA64_GPREL32MSB,
27255 + BFD_RELOC_IA64_GPREL32LSB,
27256 + BFD_RELOC_IA64_GPREL64MSB,
27257 + BFD_RELOC_IA64_GPREL64LSB,
27258 + BFD_RELOC_IA64_LTOFF22,
27259 + BFD_RELOC_IA64_LTOFF64I,
27260 + BFD_RELOC_IA64_PLTOFF22,
27261 + BFD_RELOC_IA64_PLTOFF64I,
27262 + BFD_RELOC_IA64_PLTOFF64MSB,
27263 + BFD_RELOC_IA64_PLTOFF64LSB,
27264 + BFD_RELOC_IA64_FPTR64I,
27265 + BFD_RELOC_IA64_FPTR32MSB,
27266 + BFD_RELOC_IA64_FPTR32LSB,
27267 + BFD_RELOC_IA64_FPTR64MSB,
27268 + BFD_RELOC_IA64_FPTR64LSB,
27269 + BFD_RELOC_IA64_PCREL21B,
27270 + BFD_RELOC_IA64_PCREL21BI,
27271 + BFD_RELOC_IA64_PCREL21M,
27272 + BFD_RELOC_IA64_PCREL21F,
27273 + BFD_RELOC_IA64_PCREL22,
27274 + BFD_RELOC_IA64_PCREL60B,
27275 + BFD_RELOC_IA64_PCREL64I,
27276 + BFD_RELOC_IA64_PCREL32MSB,
27277 + BFD_RELOC_IA64_PCREL32LSB,
27278 + BFD_RELOC_IA64_PCREL64MSB,
27279 + BFD_RELOC_IA64_PCREL64LSB,
27280 + BFD_RELOC_IA64_LTOFF_FPTR22,
27281 + BFD_RELOC_IA64_LTOFF_FPTR64I,
27282 + BFD_RELOC_IA64_LTOFF_FPTR32MSB,
27283 + BFD_RELOC_IA64_LTOFF_FPTR32LSB,
27284 + BFD_RELOC_IA64_LTOFF_FPTR64MSB,
27285 + BFD_RELOC_IA64_LTOFF_FPTR64LSB,
27286 + BFD_RELOC_IA64_SEGREL32MSB,
27287 + BFD_RELOC_IA64_SEGREL32LSB,
27288 + BFD_RELOC_IA64_SEGREL64MSB,
27289 + BFD_RELOC_IA64_SEGREL64LSB,
27290 + BFD_RELOC_IA64_SECREL32MSB,
27291 + BFD_RELOC_IA64_SECREL32LSB,
27292 + BFD_RELOC_IA64_SECREL64MSB,
27293 + BFD_RELOC_IA64_SECREL64LSB,
27294 + BFD_RELOC_IA64_REL32MSB,
27295 + BFD_RELOC_IA64_REL32LSB,
27296 + BFD_RELOC_IA64_REL64MSB,
27297 + BFD_RELOC_IA64_REL64LSB,
27298 + BFD_RELOC_IA64_LTV32MSB,
27299 + BFD_RELOC_IA64_LTV32LSB,
27300 + BFD_RELOC_IA64_LTV64MSB,
27301 + BFD_RELOC_IA64_LTV64LSB,
27302 + BFD_RELOC_IA64_IPLTMSB,
27303 + BFD_RELOC_IA64_IPLTLSB,
27304 + BFD_RELOC_IA64_COPY,
27305 + BFD_RELOC_IA64_LTOFF22X,
27306 + BFD_RELOC_IA64_LDXMOV,
27307 + BFD_RELOC_IA64_TPREL14,
27308 + BFD_RELOC_IA64_TPREL22,
27309 + BFD_RELOC_IA64_TPREL64I,
27310 + BFD_RELOC_IA64_TPREL64MSB,
27311 + BFD_RELOC_IA64_TPREL64LSB,
27312 + BFD_RELOC_IA64_LTOFF_TPREL22,
27313 + BFD_RELOC_IA64_DTPMOD64MSB,
27314 + BFD_RELOC_IA64_DTPMOD64LSB,
27315 + BFD_RELOC_IA64_LTOFF_DTPMOD22,
27316 + BFD_RELOC_IA64_DTPREL14,
27317 + BFD_RELOC_IA64_DTPREL22,
27318 + BFD_RELOC_IA64_DTPREL64I,
27319 + BFD_RELOC_IA64_DTPREL32MSB,
27320 + BFD_RELOC_IA64_DTPREL32LSB,
27321 + BFD_RELOC_IA64_DTPREL64MSB,
27322 + BFD_RELOC_IA64_DTPREL64LSB,
27323 + BFD_RELOC_IA64_LTOFF_DTPREL22,
27325 +/* Motorola 68HC11 reloc.
27326 +This is the 8 bit high part of an absolute address. */
27327 + BFD_RELOC_M68HC11_HI8,
27329 +/* Motorola 68HC11 reloc.
27330 +This is the 8 bit low part of an absolute address. */
27331 + BFD_RELOC_M68HC11_LO8,
27333 +/* Motorola 68HC11 reloc.
27334 +This is the 3 bit of a value. */
27335 + BFD_RELOC_M68HC11_3B,
27337 +/* Motorola 68HC11 reloc.
27338 +This reloc marks the beginning of a jump/call instruction.
27339 +It is used for linker relaxation to correctly identify beginning
27340 +of instruction and change some branches to use PC-relative
27341 +addressing mode. */
27342 + BFD_RELOC_M68HC11_RL_JUMP,
27344 +/* Motorola 68HC11 reloc.
27345 +This reloc marks a group of several instructions that gcc generates
27346 +and for which the linker relaxation pass can modify and/or remove
27348 + BFD_RELOC_M68HC11_RL_GROUP,
27350 +/* Motorola 68HC11 reloc.
27351 +This is the 16-bit lower part of an address. It is used for 'call'
27352 +instruction to specify the symbol address without any special
27353 +transformation (due to memory bank window). */
27354 + BFD_RELOC_M68HC11_LO16,
27356 +/* Motorola 68HC11 reloc.
27357 +This is a 8-bit reloc that specifies the page number of an address.
27358 +It is used by 'call' instruction to specify the page number of
27360 + BFD_RELOC_M68HC11_PAGE,
27362 +/* Motorola 68HC11 reloc.
27363 +This is a 24-bit reloc that represents the address with a 16-bit
27364 +value and a 8-bit page number. The symbol address is transformed
27365 +to follow the 16K memory bank of 68HC12 (seen as mapped in the window). */
27366 + BFD_RELOC_M68HC11_24,
27368 +/* Motorola 68HC12 reloc.
27369 +This is the 5 bits of a value. */
27370 + BFD_RELOC_M68HC12_5B,
27372 +/* NS CR16C Relocations. */
27373 + BFD_RELOC_16C_NUM08,
27374 + BFD_RELOC_16C_NUM08_C,
27375 + BFD_RELOC_16C_NUM16,
27376 + BFD_RELOC_16C_NUM16_C,
27377 + BFD_RELOC_16C_NUM32,
27378 + BFD_RELOC_16C_NUM32_C,
27379 + BFD_RELOC_16C_DISP04,
27380 + BFD_RELOC_16C_DISP04_C,
27381 + BFD_RELOC_16C_DISP08,
27382 + BFD_RELOC_16C_DISP08_C,
27383 + BFD_RELOC_16C_DISP16,
27384 + BFD_RELOC_16C_DISP16_C,
27385 + BFD_RELOC_16C_DISP24,
27386 + BFD_RELOC_16C_DISP24_C,
27387 + BFD_RELOC_16C_DISP24a,
27388 + BFD_RELOC_16C_DISP24a_C,
27389 + BFD_RELOC_16C_REG04,
27390 + BFD_RELOC_16C_REG04_C,
27391 + BFD_RELOC_16C_REG04a,
27392 + BFD_RELOC_16C_REG04a_C,
27393 + BFD_RELOC_16C_REG14,
27394 + BFD_RELOC_16C_REG14_C,
27395 + BFD_RELOC_16C_REG16,
27396 + BFD_RELOC_16C_REG16_C,
27397 + BFD_RELOC_16C_REG20,
27398 + BFD_RELOC_16C_REG20_C,
27399 + BFD_RELOC_16C_ABS20,
27400 + BFD_RELOC_16C_ABS20_C,
27401 + BFD_RELOC_16C_ABS24,
27402 + BFD_RELOC_16C_ABS24_C,
27403 + BFD_RELOC_16C_IMM04,
27404 + BFD_RELOC_16C_IMM04_C,
27405 + BFD_RELOC_16C_IMM16,
27406 + BFD_RELOC_16C_IMM16_C,
27407 + BFD_RELOC_16C_IMM20,
27408 + BFD_RELOC_16C_IMM20_C,
27409 + BFD_RELOC_16C_IMM24,
27410 + BFD_RELOC_16C_IMM24_C,
27411 + BFD_RELOC_16C_IMM32,
27412 + BFD_RELOC_16C_IMM32_C,
27414 +/* NS CRX Relocations. */
27415 + BFD_RELOC_CRX_REL4,
27416 + BFD_RELOC_CRX_REL8,
27417 + BFD_RELOC_CRX_REL8_CMP,
27418 + BFD_RELOC_CRX_REL16,
27419 + BFD_RELOC_CRX_REL24,
27420 + BFD_RELOC_CRX_REL32,
27421 + BFD_RELOC_CRX_REGREL12,
27422 + BFD_RELOC_CRX_REGREL22,
27423 + BFD_RELOC_CRX_REGREL28,
27424 + BFD_RELOC_CRX_REGREL32,
27425 + BFD_RELOC_CRX_ABS16,
27426 + BFD_RELOC_CRX_ABS32,
27427 + BFD_RELOC_CRX_NUM8,
27428 + BFD_RELOC_CRX_NUM16,
27429 + BFD_RELOC_CRX_NUM32,
27430 + BFD_RELOC_CRX_IMM16,
27431 + BFD_RELOC_CRX_IMM32,
27432 + BFD_RELOC_CRX_SWITCH8,
27433 + BFD_RELOC_CRX_SWITCH16,
27434 + BFD_RELOC_CRX_SWITCH32,
27436 +/* These relocs are only used within the CRIS assembler. They are not
27437 +(at present) written to any object files. */
27438 + BFD_RELOC_CRIS_BDISP8,
27439 + BFD_RELOC_CRIS_UNSIGNED_5,
27440 + BFD_RELOC_CRIS_SIGNED_6,
27441 + BFD_RELOC_CRIS_UNSIGNED_6,
27442 + BFD_RELOC_CRIS_SIGNED_8,
27443 + BFD_RELOC_CRIS_UNSIGNED_8,
27444 + BFD_RELOC_CRIS_SIGNED_16,
27445 + BFD_RELOC_CRIS_UNSIGNED_16,
27446 + BFD_RELOC_CRIS_LAPCQ_OFFSET,
27447 + BFD_RELOC_CRIS_UNSIGNED_4,
27449 +/* Relocs used in ELF shared libraries for CRIS. */
27450 + BFD_RELOC_CRIS_COPY,
27451 + BFD_RELOC_CRIS_GLOB_DAT,
27452 + BFD_RELOC_CRIS_JUMP_SLOT,
27453 + BFD_RELOC_CRIS_RELATIVE,
27455 +/* 32-bit offset to symbol-entry within GOT. */
27456 + BFD_RELOC_CRIS_32_GOT,
27458 +/* 16-bit offset to symbol-entry within GOT. */
27459 + BFD_RELOC_CRIS_16_GOT,
27461 +/* 32-bit offset to symbol-entry within GOT, with PLT handling. */
27462 + BFD_RELOC_CRIS_32_GOTPLT,
27464 +/* 16-bit offset to symbol-entry within GOT, with PLT handling. */
27465 + BFD_RELOC_CRIS_16_GOTPLT,
27467 +/* 32-bit offset to symbol, relative to GOT. */
27468 + BFD_RELOC_CRIS_32_GOTREL,
27470 +/* 32-bit offset to symbol with PLT entry, relative to GOT. */
27471 + BFD_RELOC_CRIS_32_PLT_GOTREL,
27473 +/* 32-bit offset to symbol with PLT entry, relative to this relocation. */
27474 + BFD_RELOC_CRIS_32_PLT_PCREL,
27476 +/* Intel i860 Relocations. */
27477 + BFD_RELOC_860_COPY,
27478 + BFD_RELOC_860_GLOB_DAT,
27479 + BFD_RELOC_860_JUMP_SLOT,
27480 + BFD_RELOC_860_RELATIVE,
27481 + BFD_RELOC_860_PC26,
27482 + BFD_RELOC_860_PLT26,
27483 + BFD_RELOC_860_PC16,
27484 + BFD_RELOC_860_LOW0,
27485 + BFD_RELOC_860_SPLIT0,
27486 + BFD_RELOC_860_LOW1,
27487 + BFD_RELOC_860_SPLIT1,
27488 + BFD_RELOC_860_LOW2,
27489 + BFD_RELOC_860_SPLIT2,
27490 + BFD_RELOC_860_LOW3,
27491 + BFD_RELOC_860_LOGOT0,
27492 + BFD_RELOC_860_SPGOT0,
27493 + BFD_RELOC_860_LOGOT1,
27494 + BFD_RELOC_860_SPGOT1,
27495 + BFD_RELOC_860_LOGOTOFF0,
27496 + BFD_RELOC_860_SPGOTOFF0,
27497 + BFD_RELOC_860_LOGOTOFF1,
27498 + BFD_RELOC_860_SPGOTOFF1,
27499 + BFD_RELOC_860_LOGOTOFF2,
27500 + BFD_RELOC_860_LOGOTOFF3,
27501 + BFD_RELOC_860_LOPC,
27502 + BFD_RELOC_860_HIGHADJ,
27503 + BFD_RELOC_860_HAGOT,
27504 + BFD_RELOC_860_HAGOTOFF,
27505 + BFD_RELOC_860_HAPC,
27506 + BFD_RELOC_860_HIGH,
27507 + BFD_RELOC_860_HIGOT,
27508 + BFD_RELOC_860_HIGOTOFF,
27510 +/* OpenRISC Relocations. */
27511 + BFD_RELOC_OPENRISC_ABS_26,
27512 + BFD_RELOC_OPENRISC_REL_26,
27514 +/* H8 elf Relocations. */
27515 + BFD_RELOC_H8_DIR16A8,
27516 + BFD_RELOC_H8_DIR16R8,
27517 + BFD_RELOC_H8_DIR24A8,
27518 + BFD_RELOC_H8_DIR24R8,
27519 + BFD_RELOC_H8_DIR32A16,
27521 +/* Sony Xstormy16 Relocations. */
27522 + BFD_RELOC_XSTORMY16_REL_12,
27523 + BFD_RELOC_XSTORMY16_12,
27524 + BFD_RELOC_XSTORMY16_24,
27525 + BFD_RELOC_XSTORMY16_FPTR16,
27527 +/* Relocations used by VAX ELF. */
27528 + BFD_RELOC_VAX_GLOB_DAT,
27529 + BFD_RELOC_VAX_JMP_SLOT,
27530 + BFD_RELOC_VAX_RELATIVE,
27532 +/* Morpho MS1 - 16 bit immediate relocation. */
27533 + BFD_RELOC_MS1_PC16,
27535 +/* Morpho MS1 - Hi 16 bits of an address. */
27536 + BFD_RELOC_MS1_HI16,
27538 +/* Morpho MS1 - Low 16 bits of an address. */
27539 + BFD_RELOC_MS1_LO16,
27541 +/* Morpho MS1 - Used to tell the linker which vtable entries are used. */
27542 + BFD_RELOC_MS1_GNU_VTINHERIT,
27544 +/* Morpho MS1 - Used to tell the linker which vtable entries are used. */
27545 + BFD_RELOC_MS1_GNU_VTENTRY,
27547 +/* msp430 specific relocation codes */
27548 + BFD_RELOC_MSP430_10_PCREL,
27549 + BFD_RELOC_MSP430_16_PCREL,
27550 + BFD_RELOC_MSP430_16,
27551 + BFD_RELOC_MSP430_16_PCREL_BYTE,
27552 + BFD_RELOC_MSP430_16_BYTE,
27553 + BFD_RELOC_MSP430_2X_PCREL,
27554 + BFD_RELOC_MSP430_RL_PCREL,
27556 +/* IQ2000 Relocations. */
27557 + BFD_RELOC_IQ2000_OFFSET_16,
27558 + BFD_RELOC_IQ2000_OFFSET_21,
27559 + BFD_RELOC_IQ2000_UHI16,
27561 +/* Special Xtensa relocation used only by PLT entries in ELF shared
27562 +objects to indicate that the runtime linker should set the value
27563 +to one of its own internal functions or data structures. */
27564 + BFD_RELOC_XTENSA_RTLD,
27566 +/* Xtensa relocations for ELF shared objects. */
27567 + BFD_RELOC_XTENSA_GLOB_DAT,
27568 + BFD_RELOC_XTENSA_JMP_SLOT,
27569 + BFD_RELOC_XTENSA_RELATIVE,
27571 +/* Xtensa relocation used in ELF object files for symbols that may require
27572 +PLT entries. Otherwise, this is just a generic 32-bit relocation. */
27573 + BFD_RELOC_XTENSA_PLT,
27575 +/* Xtensa relocations to mark the difference of two local symbols.
27576 +These are only needed to support linker relaxation and can be ignored
27577 +when not relaxing. The field is set to the value of the difference
27578 +assuming no relaxation. The relocation encodes the position of the
27579 +first symbol so the linker can determine whether to adjust the field
27581 + BFD_RELOC_XTENSA_DIFF8,
27582 + BFD_RELOC_XTENSA_DIFF16,
27583 + BFD_RELOC_XTENSA_DIFF32,
27585 +/* Generic Xtensa relocations for instruction operands. Only the slot
27586 +number is encoded in the relocation. The relocation applies to the
27587 +last PC-relative immediate operand, or if there are no PC-relative
27588 +immediates, to the last immediate operand. */
27589 + BFD_RELOC_XTENSA_SLOT0_OP,
27590 + BFD_RELOC_XTENSA_SLOT1_OP,
27591 + BFD_RELOC_XTENSA_SLOT2_OP,
27592 + BFD_RELOC_XTENSA_SLOT3_OP,
27593 + BFD_RELOC_XTENSA_SLOT4_OP,
27594 + BFD_RELOC_XTENSA_SLOT5_OP,
27595 + BFD_RELOC_XTENSA_SLOT6_OP,
27596 + BFD_RELOC_XTENSA_SLOT7_OP,
27597 + BFD_RELOC_XTENSA_SLOT8_OP,
27598 + BFD_RELOC_XTENSA_SLOT9_OP,
27599 + BFD_RELOC_XTENSA_SLOT10_OP,
27600 + BFD_RELOC_XTENSA_SLOT11_OP,
27601 + BFD_RELOC_XTENSA_SLOT12_OP,
27602 + BFD_RELOC_XTENSA_SLOT13_OP,
27603 + BFD_RELOC_XTENSA_SLOT14_OP,
27605 +/* Alternate Xtensa relocations. Only the slot is encoded in the
27606 +relocation. The meaning of these relocations is opcode-specific. */
27607 + BFD_RELOC_XTENSA_SLOT0_ALT,
27608 + BFD_RELOC_XTENSA_SLOT1_ALT,
27609 + BFD_RELOC_XTENSA_SLOT2_ALT,
27610 + BFD_RELOC_XTENSA_SLOT3_ALT,
27611 + BFD_RELOC_XTENSA_SLOT4_ALT,
27612 + BFD_RELOC_XTENSA_SLOT5_ALT,
27613 + BFD_RELOC_XTENSA_SLOT6_ALT,
27614 + BFD_RELOC_XTENSA_SLOT7_ALT,
27615 + BFD_RELOC_XTENSA_SLOT8_ALT,
27616 + BFD_RELOC_XTENSA_SLOT9_ALT,
27617 + BFD_RELOC_XTENSA_SLOT10_ALT,
27618 + BFD_RELOC_XTENSA_SLOT11_ALT,
27619 + BFD_RELOC_XTENSA_SLOT12_ALT,
27620 + BFD_RELOC_XTENSA_SLOT13_ALT,
27621 + BFD_RELOC_XTENSA_SLOT14_ALT,
27623 +/* Xtensa relocations for backward compatibility. These have all been
27624 +replaced by BFD_RELOC_XTENSA_SLOT0_OP. */
27625 + BFD_RELOC_XTENSA_OP0,
27626 + BFD_RELOC_XTENSA_OP1,
27627 + BFD_RELOC_XTENSA_OP2,
27629 +/* Xtensa relocation to mark that the assembler expanded the
27630 +instructions from an original target. The expansion size is
27631 +encoded in the reloc size. */
27632 + BFD_RELOC_XTENSA_ASM_EXPAND,
27634 +/* Xtensa relocation to mark that the linker should simplify
27635 +assembler-expanded instructions. This is commonly used
27636 +internally by the linker after analysis of a
27637 +BFD_RELOC_XTENSA_ASM_EXPAND. */
27638 + BFD_RELOC_XTENSA_ASM_SIMPLIFY,
27639 + BFD_RELOC_UNUSED };
27640 +typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
27641 +reloc_howto_type *bfd_reloc_type_lookup
27642 + (bfd *abfd, bfd_reloc_code_real_type code);
27644 +const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
27646 +/* Extracted from syms.c. */
27648 +typedef struct bfd_symbol
27650 + /* A pointer to the BFD which owns the symbol. This information
27651 + is necessary so that a back end can work out what additional
27652 + information (invisible to the application writer) is carried
27655 + This field is *almost* redundant, since you can use section->owner
27656 + instead, except that some symbols point to the global sections
27657 + bfd_{abs,com,und}_section. This could be fixed by making
27658 + these globals be per-bfd (or per-target-flavor). FIXME. */
27659 + struct bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */
27661 + /* The text of the symbol. The name is left alone, and not copied; the
27662 + application may not alter it. */
27663 + const char *name;
27665 + /* The value of the symbol. This really should be a union of a
27666 + numeric value with a pointer, since some flags indicate that
27667 + a pointer to another symbol is stored here. */
27670 + /* Attributes of a symbol. */
27671 +#define BSF_NO_FLAGS 0x00
27673 + /* The symbol has local scope; <<static>> in <<C>>. The value
27674 + is the offset into the section of the data. */
27675 +#define BSF_LOCAL 0x01
27677 + /* The symbol has global scope; initialized data in <<C>>. The
27678 + value is the offset into the section of the data. */
27679 +#define BSF_GLOBAL 0x02
27681 + /* The symbol has global scope and is exported. The value is
27682 + the offset into the section of the data. */
27683 +#define BSF_EXPORT BSF_GLOBAL /* No real difference. */
27685 + /* A normal C symbol would be one of:
27686 + <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
27687 + <<BSF_GLOBAL>>. */
27689 + /* The symbol is a debugging record. The value has an arbitrary
27690 + meaning, unless BSF_DEBUGGING_RELOC is also set. */
27691 +#define BSF_DEBUGGING 0x08
27693 + /* The symbol denotes a function entry point. Used in ELF,
27694 + perhaps others someday. */
27695 +#define BSF_FUNCTION 0x10
27697 + /* Used by the linker. */
27698 +#define BSF_KEEP 0x20
27699 +#define BSF_KEEP_G 0x40
27701 + /* A weak global symbol, overridable without warnings by
27702 + a regular global symbol of the same name. */
27703 +#define BSF_WEAK 0x80
27705 + /* This symbol was created to point to a section, e.g. ELF's
27706 + STT_SECTION symbols. */
27707 +#define BSF_SECTION_SYM 0x100
27709 + /* The symbol used to be a common symbol, but now it is
27711 +#define BSF_OLD_COMMON 0x200
27713 + /* The default value for common data. */
27714 +#define BFD_FORT_COMM_DEFAULT_VALUE 0
27716 + /* In some files the type of a symbol sometimes alters its
27717 + location in an output file - ie in coff a <<ISFCN>> symbol
27718 + which is also <<C_EXT>> symbol appears where it was
27719 + declared and not at the end of a section. This bit is set
27720 + by the target BFD part to convey this information. */
27721 +#define BSF_NOT_AT_END 0x400
27723 + /* Signal that the symbol is the label of constructor section. */
27724 +#define BSF_CONSTRUCTOR 0x800
27726 + /* Signal that the symbol is a warning symbol. The name is a
27727 + warning. The name of the next symbol is the one to warn about;
27728 + if a reference is made to a symbol with the same name as the next
27729 + symbol, a warning is issued by the linker. */
27730 +#define BSF_WARNING 0x1000
27732 + /* Signal that the symbol is indirect. This symbol is an indirect
27733 + pointer to the symbol with the same name as the next symbol. */
27734 +#define BSF_INDIRECT 0x2000
27736 + /* BSF_FILE marks symbols that contain a file name. This is used
27737 + for ELF STT_FILE symbols. */
27738 +#define BSF_FILE 0x4000
27740 + /* Symbol is from dynamic linking information. */
27741 +#define BSF_DYNAMIC 0x8000
27743 + /* The symbol denotes a data object. Used in ELF, and perhaps
27744 + others someday. */
27745 +#define BSF_OBJECT 0x10000
27747 + /* This symbol is a debugging symbol. The value is the offset
27748 + into the section of the data. BSF_DEBUGGING should be set
27750 +#define BSF_DEBUGGING_RELOC 0x20000
27752 + /* This symbol is thread local. Used in ELF. */
27753 +#define BSF_THREAD_LOCAL 0x40000
27757 + /* A pointer to the section to which this symbol is
27758 + relative. This will always be non NULL, there are special
27759 + sections for undefined and absolute symbols. */
27760 + struct bfd_section *section;
27762 + /* Back end special data. */
27772 +#define bfd_get_symtab_upper_bound(abfd) \
27773 + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
27775 +bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym);
27777 +bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name);
27779 +#define bfd_is_local_label_name(abfd, name) \
27780 + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
27782 +bfd_boolean bfd_is_target_special_symbol (bfd *abfd, asymbol *sym);
27784 +#define bfd_is_target_special_symbol(abfd, sym) \
27785 + BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym))
27787 +#define bfd_canonicalize_symtab(abfd, location) \
27788 + BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location))
27790 +bfd_boolean bfd_set_symtab
27791 + (bfd *abfd, asymbol **location, unsigned int count);
27793 +void bfd_print_symbol_vandf (bfd *abfd, void *file, asymbol *symbol);
27795 +#define bfd_make_empty_symbol(abfd) \
27796 + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
27798 +asymbol *_bfd_generic_make_empty_symbol (bfd *);
27800 +#define bfd_make_debug_symbol(abfd,ptr,size) \
27801 + BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
27803 +int bfd_decode_symclass (asymbol *symbol);
27805 +bfd_boolean bfd_is_undefined_symclass (int symclass);
27807 +void bfd_symbol_info (asymbol *symbol, symbol_info *ret);
27809 +bfd_boolean bfd_copy_private_symbol_data
27810 + (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
27812 +#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
27813 + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
27814 + (ibfd, isymbol, obfd, osymbol))
27816 +/* Extracted from bfd.c. */
27819 + /* A unique identifier of the BFD */
27822 + /* The filename the application opened the BFD with. */
27823 + const char *filename;
27825 + /* A pointer to the target jump table. */
27826 + const struct bfd_target *xvec;
27828 + /* The IOSTREAM, and corresponding IO vector that provide access
27829 + to the file backing the BFD. */
27831 + const struct bfd_iovec *iovec;
27833 + /* Is the file descriptor being cached? That is, can it be closed as
27834 + needed, and re-opened when accessed later? */
27835 + bfd_boolean cacheable;
27837 + /* Marks whether there was a default target specified when the
27838 + BFD was opened. This is used to select which matching algorithm
27839 + to use to choose the back end. */
27840 + bfd_boolean target_defaulted;
27842 + /* The caching routines use these to maintain a
27843 + least-recently-used list of BFDs. */
27844 + struct bfd *lru_prev, *lru_next;
27846 + /* When a file is closed by the caching routines, BFD retains
27847 + state information on the file here... */
27850 + /* ... and here: (``once'' means at least once). */
27851 + bfd_boolean opened_once;
27853 + /* Set if we have a locally maintained mtime value, rather than
27854 + getting it from the file each time. */
27855 + bfd_boolean mtime_set;
27857 + /* File modified time, if mtime_set is TRUE. */
27860 + /* Reserved for an unimplemented file locking extension. */
27863 + /* The format which belongs to the BFD. (object, core, etc.) */
27864 + bfd_format format;
27866 + /* The direction with which the BFD was opened. */
27867 + enum bfd_direction
27869 + no_direction = 0,
27870 + read_direction = 1,
27871 + write_direction = 2,
27872 + both_direction = 3
27876 + /* Format_specific flags. */
27879 + /* Currently my_archive is tested before adding origin to
27880 + anything. I believe that this can become always an add of
27881 + origin, with origin set to 0 for non archive files. */
27882 + ufile_ptr origin;
27884 + /* Remember when output has begun, to stop strange things
27885 + from happening. */
27886 + bfd_boolean output_has_begun;
27888 + /* A hash table for section names. */
27889 + struct bfd_hash_table section_htab;
27891 + /* Pointer to linked list of sections. */
27892 + struct bfd_section *sections;
27894 + /* The last section on the section list. */
27895 + struct bfd_section *section_last;
27897 + /* The number of sections. */
27898 + unsigned int section_count;
27900 + /* Stuff only useful for object files:
27901 + The start address. */
27902 + bfd_vma start_address;
27904 + /* Used for input and output. */
27905 + unsigned int symcount;
27907 + /* Symbol table for output BFD (with symcount entries). */
27908 + struct bfd_symbol **outsymbols;
27910 + /* Used for slurped dynamic symbol tables. */
27911 + unsigned int dynsymcount;
27913 + /* Pointer to structure which contains architecture information. */
27914 + const struct bfd_arch_info *arch_info;
27916 + /* Flag set if symbols from this BFD should not be exported. */
27917 + bfd_boolean no_export;
27919 + /* Stuff only useful for archives. */
27920 + void *arelt_data;
27921 + struct bfd *my_archive; /* The containing archive BFD. */
27922 + struct bfd *next; /* The next BFD in the archive. */
27923 + struct bfd *archive_head; /* The first BFD in the archive. */
27924 + bfd_boolean has_armap;
27926 + /* A chain of BFD structures involved in a link. */
27927 + struct bfd *link_next;
27929 + /* A field used by _bfd_generic_link_add_archive_symbols. This will
27930 + be used only for archive elements. */
27931 + int archive_pass;
27933 + /* Used by the back end to hold private data. */
27936 + struct aout_data_struct *aout_data;
27937 + struct artdata *aout_ar_data;
27938 + struct _oasys_data *oasys_obj_data;
27939 + struct _oasys_ar_data *oasys_ar_data;
27940 + struct coff_tdata *coff_obj_data;
27941 + struct pe_tdata *pe_obj_data;
27942 + struct xcoff_tdata *xcoff_obj_data;
27943 + struct ecoff_tdata *ecoff_obj_data;
27944 + struct ieee_data_struct *ieee_data;
27945 + struct ieee_ar_data_struct *ieee_ar_data;
27946 + struct srec_data_struct *srec_data;
27947 + struct ihex_data_struct *ihex_data;
27948 + struct tekhex_data_struct *tekhex_data;
27949 + struct elf_obj_tdata *elf_obj_data;
27950 + struct nlm_obj_tdata *nlm_obj_data;
27951 + struct bout_data_struct *bout_data;
27952 + struct mmo_data_struct *mmo_data;
27953 + struct sun_core_struct *sun_core_data;
27954 + struct sco5_core_struct *sco5_core_data;
27955 + struct trad_core_struct *trad_core_data;
27956 + struct som_data_struct *som_data;
27957 + struct hpux_core_struct *hpux_core_data;
27958 + struct hppabsd_core_struct *hppabsd_core_data;
27959 + struct sgi_core_struct *sgi_core_data;
27960 + struct lynx_core_struct *lynx_core_data;
27961 + struct osf_core_struct *osf_core_data;
27962 + struct cisco_core_struct *cisco_core_data;
27963 + struct versados_data_struct *versados_data;
27964 + struct netbsd_core_struct *netbsd_core_data;
27965 + struct mach_o_data_struct *mach_o_data;
27966 + struct mach_o_fat_data_struct *mach_o_fat_data;
27967 + struct bfd_pef_data_struct *pef_data;
27968 + struct bfd_pef_xlib_data_struct *pef_xlib_data;
27969 + struct bfd_sym_data_struct *sym_data;
27974 + /* Used by the application to hold private data. */
27977 + /* Where all the allocated stuff under this BFD goes. This is a
27978 + struct objalloc *, but we use void * to avoid requiring the inclusion
27979 + of objalloc.h. */
27983 +typedef enum bfd_error
27985 + bfd_error_no_error = 0,
27986 + bfd_error_system_call,
27987 + bfd_error_invalid_target,
27988 + bfd_error_wrong_format,
27989 + bfd_error_wrong_object_format,
27990 + bfd_error_invalid_operation,
27991 + bfd_error_no_memory,
27992 + bfd_error_no_symbols,
27993 + bfd_error_no_armap,
27994 + bfd_error_no_more_archived_files,
27995 + bfd_error_malformed_archive,
27996 + bfd_error_file_not_recognized,
27997 + bfd_error_file_ambiguously_recognized,
27998 + bfd_error_no_contents,
27999 + bfd_error_nonrepresentable_section,
28000 + bfd_error_no_debug_section,
28001 + bfd_error_bad_value,
28002 + bfd_error_file_truncated,
28003 + bfd_error_file_too_big,
28004 + bfd_error_invalid_error_code
28008 +bfd_error_type bfd_get_error (void);
28010 +void bfd_set_error (bfd_error_type error_tag);
28012 +const char *bfd_errmsg (bfd_error_type error_tag);
28014 +void bfd_perror (const char *message);
28016 +typedef void (*bfd_error_handler_type) (const char *, ...);
28018 +bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
28020 +void bfd_set_error_program_name (const char *);
28022 +bfd_error_handler_type bfd_get_error_handler (void);
28024 +long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect);
28026 +long bfd_canonicalize_reloc
28027 + (bfd *abfd, asection *sec, arelent **loc, asymbol **syms);
28029 +void bfd_set_reloc
28030 + (bfd *abfd, asection *sec, arelent **rel, unsigned int count);
28032 +bfd_boolean bfd_set_file_flags (bfd *abfd, flagword flags);
28034 +int bfd_get_arch_size (bfd *abfd);
28036 +int bfd_get_sign_extend_vma (bfd *abfd);
28038 +bfd_boolean bfd_set_start_address (bfd *abfd, bfd_vma vma);
28040 +unsigned int bfd_get_gp_size (bfd *abfd);
28042 +void bfd_set_gp_size (bfd *abfd, unsigned int i);
28044 +bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
28046 +bfd_boolean bfd_copy_private_header_data (bfd *ibfd, bfd *obfd);
28048 +#define bfd_copy_private_header_data(ibfd, obfd) \
28049 + BFD_SEND (obfd, _bfd_copy_private_header_data, \
28051 +bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd);
28053 +#define bfd_copy_private_bfd_data(ibfd, obfd) \
28054 + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \
28056 +bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
28058 +#define bfd_merge_private_bfd_data(ibfd, obfd) \
28059 + BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
28061 +bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags);
28063 +#define bfd_set_private_flags(abfd, flags) \
28064 + BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags))
28065 +#define bfd_sizeof_headers(abfd, reloc) \
28066 + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
28068 +#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
28069 + BFD_SEND (abfd, _bfd_find_nearest_line, \
28070 + (abfd, sec, syms, off, file, func, line))
28072 +#define bfd_find_line(abfd, syms, sym, file, line) \
28073 + BFD_SEND (abfd, _bfd_find_line, \
28074 + (abfd, syms, sym, file, line))
28076 +#define bfd_find_inliner_info(abfd, file, func, line) \
28077 + BFD_SEND (abfd, _bfd_find_inliner_info, \
28078 + (abfd, file, func, line))
28080 +#define bfd_debug_info_start(abfd) \
28081 + BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
28083 +#define bfd_debug_info_end(abfd) \
28084 + BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
28086 +#define bfd_debug_info_accumulate(abfd, section) \
28087 + BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
28089 +#define bfd_stat_arch_elt(abfd, stat) \
28090 + BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
28092 +#define bfd_update_armap_timestamp(abfd) \
28093 + BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
28095 +#define bfd_set_arch_mach(abfd, arch, mach)\
28096 + BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
28098 +#define bfd_relax_section(abfd, section, link_info, again) \
28099 + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
28101 +#define bfd_gc_sections(abfd, link_info) \
28102 + BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
28104 +#define bfd_merge_sections(abfd, link_info) \
28105 + BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
28107 +#define bfd_is_group_section(abfd, sec) \
28108 + BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec))
28110 +#define bfd_discard_group(abfd, sec) \
28111 + BFD_SEND (abfd, _bfd_discard_group, (abfd, sec))
28113 +#define bfd_link_hash_table_create(abfd) \
28114 + BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
28116 +#define bfd_link_hash_table_free(abfd, hash) \
28117 + BFD_SEND (abfd, _bfd_link_hash_table_free, (hash))
28119 +#define bfd_link_add_symbols(abfd, info) \
28120 + BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
28122 +#define bfd_link_just_syms(abfd, sec, info) \
28123 + BFD_SEND (abfd, _bfd_link_just_syms, (sec, info))
28125 +#define bfd_final_link(abfd, info) \
28126 + BFD_SEND (abfd, _bfd_final_link, (abfd, info))
28128 +#define bfd_free_cached_info(abfd) \
28129 + BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
28131 +#define bfd_get_dynamic_symtab_upper_bound(abfd) \
28132 + BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
28134 +#define bfd_print_private_bfd_data(abfd, file)\
28135 + BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
28137 +#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
28138 + BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
28140 +#define bfd_get_synthetic_symtab(abfd, count, syms, dyncount, dynsyms, ret) \
28141 + BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, count, syms, \
28142 + dyncount, dynsyms, ret))
28144 +#define bfd_get_dynamic_reloc_upper_bound(abfd) \
28145 + BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
28147 +#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
28148 + BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
28150 +extern bfd_byte *bfd_get_relocated_section_contents
28151 + (bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *,
28152 + bfd_boolean, asymbol **);
28154 +bfd_boolean bfd_alt_mach_code (bfd *abfd, int alternative);
28156 +struct bfd_preserve
28161 + const struct bfd_arch_info *arch_info;
28162 + struct bfd_section *sections;
28163 + struct bfd_section *section_last;
28164 + unsigned int section_count;
28165 + struct bfd_hash_table section_htab;
28168 +bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
28170 +void bfd_preserve_restore (bfd *, struct bfd_preserve *);
28172 +void bfd_preserve_finish (bfd *, struct bfd_preserve *);
28174 +/* Extracted from archive.c. */
28175 +symindex bfd_get_next_mapent
28176 + (bfd *abfd, symindex previous, carsym **sym);
28178 +bfd_boolean bfd_set_archive_head (bfd *output, bfd *new_head);
28180 +bfd *bfd_openr_next_archived_file (bfd *archive, bfd *previous);
28182 +/* Extracted from corefile.c. */
28183 +const char *bfd_core_file_failing_command (bfd *abfd);
28185 +int bfd_core_file_failing_signal (bfd *abfd);
28187 +bfd_boolean core_file_matches_executable_p
28188 + (bfd *core_bfd, bfd *exec_bfd);
28190 +/* Extracted from targets.c. */
28191 +#define BFD_SEND(bfd, message, arglist) \
28192 + ((*((bfd)->xvec->message)) arglist)
28194 +#ifdef DEBUG_BFD_SEND
28196 +#define BFD_SEND(bfd, message, arglist) \
28197 + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
28198 + ((*((bfd)->xvec->message)) arglist) : \
28199 + (bfd_assert (__FILE__,__LINE__), NULL))
28201 +#define BFD_SEND_FMT(bfd, message, arglist) \
28202 + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist)
28204 +#ifdef DEBUG_BFD_SEND
28205 +#undef BFD_SEND_FMT
28206 +#define BFD_SEND_FMT(bfd, message, arglist) \
28207 + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
28208 + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
28209 + (bfd_assert (__FILE__,__LINE__), NULL))
28214 + bfd_target_unknown_flavour,
28215 + bfd_target_aout_flavour,
28216 + bfd_target_coff_flavour,
28217 + bfd_target_ecoff_flavour,
28218 + bfd_target_xcoff_flavour,
28219 + bfd_target_elf_flavour,
28220 + bfd_target_ieee_flavour,
28221 + bfd_target_nlm_flavour,
28222 + bfd_target_oasys_flavour,
28223 + bfd_target_tekhex_flavour,
28224 + bfd_target_srec_flavour,
28225 + bfd_target_ihex_flavour,
28226 + bfd_target_som_flavour,
28227 + bfd_target_os9k_flavour,
28228 + bfd_target_versados_flavour,
28229 + bfd_target_msdos_flavour,
28230 + bfd_target_ovax_flavour,
28231 + bfd_target_evax_flavour,
28232 + bfd_target_mmo_flavour,
28233 + bfd_target_mach_o_flavour,
28234 + bfd_target_pef_flavour,
28235 + bfd_target_pef_xlib_flavour,
28236 + bfd_target_sym_flavour
28239 +enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
28241 +/* Forward declaration. */
28242 +typedef struct bfd_link_info _bfd_link_info;
28244 +typedef struct bfd_target
28246 + /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. */
28249 + /* The "flavour" of a back end is a general indication about
28250 + the contents of a file. */
28251 + enum bfd_flavour flavour;
28253 + /* The order of bytes within the data area of a file. */
28254 + enum bfd_endian byteorder;
28256 + /* The order of bytes within the header parts of a file. */
28257 + enum bfd_endian header_byteorder;
28259 + /* A mask of all the flags which an executable may have set -
28260 + from the set <<BFD_NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>. */
28261 + flagword object_flags;
28263 + /* A mask of all the flags which a section may have set - from
28264 + the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>. */
28265 + flagword section_flags;
28267 + /* The character normally found at the front of a symbol.
28268 + (if any), perhaps `_'. */
28269 + char symbol_leading_char;
28271 + /* The pad character for file names within an archive header. */
28272 + char ar_pad_char;
28274 + /* The maximum number of characters in an archive header. */
28275 + unsigned short ar_max_namelen;
28277 + /* Entries for byte swapping for data. These are different from the
28278 + other entry points, since they don't take a BFD as the first argument.
28279 + Certain other handlers could do the same. */
28280 + bfd_uint64_t (*bfd_getx64) (const void *);
28281 + bfd_int64_t (*bfd_getx_signed_64) (const void *);
28282 + void (*bfd_putx64) (bfd_uint64_t, void *);
28283 + bfd_vma (*bfd_getx32) (const void *);
28284 + bfd_signed_vma (*bfd_getx_signed_32) (const void *);
28285 + void (*bfd_putx32) (bfd_vma, void *);
28286 + bfd_vma (*bfd_getx16) (const void *);
28287 + bfd_signed_vma (*bfd_getx_signed_16) (const void *);
28288 + void (*bfd_putx16) (bfd_vma, void *);
28290 + /* Byte swapping for the headers. */
28291 + bfd_uint64_t (*bfd_h_getx64) (const void *);
28292 + bfd_int64_t (*bfd_h_getx_signed_64) (const void *);
28293 + void (*bfd_h_putx64) (bfd_uint64_t, void *);
28294 + bfd_vma (*bfd_h_getx32) (const void *);
28295 + bfd_signed_vma (*bfd_h_getx_signed_32) (const void *);
28296 + void (*bfd_h_putx32) (bfd_vma, void *);
28297 + bfd_vma (*bfd_h_getx16) (const void *);
28298 + bfd_signed_vma (*bfd_h_getx_signed_16) (const void *);
28299 + void (*bfd_h_putx16) (bfd_vma, void *);
28301 + /* Format dependent routines: these are vectors of entry points
28302 + within the target vector structure, one for each format to check. */
28304 + /* Check the format of a file being read. Return a <<bfd_target *>> or zero. */
28305 + const struct bfd_target *(*_bfd_check_format[bfd_type_end]) (bfd *);
28307 + /* Set the format of a file being written. */
28308 + bfd_boolean (*_bfd_set_format[bfd_type_end]) (bfd *);
28310 + /* Write cached information into a file being written, at <<bfd_close>>. */
28311 + bfd_boolean (*_bfd_write_contents[bfd_type_end]) (bfd *);
28314 + /* Generic entry points. */
28315 +#define BFD_JUMP_TABLE_GENERIC(NAME) \
28316 + NAME##_close_and_cleanup, \
28317 + NAME##_bfd_free_cached_info, \
28318 + NAME##_new_section_hook, \
28319 + NAME##_get_section_contents, \
28320 + NAME##_get_section_contents_in_window
28322 + /* Called when the BFD is being closed to do any necessary cleanup. */
28323 + bfd_boolean (*_close_and_cleanup) (bfd *);
28324 + /* Ask the BFD to free all cached information. */
28325 + bfd_boolean (*_bfd_free_cached_info) (bfd *);
28326 + /* Called when a new section is created. */
28327 + bfd_boolean (*_new_section_hook) (bfd *, sec_ptr);
28328 + /* Read the contents of a section. */
28329 + bfd_boolean (*_bfd_get_section_contents)
28330 + (bfd *, sec_ptr, void *, file_ptr, bfd_size_type);
28331 + bfd_boolean (*_bfd_get_section_contents_in_window)
28332 + (bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type);
28334 + /* Entry points to copy private data. */
28335 +#define BFD_JUMP_TABLE_COPY(NAME) \
28336 + NAME##_bfd_copy_private_bfd_data, \
28337 + NAME##_bfd_merge_private_bfd_data, \
28338 + NAME##_bfd_copy_private_section_data, \
28339 + NAME##_bfd_copy_private_symbol_data, \
28340 + NAME##_bfd_copy_private_header_data, \
28341 + NAME##_bfd_set_private_flags, \
28342 + NAME##_bfd_print_private_bfd_data
28344 + /* Called to copy BFD general private data from one object file
28346 + bfd_boolean (*_bfd_copy_private_bfd_data) (bfd *, bfd *);
28347 + /* Called to merge BFD general private data from one object file
28348 + to a common output file when linking. */
28349 + bfd_boolean (*_bfd_merge_private_bfd_data) (bfd *, bfd *);
28350 + /* Called to copy BFD private section data from one object file
28352 + bfd_boolean (*_bfd_copy_private_section_data)
28353 + (bfd *, sec_ptr, bfd *, sec_ptr);
28354 + /* Called to copy BFD private symbol data from one symbol
28356 + bfd_boolean (*_bfd_copy_private_symbol_data)
28357 + (bfd *, asymbol *, bfd *, asymbol *);
28358 + /* Called to copy BFD private header data from one object file
28360 + bfd_boolean (*_bfd_copy_private_header_data)
28362 + /* Called to set private backend flags. */
28363 + bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword);
28365 + /* Called to print private BFD data. */
28366 + bfd_boolean (*_bfd_print_private_bfd_data) (bfd *, void *);
28368 + /* Core file entry points. */
28369 +#define BFD_JUMP_TABLE_CORE(NAME) \
28370 + NAME##_core_file_failing_command, \
28371 + NAME##_core_file_failing_signal, \
28372 + NAME##_core_file_matches_executable_p
28374 + char * (*_core_file_failing_command) (bfd *);
28375 + int (*_core_file_failing_signal) (bfd *);
28376 + bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *);
28378 + /* Archive entry points. */
28379 +#define BFD_JUMP_TABLE_ARCHIVE(NAME) \
28380 + NAME##_slurp_armap, \
28381 + NAME##_slurp_extended_name_table, \
28382 + NAME##_construct_extended_name_table, \
28383 + NAME##_truncate_arname, \
28384 + NAME##_write_armap, \
28385 + NAME##_read_ar_hdr, \
28386 + NAME##_openr_next_archived_file, \
28387 + NAME##_get_elt_at_index, \
28388 + NAME##_generic_stat_arch_elt, \
28389 + NAME##_update_armap_timestamp
28391 + bfd_boolean (*_bfd_slurp_armap) (bfd *);
28392 + bfd_boolean (*_bfd_slurp_extended_name_table) (bfd *);
28393 + bfd_boolean (*_bfd_construct_extended_name_table)
28394 + (bfd *, char **, bfd_size_type *, const char **);
28395 + void (*_bfd_truncate_arname) (bfd *, const char *, char *);
28396 + bfd_boolean (*write_armap)
28397 + (bfd *, unsigned int, struct orl *, unsigned int, int);
28398 + void * (*_bfd_read_ar_hdr_fn) (bfd *);
28399 + bfd * (*openr_next_archived_file) (bfd *, bfd *);
28400 +#define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i))
28401 + bfd * (*_bfd_get_elt_at_index) (bfd *, symindex);
28402 + int (*_bfd_stat_arch_elt) (bfd *, struct stat *);
28403 + bfd_boolean (*_bfd_update_armap_timestamp) (bfd *);
28405 + /* Entry points used for symbols. */
28406 +#define BFD_JUMP_TABLE_SYMBOLS(NAME) \
28407 + NAME##_get_symtab_upper_bound, \
28408 + NAME##_canonicalize_symtab, \
28409 + NAME##_make_empty_symbol, \
28410 + NAME##_print_symbol, \
28411 + NAME##_get_symbol_info, \
28412 + NAME##_bfd_is_local_label_name, \
28413 + NAME##_bfd_is_target_special_symbol, \
28414 + NAME##_get_lineno, \
28415 + NAME##_find_nearest_line, \
28416 + _bfd_generic_find_line, \
28417 + NAME##_find_inliner_info, \
28418 + NAME##_bfd_make_debug_symbol, \
28419 + NAME##_read_minisymbols, \
28420 + NAME##_minisymbol_to_symbol
28422 + long (*_bfd_get_symtab_upper_bound) (bfd *);
28423 + long (*_bfd_canonicalize_symtab)
28424 + (bfd *, struct bfd_symbol **);
28425 + struct bfd_symbol *
28426 + (*_bfd_make_empty_symbol) (bfd *);
28427 + void (*_bfd_print_symbol)
28428 + (bfd *, void *, struct bfd_symbol *, bfd_print_symbol_type);
28429 +#define bfd_print_symbol(b,p,s,e) BFD_SEND (b, _bfd_print_symbol, (b,p,s,e))
28430 + void (*_bfd_get_symbol_info)
28431 + (bfd *, struct bfd_symbol *, symbol_info *);
28432 +#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
28433 + bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
28434 + bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
28435 + alent * (*_get_lineno) (bfd *, struct bfd_symbol *);
28436 + bfd_boolean (*_bfd_find_nearest_line)
28437 + (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma,
28438 + const char **, const char **, unsigned int *);
28439 + bfd_boolean (*_bfd_find_line)
28440 + (bfd *, struct bfd_symbol **, struct bfd_symbol *,
28441 + const char **, unsigned int *);
28442 + bfd_boolean (*_bfd_find_inliner_info)
28443 + (bfd *, const char **, const char **, unsigned int *);
28444 + /* Back-door to allow format-aware applications to create debug symbols
28445 + while using BFD for everything else. Currently used by the assembler
28446 + when creating COFF files. */
28447 + asymbol * (*_bfd_make_debug_symbol)
28448 + (bfd *, void *, unsigned long size);
28449 +#define bfd_read_minisymbols(b, d, m, s) \
28450 + BFD_SEND (b, _read_minisymbols, (b, d, m, s))
28451 + long (*_read_minisymbols)
28452 + (bfd *, bfd_boolean, void **, unsigned int *);
28453 +#define bfd_minisymbol_to_symbol(b, d, m, f) \
28454 + BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
28455 + asymbol * (*_minisymbol_to_symbol)
28456 + (bfd *, bfd_boolean, const void *, asymbol *);
28458 + /* Routines for relocs. */
28459 +#define BFD_JUMP_TABLE_RELOCS(NAME) \
28460 + NAME##_get_reloc_upper_bound, \
28461 + NAME##_canonicalize_reloc, \
28462 + NAME##_bfd_reloc_type_lookup
28464 + long (*_get_reloc_upper_bound) (bfd *, sec_ptr);
28465 + long (*_bfd_canonicalize_reloc)
28466 + (bfd *, sec_ptr, arelent **, struct bfd_symbol **);
28467 + /* See documentation on reloc types. */
28468 + reloc_howto_type *
28469 + (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
28471 + /* Routines used when writing an object file. */
28472 +#define BFD_JUMP_TABLE_WRITE(NAME) \
28473 + NAME##_set_arch_mach, \
28474 + NAME##_set_section_contents
28476 + bfd_boolean (*_bfd_set_arch_mach)
28477 + (bfd *, enum bfd_architecture, unsigned long);
28478 + bfd_boolean (*_bfd_set_section_contents)
28479 + (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
28481 + /* Routines used by the linker. */
28482 +#define BFD_JUMP_TABLE_LINK(NAME) \
28483 + NAME##_sizeof_headers, \
28484 + NAME##_bfd_get_relocated_section_contents, \
28485 + NAME##_bfd_relax_section, \
28486 + NAME##_bfd_link_hash_table_create, \
28487 + NAME##_bfd_link_hash_table_free, \
28488 + NAME##_bfd_link_add_symbols, \
28489 + NAME##_bfd_link_just_syms, \
28490 + NAME##_bfd_final_link, \
28491 + NAME##_bfd_link_split_section, \
28492 + NAME##_bfd_gc_sections, \
28493 + NAME##_bfd_merge_sections, \
28494 + NAME##_bfd_is_group_section, \
28495 + NAME##_bfd_discard_group, \
28496 + NAME##_section_already_linked \
28498 + int (*_bfd_sizeof_headers) (bfd *, bfd_boolean);
28499 + bfd_byte * (*_bfd_get_relocated_section_contents)
28500 + (bfd *, struct bfd_link_info *, struct bfd_link_order *,
28501 + bfd_byte *, bfd_boolean, struct bfd_symbol **);
28503 + bfd_boolean (*_bfd_relax_section)
28504 + (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *);
28506 + /* Create a hash table for the linker. Different backends store
28507 + different information in this table. */
28508 + struct bfd_link_hash_table *
28509 + (*_bfd_link_hash_table_create) (bfd *);
28511 + /* Release the memory associated with the linker hash table. */
28512 + void (*_bfd_link_hash_table_free) (struct bfd_link_hash_table *);
28514 + /* Add symbols from this object file into the hash table. */
28515 + bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *);
28517 + /* Indicate that we are only retrieving symbol values from this section. */
28518 + void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *);
28520 + /* Do a link based on the link_order structures attached to each
28521 + section of the BFD. */
28522 + bfd_boolean (*_bfd_final_link) (bfd *, struct bfd_link_info *);
28524 + /* Should this section be split up into smaller pieces during linking. */
28525 + bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *);
28527 + /* Remove sections that are not referenced from the output. */
28528 + bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
28530 + /* Attempt to merge SEC_MERGE sections. */
28531 + bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
28533 + /* Is this section a member of a group? */
28534 + bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *);
28536 + /* Discard members of a group. */
28537 + bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *);
28539 + /* Check if SEC has been already linked during a reloceatable or
28541 + void (*_section_already_linked) (bfd *, struct bfd_section *);
28543 + /* Routines to handle dynamic symbols and relocs. */
28544 +#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
28545 + NAME##_get_dynamic_symtab_upper_bound, \
28546 + NAME##_canonicalize_dynamic_symtab, \
28547 + NAME##_get_synthetic_symtab, \
28548 + NAME##_get_dynamic_reloc_upper_bound, \
28549 + NAME##_canonicalize_dynamic_reloc
28551 + /* Get the amount of memory required to hold the dynamic symbols. */
28552 + long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *);
28553 + /* Read in the dynamic symbols. */
28554 + long (*_bfd_canonicalize_dynamic_symtab)
28555 + (bfd *, struct bfd_symbol **);
28556 + /* Create synthetized symbols. */
28557 + long (*_bfd_get_synthetic_symtab)
28558 + (bfd *, long, struct bfd_symbol **, long, struct bfd_symbol **,
28559 + struct bfd_symbol **);
28560 + /* Get the amount of memory required to hold the dynamic relocs. */
28561 + long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *);
28562 + /* Read in the dynamic relocs. */
28563 + long (*_bfd_canonicalize_dynamic_reloc)
28564 + (bfd *, arelent **, struct bfd_symbol **);
28566 + /* Opposite endian version of this target. */
28567 + const struct bfd_target * alternative_target;
28569 + /* Data for use by back-end routines, which isn't
28570 + generic enough to belong in this structure. */
28571 + const void *backend_data;
28575 +bfd_boolean bfd_set_default_target (const char *name);
28577 +const bfd_target *bfd_find_target (const char *target_name, bfd *abfd);
28579 +const char ** bfd_target_list (void);
28581 +const bfd_target *bfd_search_for_target
28582 + (int (*search_func) (const bfd_target *, void *),
28585 +/* Extracted from format.c. */
28586 +bfd_boolean bfd_check_format (bfd *abfd, bfd_format format);
28588 +bfd_boolean bfd_check_format_matches
28589 + (bfd *abfd, bfd_format format, char ***matching);
28591 +bfd_boolean bfd_set_format (bfd *abfd, bfd_format format);
28593 +const char *bfd_format_string (bfd_format format);
28595 +/* Extracted from linker.c. */
28596 +bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec);
28598 +#define bfd_link_split_section(abfd, sec) \
28599 + BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
28601 +void bfd_section_already_linked (bfd *abfd, asection *sec);
28603 +#define bfd_section_already_linked(abfd, sec) \
28604 + BFD_SEND (abfd, _section_already_linked, (abfd, sec))
28606 +/* Extracted from simple.c. */
28607 +bfd_byte *bfd_simple_get_relocated_section_contents
28608 + (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table);
28610 +#ifdef __cplusplus
28614 diff -Nurp linux-2.6.22-590/include/asm-i386/kdb.h linux-2.6.22-600/include/asm-i386/kdb.h
28615 --- linux-2.6.22-590/include/asm-i386/kdb.h 1970-01-01 01:00:00.000000000 +0100
28616 +++ linux-2.6.22-600/include/asm-i386/kdb.h 2008-04-09 18:16:14.000000000 +0200
28618 +#ifndef _ASM_KDB_H
28619 +#define _ASM_KDB_H
28622 + * Kernel Debugger Architecture Dependent Global Headers
28624 + * This file is subject to the terms and conditions of the GNU General Public
28625 + * License. See the file "COPYING" in the main directory of this archive
28626 + * for more details.
28628 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
28632 + * KDB_ENTER() is a macro which causes entry into the kernel
28633 + * debugger from any point in the kernel code stream. If it
28634 + * is intended to be used from interrupt level, it must use
28635 + * a non-maskable entry method.
28637 +#define KDB_ENTER() do {if (kdb_on && !KDB_IS_RUNNING()) { asm("\tint $129\n"); }} while(0)
28640 + * Needed for exported symbols.
28642 +typedef unsigned long kdb_machreg_t;
28644 +#define kdb_machreg_fmt "0x%lx"
28645 +#define kdb_machreg_fmt0 "0x%08lx"
28646 +#define kdb_bfd_vma_fmt "0x%lx"
28647 +#define kdb_bfd_vma_fmt0 "0x%08lx"
28648 +#define kdb_elfw_addr_fmt "0x%x"
28649 +#define kdb_elfw_addr_fmt0 "0x%08x"
28652 + * Per cpu arch specific kdb state. Must be in range 0xff000000.
28654 +#define KDB_STATE_A_IF 0x01000000 /* Saved IF flag */
28656 +static inline unsigned long
28657 +kdba_funcptr_value(void *fp)
28659 + return (unsigned long)fp;
28662 +#endif /* !_ASM_KDB_H */
28663 diff -Nurp linux-2.6.22-590/include/asm-i386/kdbprivate.h linux-2.6.22-600/include/asm-i386/kdbprivate.h
28664 --- linux-2.6.22-590/include/asm-i386/kdbprivate.h 1970-01-01 01:00:00.000000000 +0100
28665 +++ linux-2.6.22-600/include/asm-i386/kdbprivate.h 2008-04-09 18:16:14.000000000 +0200
28667 +#ifndef _ASM_KDBPRIVATE_H
28668 +#define _ASM_KDBPRIVATE_H
28671 + * Kernel Debugger Architecture Dependent Private Headers
28673 + * This file is subject to the terms and conditions of the GNU General Public
28674 + * License. See the file "COPYING" in the main directory of this archive
28675 + * for more details.
28677 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
28680 +typedef unsigned char kdb_machinst_t;
28683 + * KDB_MAXBPT describes the total number of breakpoints
28684 + * supported by this architecure.
28686 +#define KDB_MAXBPT 16
28689 + * KDB_MAXHARDBPT describes the total number of hardware
28690 + * breakpoint registers that exist.
28692 +#define KDB_MAXHARDBPT 4
28694 +/* Maximum number of arguments to a function */
28695 +#define KDBA_MAXARGS 16
28698 + * Platform specific environment entries
28700 +#define KDB_PLATFORM_ENV "IDMODE=x86", "BYTESPERWORD=4", "IDCOUNT=16"
28703 + * Support for ia32 debug registers
28705 +typedef struct _kdbhard_bp {
28706 + kdb_machreg_t bph_reg; /* Register this breakpoint uses */
28708 + unsigned int bph_free:1; /* Register available for use */
28709 + unsigned int bph_data:1; /* Data Access breakpoint */
28711 + unsigned int bph_write:1; /* Write Data breakpoint */
28712 + unsigned int bph_mode:2; /* 0=inst, 1=write, 2=io, 3=read */
28713 + unsigned int bph_length:2; /* 0=1, 1=2, 2=BAD, 3=4 (bytes) */
28716 +#define IA32_BREAKPOINT_INSTRUCTION 0xcc
28718 +#define DR6_BT 0x00008000
28719 +#define DR6_BS 0x00004000
28720 +#define DR6_BD 0x00002000
28722 +#define DR6_B3 0x00000008
28723 +#define DR6_B2 0x00000004
28724 +#define DR6_B1 0x00000002
28725 +#define DR6_B0 0x00000001
28726 +#define DR6_DR_MASK 0x0000000F
28728 +#define DR7_RW_VAL(dr, drnum) \
28729 + (((dr) >> (16 + (4 * (drnum)))) & 0x3)
28731 +#define DR7_RW_SET(dr, drnum, rw) \
28733 + (dr) &= ~(0x3 << (16 + (4 * (drnum)))); \
28734 + (dr) |= (((rw) & 0x3) << (16 + (4 * (drnum)))); \
28737 +#define DR7_RW0(dr) DR7_RW_VAL(dr, 0)
28738 +#define DR7_RW0SET(dr,rw) DR7_RW_SET(dr, 0, rw)
28739 +#define DR7_RW1(dr) DR7_RW_VAL(dr, 1)
28740 +#define DR7_RW1SET(dr,rw) DR7_RW_SET(dr, 1, rw)
28741 +#define DR7_RW2(dr) DR7_RW_VAL(dr, 2)
28742 +#define DR7_RW2SET(dr,rw) DR7_RW_SET(dr, 2, rw)
28743 +#define DR7_RW3(dr) DR7_RW_VAL(dr, 3)
28744 +#define DR7_RW3SET(dr,rw) DR7_RW_SET(dr, 3, rw)
28747 +#define DR7_LEN_VAL(dr, drnum) \
28748 + (((dr) >> (18 + (4 * (drnum)))) & 0x3)
28750 +#define DR7_LEN_SET(dr, drnum, rw) \
28752 + (dr) &= ~(0x3 << (18 + (4 * (drnum)))); \
28753 + (dr) |= (((rw) & 0x3) << (18 + (4 * (drnum)))); \
28756 +#define DR7_LEN0(dr) DR7_LEN_VAL(dr, 0)
28757 +#define DR7_LEN0SET(dr,len) DR7_LEN_SET(dr, 0, len)
28758 +#define DR7_LEN1(dr) DR7_LEN_VAL(dr, 1)
28759 +#define DR7_LEN1SET(dr,len) DR7_LEN_SET(dr, 1, len)
28760 +#define DR7_LEN2(dr) DR7_LEN_VAL(dr, 2)
28761 +#define DR7_LEN2SET(dr,len) DR7_LEN_SET(dr, 2, len)
28762 +#define DR7_LEN3(dr) DR7_LEN_VAL(dr, 3)
28763 +#define DR7_LEN3SET(dr,len) DR7_LEN_SET(dr, 3, len)
28765 +#define DR7_G0(dr) (((dr)>>1)&0x1)
28766 +#define DR7_G0SET(dr) ((dr) |= 0x2)
28767 +#define DR7_G0CLR(dr) ((dr) &= ~0x2)
28768 +#define DR7_G1(dr) (((dr)>>3)&0x1)
28769 +#define DR7_G1SET(dr) ((dr) |= 0x8)
28770 +#define DR7_G1CLR(dr) ((dr) &= ~0x8)
28771 +#define DR7_G2(dr) (((dr)>>5)&0x1)
28772 +#define DR7_G2SET(dr) ((dr) |= 0x20)
28773 +#define DR7_G2CLR(dr) ((dr) &= ~0x20)
28774 +#define DR7_G3(dr) (((dr)>>7)&0x1)
28775 +#define DR7_G3SET(dr) ((dr) |= 0x80)
28776 +#define DR7_G3CLR(dr) ((dr) &= ~0x80)
28778 +#define DR7_L0(dr) (((dr))&0x1)
28779 +#define DR7_L0SET(dr) ((dr) |= 0x1)
28780 +#define DR7_L0CLR(dr) ((dr) &= ~0x1)
28781 +#define DR7_L1(dr) (((dr)>>2)&0x1)
28782 +#define DR7_L1SET(dr) ((dr) |= 0x4)
28783 +#define DR7_L1CLR(dr) ((dr) &= ~0x4)
28784 +#define DR7_L2(dr) (((dr)>>4)&0x1)
28785 +#define DR7_L2SET(dr) ((dr) |= 0x10)
28786 +#define DR7_L2CLR(dr) ((dr) &= ~0x10)
28787 +#define DR7_L3(dr) (((dr)>>6)&0x1)
28788 +#define DR7_L3SET(dr) ((dr) |= 0x40)
28789 +#define DR7_L3CLR(dr) ((dr) &= ~0x40)
28791 +#define DR7_GD 0x00002000 /* General Detect Enable */
28792 +#define DR7_GE 0x00000200 /* Global exact */
28793 +#define DR7_LE 0x00000100 /* Local exact */
28795 +#define DR_TYPE_EXECUTE 0x0
28796 +#define DR_TYPE_WRITE 0x1
28797 +#define DR_TYPE_IO 0x2
28798 +#define DR_TYPE_RW 0x3
28800 +extern kdb_machreg_t kdba_getdr6(void);
28801 +extern void kdba_putdr6(kdb_machreg_t);
28803 +extern kdb_machreg_t kdba_getdr7(void);
28806 + * Support for setjmp/longjmp
28815 +typedef struct __kdb_jmp_buf {
28816 + unsigned long regs[6]; /* kdba_setjmp assumes fixed offsets here */
28819 +extern int asmlinkage kdba_setjmp(kdb_jmp_buf *);
28820 +extern void asmlinkage kdba_longjmp(kdb_jmp_buf *, int);
28821 +#define kdba_setjmp kdba_setjmp
28823 +extern kdb_jmp_buf *kdbjmpbuf;
28825 +/* Arch specific data saved for running processes */
28827 +struct kdba_running_process {
28828 + long esp; /* CONFIG_4KSTACKS may be on a different stack */
28829 + long eip; /* eip when esp was set */
28833 +void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
28835 + k->esp = current_stack_pointer;
28836 + __asm__ __volatile__ ( " lea 1f,%%eax; movl %%eax,%0 ; 1: " : "=r"(k->eip) : : "eax" );
28840 +void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
28844 +struct kdb_activation_record;
28845 +extern void kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
28846 + struct kdb_activation_record *ar);
28848 +extern void kdba_wait_for_cpus(void);
28850 +extern fastcall void kdb_interrupt(void);
28852 +#define KDB_INT_REGISTERS 8
28855 +#endif /* !_ASM_KDBPRIVATE_H */
28856 diff -Nurp linux-2.6.22-590/include/asm-i386/kdebug.h linux-2.6.22-600/include/asm-i386/kdebug.h
28857 --- linux-2.6.22-590/include/asm-i386/kdebug.h 2007-07-09 01:32:17.000000000 +0200
28858 +++ linux-2.6.22-600/include/asm-i386/kdebug.h 2008-04-09 18:16:14.000000000 +0200
28859 @@ -23,6 +23,8 @@ enum die_val {
28863 + DIE_KDEBUG_ENTER,
28864 + DIE_KDEBUG_LEAVE,
28868 diff -Nurp linux-2.6.22-590/include/asm-i386/kmap_types.h linux-2.6.22-600/include/asm-i386/kmap_types.h
28869 --- linux-2.6.22-590/include/asm-i386/kmap_types.h 2007-07-09 01:32:17.000000000 +0200
28870 +++ linux-2.6.22-600/include/asm-i386/kmap_types.h 2008-04-09 18:16:14.000000000 +0200
28871 @@ -22,7 +22,8 @@ D(9) KM_IRQ0,
28881 diff -Nurp linux-2.6.22-590/include/asm-i386/mach-default/irq_vectors.h linux-2.6.22-600/include/asm-i386/mach-default/irq_vectors.h
28882 --- linux-2.6.22-590/include/asm-i386/mach-default/irq_vectors.h 2007-07-09 01:32:17.000000000 +0200
28883 +++ linux-2.6.22-600/include/asm-i386/mach-default/irq_vectors.h 2008-04-09 18:16:14.000000000 +0200
28885 #define FIRST_EXTERNAL_VECTOR 0x20
28887 #define SYSCALL_VECTOR 0x80
28888 +#define KDBENTER_VECTOR 0x81
28891 * Vectors 0x20-0x2f are used for ISA interrupts.
28893 #define INVALIDATE_TLB_VECTOR 0xfd
28894 #define RESCHEDULE_VECTOR 0xfc
28895 #define CALL_FUNCTION_VECTOR 0xfb
28896 +#define KDB_VECTOR 0xf9
28898 #define THERMAL_APIC_VECTOR 0xf0
28900 diff -Nurp linux-2.6.22-590/include/asm-i386/ptrace.h linux-2.6.22-600/include/asm-i386/ptrace.h
28901 --- linux-2.6.22-590/include/asm-i386/ptrace.h 2007-07-09 01:32:17.000000000 +0200
28902 +++ linux-2.6.22-600/include/asm-i386/ptrace.h 2008-04-09 18:16:14.000000000 +0200
28903 @@ -26,6 +26,29 @@ struct pt_regs {
28908 + EF_CF = 0x00000001,
28909 + EF_PF = 0x00000004,
28910 + EF_AF = 0x00000010,
28911 + EF_ZF = 0x00000040,
28912 + EF_SF = 0x00000080,
28913 + EF_TF = 0x00000100,
28914 + EF_IE = 0x00000200,
28915 + EF_DF = 0x00000400,
28916 + EF_OF = 0x00000800,
28917 + EF_IOPL = 0x00003000,
28918 + EF_IOPL_RING0 = 0x00000000,
28919 + EF_IOPL_RING1 = 0x00001000,
28920 + EF_IOPL_RING2 = 0x00002000,
28921 + EF_NT = 0x00004000, /* nested task */
28922 + EF_RF = 0x00010000, /* resume */
28923 + EF_VM = 0x00020000, /* virtual mode */
28924 + EF_AC = 0x00040000, /* alignment */
28925 + EF_VIF = 0x00080000, /* virtual interrupt */
28926 + EF_VIP = 0x00100000, /* virtual interrupt pending */
28927 + EF_ID = 0x00200000, /* id */
28932 #include <asm/vm86.h>
28933 diff -Nurp linux-2.6.22-590/include/asm-x86_64/ansidecl.h linux-2.6.22-600/include/asm-x86_64/ansidecl.h
28934 --- linux-2.6.22-590/include/asm-x86_64/ansidecl.h 1970-01-01 01:00:00.000000000 +0100
28935 +++ linux-2.6.22-600/include/asm-x86_64/ansidecl.h 2008-04-09 18:16:24.000000000 +0200
28937 +/* ANSI and traditional C compatability macros
28938 + Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
28939 + Free Software Foundation, Inc.
28940 + This file is part of the GNU C Library.
28942 +This program is free software; you can redistribute it and/or modify
28943 +it under the terms of the GNU General Public License as published by
28944 +the Free Software Foundation; either version 2 of the License, or
28945 +(at your option) any later version.
28947 +This program is distributed in the hope that it will be useful,
28948 +but WITHOUT ANY WARRANTY; without even the implied warranty of
28949 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28950 +GNU General Public License for more details.
28952 +You should have received a copy of the GNU General Public License
28953 +along with this program; if not, write to the Free Software
28954 +Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
28956 +/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
28957 + * Any trailing whitespace was removed and #ifdef/ifndef __KERNEL__ added as
28959 + * Keith Owens <kaos@sgi.com> 15 May 2006
28962 +/* ANSI and traditional C compatibility macros
28964 + ANSI C is assumed if __STDC__ is #defined.
28966 + Macro ANSI C definition Traditional C definition
28967 + ----- ---- - ---------- ----------- - ----------
28968 + ANSI_PROTOTYPES 1 not defined
28969 + PTR `void *' `char *'
28970 + PTRCONST `void *const' `char *'
28971 + LONG_DOUBLE `long double' `double'
28972 + const not defined `'
28973 + volatile not defined `'
28974 + signed not defined `'
28975 + VA_START(ap, var) va_start(ap, var) va_start(ap)
28977 + Note that it is safe to write "void foo();" indicating a function
28978 + with no return value, in all K+R compilers we have been able to test.
28980 + For declaring functions with prototypes, we also provide these:
28982 + PARAMS ((prototype))
28983 + -- for functions which take a fixed number of arguments. Use this
28984 + when declaring the function. When defining the function, write a
28985 + K+R style argument list. For example:
28987 + char *strcpy PARAMS ((char *dest, char *source));
28990 + strcpy (dest, source)
28996 + VPARAMS ((prototype, ...))
28997 + -- for functions which take a variable number of arguments. Use
28998 + PARAMS to declare the function, VPARAMS to define it. For example:
29000 + int printf PARAMS ((const char *format, ...));
29003 + printf VPARAMS ((const char *format, ...))
29008 + For writing functions which take variable numbers of arguments, we
29009 + also provide the VA_OPEN, VA_CLOSE, and VA_FIXEDARG macros. These
29010 + hide the differences between K+R <varargs.h> and C89 <stdarg.h> more
29011 + thoroughly than the simple VA_START() macro mentioned above.
29013 + VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end.
29014 + Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls
29015 + corresponding to the list of fixed arguments. Then use va_arg
29016 + normally to get the variable arguments, or pass your va_list object
29017 + around. You do not declare the va_list yourself; VA_OPEN does it
29020 + Here is a complete example:
29023 + printf VPARAMS ((const char *format, ...))
29027 + VA_OPEN (ap, format);
29028 + VA_FIXEDARG (ap, const char *, format);
29030 + result = vfprintf (stdout, format, ap);
29037 + You can declare variables either before or after the VA_OPEN,
29038 + VA_FIXEDARG sequence. Also, VA_OPEN and VA_CLOSE are the beginning
29039 + and end of a block. They must appear at the same nesting level,
29040 + and any variables declared after VA_OPEN go out of scope at
29041 + VA_CLOSE. Unfortunately, with a K+R compiler, that includes the
29042 + argument list. You can have multiple instances of VA_OPEN/VA_CLOSE
29043 + pairs in a single function in case you need to traverse the
29044 + argument list more than once.
29046 + For ease of writing code which uses GCC extensions but needs to be
29047 + portable to other compilers, we provide the GCC_VERSION macro that
29048 + simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
29049 + wrappers around __attribute__. Also, __extension__ will be #defined
29050 + to nothing if it doesn't work. See below.
29052 + This header also defines a lot of obsolete macros:
29053 + CONST, VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID,
29054 + AND, DOTS, NOARGS. Don't use them. */
29056 +#ifndef _ANSIDECL_H
29057 +#define _ANSIDECL_H 1
29059 +/* Every source file includes this file,
29060 + so they will all get the switch for lint. */
29063 +/* Using MACRO(x,y) in cpp #if conditionals does not work with some
29064 + older preprocessors. Thus we can't define something like this:
29066 +#define HAVE_GCC_VERSION(MAJOR, MINOR) \
29067 + (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
29069 +and then test "#if HAVE_GCC_VERSION(2,7)".
29071 +So instead we use the macro below and test it against specific values. */
29073 +/* This macro simplifies testing whether we are using gcc, and if it
29074 + is of a particular minimum version. (Both major & minor numbers are
29075 + significant.) This macro will evaluate to 0 if we are not using
29077 +#ifndef GCC_VERSION
29078 +#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
29079 +#endif /* GCC_VERSION */
29081 +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) || (defined(__alpha) && defined(__cplusplus))
29082 +/* All known AIX compilers implement these things (but don't always
29083 + define __STDC__). The RISC/OS MIPS compiler defines these things
29084 + in SVR4 mode, but does not define __STDC__. */
29085 +/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
29086 + C++ compilers, does not define __STDC__, though it acts as if this
29087 + was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
29089 +#define ANSI_PROTOTYPES 1
29090 +#define PTR void *
29091 +#define PTRCONST void *const
29092 +#define LONG_DOUBLE long double
29094 +/* PARAMS is often defined elsewhere (e.g. by libintl.h), so wrap it in
29097 +#define PARAMS(ARGS) ARGS
29100 +#define VPARAMS(ARGS) ARGS
29101 +#define VA_START(VA_LIST, VAR) va_start(VA_LIST, VAR)
29103 +/* variadic function helper macros */
29104 +/* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's
29105 + use without inhibiting further decls and without declaring an
29106 + actual variable. */
29107 +#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP, VAR); { struct Qdmy
29108 +#define VA_CLOSE(AP) } va_end(AP); }
29109 +#define VA_FIXEDARG(AP, T, N) struct Qdmy
29116 +#ifndef __STDC_VERSION__
29117 +#define __STDC_VERSION__ 0
29119 +#endif /* __KERNEL__ */
29121 +/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
29122 + it too, but it's not in C89. */
29124 +#if __STDC_VERSION__ > 199901L
29125 +/* it's a keyword */
29127 +# if GCC_VERSION >= 2007
29128 +# define inline __inline__ /* __inline__ prevents -pedantic warnings */
29130 +# define inline /* nothing */
29134 +/* These are obsolete. Do not use. */
29136 +#define CONST const
29137 +#define VOLATILE volatile
29138 +#define SIGNED signed
29140 +#define PROTO(type, name, arglist) type name arglist
29141 +#define EXFUN(name, proto) name proto
29142 +#define DEFUN(name, arglist, args) name(args)
29143 +#define DEFUN_VOID(name) name(void)
29145 +#define DOTS , ...
29146 +#define NOARGS void
29147 +#endif /* ! IN_GCC */
29149 +#else /* Not ANSI C. */
29151 +#undef ANSI_PROTOTYPES
29152 +#define PTR char *
29153 +#define PTRCONST PTR
29154 +#define LONG_DOUBLE double
29156 +#define PARAMS(args) ()
29157 +#define VPARAMS(args) (va_alist) va_dcl
29158 +#define VA_START(va_list, var) va_start(va_list)
29160 +#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP); { struct Qdmy
29161 +#define VA_CLOSE(AP) } va_end(AP); }
29162 +#define VA_FIXEDARG(AP, TYPE, NAME) TYPE NAME = va_arg(AP, TYPE)
29164 +/* some systems define these in header files for non-ansi mode */
29179 +#define PROTO(type, name, arglist) type name ()
29180 +#define EXFUN(name, proto) name()
29181 +#define DEFUN(name, arglist, args) name arglist args;
29182 +#define DEFUN_VOID(name) name()
29186 +#endif /* ! IN_GCC */
29188 +#endif /* ANSI C. */
29190 +/* Define macros for some gcc attributes. This permits us to use the
29191 + macros freely, and know that they will come into play for the
29192 + version of gcc in which they are supported. */
29194 +#if (GCC_VERSION < 2007)
29195 +# define __attribute__(x)
29198 +/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
29199 +#ifndef ATTRIBUTE_MALLOC
29200 +# if (GCC_VERSION >= 2096)
29201 +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
29203 +# define ATTRIBUTE_MALLOC
29204 +# endif /* GNUC >= 2.96 */
29205 +#endif /* ATTRIBUTE_MALLOC */
29207 +/* Attributes on labels were valid as of gcc 2.93. */
29208 +#ifndef ATTRIBUTE_UNUSED_LABEL
29209 +# if (!defined (__cplusplus) && GCC_VERSION >= 2093)
29210 +# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
29212 +# define ATTRIBUTE_UNUSED_LABEL
29213 +# endif /* !__cplusplus && GNUC >= 2.93 */
29214 +#endif /* ATTRIBUTE_UNUSED_LABEL */
29216 +#ifndef ATTRIBUTE_UNUSED
29217 +#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
29218 +#endif /* ATTRIBUTE_UNUSED */
29220 +/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
29221 + identifier name. */
29222 +#if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
29223 +# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
29224 +#else /* !__cplusplus || GNUC >= 3.4 */
29225 +# define ARG_UNUSED(NAME) NAME
29226 +#endif /* !__cplusplus || GNUC >= 3.4 */
29228 +#ifndef ATTRIBUTE_NORETURN
29229 +#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
29230 +#endif /* ATTRIBUTE_NORETURN */
29232 +/* Attribute `nonnull' was valid as of gcc 3.3. */
29233 +#ifndef ATTRIBUTE_NONNULL
29234 +# if (GCC_VERSION >= 3003)
29235 +# define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
29237 +# define ATTRIBUTE_NONNULL(m)
29238 +# endif /* GNUC >= 3.3 */
29239 +#endif /* ATTRIBUTE_NONNULL */
29241 +/* Attribute `pure' was valid as of gcc 3.0. */
29242 +#ifndef ATTRIBUTE_PURE
29243 +# if (GCC_VERSION >= 3000)
29244 +# define ATTRIBUTE_PURE __attribute__ ((__pure__))
29246 +# define ATTRIBUTE_PURE
29247 +# endif /* GNUC >= 3.0 */
29248 +#endif /* ATTRIBUTE_PURE */
29250 +/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
29251 + This was the case for the `printf' format attribute by itself
29252 + before GCC 3.3, but as of 3.3 we need to add the `nonnull'
29253 + attribute to retain this behavior. */
29254 +#ifndef ATTRIBUTE_PRINTF
29255 +#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
29256 +#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
29257 +#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
29258 +#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
29259 +#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
29260 +#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
29261 +#endif /* ATTRIBUTE_PRINTF */
29263 +/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
29264 + a function pointer. Format attributes were allowed on function
29265 + pointers as of gcc 3.1. */
29266 +#ifndef ATTRIBUTE_FPTR_PRINTF
29267 +# if (GCC_VERSION >= 3001)
29268 +# define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
29270 +# define ATTRIBUTE_FPTR_PRINTF(m, n)
29271 +# endif /* GNUC >= 3.1 */
29272 +# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
29273 +# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
29274 +# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
29275 +# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
29276 +# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
29277 +#endif /* ATTRIBUTE_FPTR_PRINTF */
29279 +/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL. A
29280 + NULL format specifier was allowed as of gcc 3.3. */
29281 +#ifndef ATTRIBUTE_NULL_PRINTF
29282 +# if (GCC_VERSION >= 3003)
29283 +# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
29285 +# define ATTRIBUTE_NULL_PRINTF(m, n)
29286 +# endif /* GNUC >= 3.3 */
29287 +# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
29288 +# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
29289 +# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
29290 +# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
29291 +# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
29292 +#endif /* ATTRIBUTE_NULL_PRINTF */
29294 +/* Attribute `sentinel' was valid as of gcc 3.5. */
29295 +#ifndef ATTRIBUTE_SENTINEL
29296 +# if (GCC_VERSION >= 3005)
29297 +# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
29299 +# define ATTRIBUTE_SENTINEL
29300 +# endif /* GNUC >= 3.5 */
29301 +#endif /* ATTRIBUTE_SENTINEL */
29304 +#ifndef ATTRIBUTE_ALIGNED_ALIGNOF
29305 +# if (GCC_VERSION >= 3000)
29306 +# define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
29308 +# define ATTRIBUTE_ALIGNED_ALIGNOF(m)
29309 +# endif /* GNUC >= 3.0 */
29310 +#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
29312 +/* We use __extension__ in some places to suppress -pedantic warnings
29313 + about GCC extensions. This feature didn't work properly before
29315 +#if GCC_VERSION < 2008
29316 +#define __extension__
29319 +#endif /* ansidecl.h */
29320 diff -Nurp linux-2.6.22-590/include/asm-x86_64/bfd.h linux-2.6.22-600/include/asm-x86_64/bfd.h
29321 --- linux-2.6.22-590/include/asm-x86_64/bfd.h 1970-01-01 01:00:00.000000000 +0100
29322 +++ linux-2.6.22-600/include/asm-x86_64/bfd.h 2008-04-09 18:16:24.000000000 +0200
29324 +/* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically
29325 + generated from "bfd-in.h", "init.c", "opncls.c", "libbfd.c",
29326 + "bfdio.c", "bfdwin.c", "section.c", "archures.c", "reloc.c",
29327 + "syms.c", "bfd.c", "archive.c", "corefile.c", "targets.c", "format.c",
29328 + "linker.c" and "simple.c".
29329 + Run "make headers" in your build bfd/ to regenerate. */
29331 +/* Main header file for the bfd library -- portable access to object files.
29333 + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
29334 + 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
29336 + Contributed by Cygnus Support.
29338 + This file is part of BFD, the Binary File Descriptor library.
29340 + This program is free software; you can redistribute it and/or modify
29341 + it under the terms of the GNU General Public License as published by
29342 + the Free Software Foundation; either version 2 of the License, or
29343 + (at your option) any later version.
29345 + This program is distributed in the hope that it will be useful,
29346 + but WITHOUT ANY WARRANTY; without even the implied warranty of
29347 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29348 + GNU General Public License for more details.
29350 + You should have received a copy of the GNU General Public License
29351 + along with this program; if not, write to the Free Software
29352 + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
29354 +/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
29355 + * Any trailing whitespace was removed and #ifdef/ifndef __KERNEL__ added as
29357 + * Keith Owens <kaos@sgi.com> 15 May 2006
29360 +#ifndef __BFD_H_SEEN__
29361 +#define __BFD_H_SEEN__
29363 +#ifdef __cplusplus
29368 +#include <asm/ansidecl.h>
29369 +#else /* __KERNEL__ */
29370 +#include "ansidecl.h"
29371 +#include "symcat.h"
29372 +#endif /* __KERNEL__ */
29373 +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
29375 +/* This hack is to avoid a problem with some strict ANSI C preprocessors.
29376 + The problem is, "32_" is not a valid preprocessing token, and we don't
29377 + want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will
29378 + cause the inner CONCAT2 macros to be evaluated first, producing
29379 + still-valid pp-tokens. Then the final concatenation can be done. */
29381 +#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d))
29385 +/* The word size used by BFD on the host. This may be 64 with a 32
29386 + bit target if the host is 64 bit, or if other 64 bit targets have
29387 + been selected with --enable-targets, or if --enable-64-bit-bfd. */
29388 +#define BFD_ARCH_SIZE 64
29390 +/* The word size of the default bfd target. */
29391 +#define BFD_DEFAULT_TARGET_SIZE 64
29393 +#define BFD_HOST_64BIT_LONG 1
29394 +#define BFD_HOST_LONG_LONG 1
29396 +#define BFD_HOST_64_BIT long
29397 +#define BFD_HOST_U_64_BIT unsigned long
29398 +typedef BFD_HOST_64_BIT bfd_int64_t;
29399 +typedef BFD_HOST_U_64_BIT bfd_uint64_t;
29402 +#if BFD_ARCH_SIZE >= 64
29408 +#define INLINE __inline__
29414 +/* Forward declaration. */
29415 +typedef struct bfd bfd;
29417 +/* Boolean type used in bfd. Too many systems define their own
29418 + versions of "boolean" for us to safely typedef a "boolean" of
29419 + our own. Using an enum for "bfd_boolean" has its own set of
29420 + problems, with strange looking casts required to avoid warnings
29421 + on some older compilers. Thus we just use an int.
29423 + General rule: Functions which are bfd_boolean return TRUE on
29424 + success and FALSE on failure (unless they're a predicate). */
29426 +typedef int bfd_boolean;
29434 +#ifndef BFD_HOST_64_BIT
29435 + #error No 64 bit integer type available
29436 +#endif /* ! defined (BFD_HOST_64_BIT) */
29438 +typedef BFD_HOST_U_64_BIT bfd_vma;
29439 +typedef BFD_HOST_64_BIT bfd_signed_vma;
29440 +typedef BFD_HOST_U_64_BIT bfd_size_type;
29441 +typedef BFD_HOST_U_64_BIT symvalue;
29443 +#ifndef fprintf_vma
29444 +#if BFD_HOST_64BIT_LONG
29445 +#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
29446 +#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
29448 +#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
29449 +#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
29450 +#define fprintf_vma(s,x) \
29451 + fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
29452 +#define sprintf_vma(s,x) \
29453 + sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
29457 +#else /* not BFD64 */
29459 +/* Represent a target address. Also used as a generic unsigned type
29460 + which is guaranteed to be big enough to hold any arithmetic types
29461 + we need to deal with. */
29462 +typedef unsigned long bfd_vma;
29464 +/* A generic signed type which is guaranteed to be big enough to hold any
29465 + arithmetic types we need to deal with. Can be assumed to be compatible
29466 + with bfd_vma in the same way that signed and unsigned ints are compatible
29467 + (as parameters, in assignment, etc). */
29468 +typedef long bfd_signed_vma;
29470 +typedef unsigned long symvalue;
29471 +typedef unsigned long bfd_size_type;
29473 +/* Print a bfd_vma x on stream s. */
29474 +#define fprintf_vma(s,x) fprintf (s, "%08lx", x)
29475 +#define sprintf_vma(s,x) sprintf (s, "%08lx", x)
29477 +#endif /* not BFD64 */
29479 +#define HALF_BFD_SIZE_TYPE \
29480 + (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2))
29482 +#ifndef BFD_HOST_64_BIT
29483 +/* Fall back on a 32 bit type. The idea is to make these types always
29484 + available for function return types, but in the case that
29485 + BFD_HOST_64_BIT is undefined such a function should abort or
29486 + otherwise signal an error. */
29487 +typedef bfd_signed_vma bfd_int64_t;
29488 +typedef bfd_vma bfd_uint64_t;
29491 +/* An offset into a file. BFD always uses the largest possible offset
29492 + based on the build time availability of fseek, fseeko, or fseeko64. */
29493 +typedef BFD_HOST_64_BIT file_ptr;
29494 +typedef unsigned BFD_HOST_64_BIT ufile_ptr;
29496 +extern void bfd_sprintf_vma (bfd *, char *, bfd_vma);
29497 +extern void bfd_fprintf_vma (bfd *, void *, bfd_vma);
29499 +#define printf_vma(x) fprintf_vma(stdout,x)
29500 +#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
29502 +typedef unsigned int flagword; /* 32 bits of flags */
29503 +typedef unsigned char bfd_byte;
29505 +/* File formats. */
29507 +typedef enum bfd_format
29509 + bfd_unknown = 0, /* File format is unknown. */
29510 + bfd_object, /* Linker/assembler/compiler output. */
29511 + bfd_archive, /* Object archive file. */
29512 + bfd_core, /* Core dump. */
29513 + bfd_type_end /* Marks the end; don't use it! */
29517 +/* Values that may appear in the flags field of a BFD. These also
29518 + appear in the object_flags field of the bfd_target structure, where
29519 + they indicate the set of flags used by that backend (not all flags
29520 + are meaningful for all object file formats) (FIXME: at the moment,
29521 + the object_flags values have mostly just been copied from backend
29522 + to another, and are not necessarily correct). */
29525 +#define BFD_NO_FLAGS 0x00
29527 +/* BFD contains relocation entries. */
29528 +#define HAS_RELOC 0x01
29530 +/* BFD is directly executable. */
29531 +#define EXEC_P 0x02
29533 +/* BFD has line number information (basically used for F_LNNO in a
29535 +#define HAS_LINENO 0x04
29537 +/* BFD has debugging information. */
29538 +#define HAS_DEBUG 0x08
29540 +/* BFD has symbols. */
29541 +#define HAS_SYMS 0x10
29543 +/* BFD has local symbols (basically used for F_LSYMS in a COFF
29545 +#define HAS_LOCALS 0x20
29547 +/* BFD is a dynamic object. */
29548 +#define DYNAMIC 0x40
29550 +/* Text section is write protected (if D_PAGED is not set, this is
29551 + like an a.out NMAGIC file) (the linker sets this by default, but
29552 + clears it for -r or -N). */
29553 +#define WP_TEXT 0x80
29555 +/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
29556 + linker sets this by default, but clears it for -r or -n or -N). */
29557 +#define D_PAGED 0x100
29559 +/* BFD is relaxable (this means that bfd_relax_section may be able to
29560 + do something) (sometimes bfd_relax_section can do something even if
29561 + this is not set). */
29562 +#define BFD_IS_RELAXABLE 0x200
29564 +/* This may be set before writing out a BFD to request using a
29565 + traditional format. For example, this is used to request that when
29566 + writing out an a.out object the symbols not be hashed to eliminate
29568 +#define BFD_TRADITIONAL_FORMAT 0x400
29570 +/* This flag indicates that the BFD contents are actually cached in
29571 + memory. If this is set, iostream points to a bfd_in_memory struct. */
29572 +#define BFD_IN_MEMORY 0x800
29574 +/* The sections in this BFD specify a memory page. */
29575 +#define HAS_LOAD_PAGE 0x1000
29577 +/* This BFD has been created by the linker and doesn't correspond
29578 + to any input file. */
29579 +#define BFD_LINKER_CREATED 0x2000
29581 +/* Symbols and relocation. */
29583 +/* A count of carsyms (canonical archive symbols). */
29584 +typedef unsigned long symindex;
29586 +/* How to perform a relocation. */
29587 +typedef const struct reloc_howto_struct reloc_howto_type;
29589 +#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
29591 +/* General purpose part of a symbol X;
29592 + target specific parts are in libcoff.h, libaout.h, etc. */
29594 +#define bfd_get_section(x) ((x)->section)
29595 +#define bfd_get_output_section(x) ((x)->section->output_section)
29596 +#define bfd_set_section(x,y) ((x)->section) = (y)
29597 +#define bfd_asymbol_base(x) ((x)->section->vma)
29598 +#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
29599 +#define bfd_asymbol_name(x) ((x)->name)
29600 +/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
29601 +#define bfd_asymbol_bfd(x) ((x)->the_bfd)
29602 +#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
29604 +/* A canonical archive symbol. */
29605 +/* This is a type pun with struct ranlib on purpose! */
29606 +typedef struct carsym
29609 + file_ptr file_offset; /* Look here to find the file. */
29611 +carsym; /* To make these you call a carsymogen. */
29613 +/* Used in generating armaps (archive tables of contents).
29614 + Perhaps just a forward definition would do? */
29615 +struct orl /* Output ranlib. */
29617 + char **name; /* Symbol name. */
29622 + } u; /* bfd* or file position. */
29623 + int namidx; /* Index into string table. */
29626 +/* Linenumber stuff. */
29627 +typedef struct lineno_cache_entry
29629 + unsigned int line_number; /* Linenumber from start of function. */
29632 + struct bfd_symbol *sym; /* Function name. */
29633 + bfd_vma offset; /* Offset into section. */
29638 +/* Object and core file sections. */
29640 +#define align_power(addr, align) \
29641 + (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
29643 +typedef struct bfd_section *sec_ptr;
29645 +#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
29646 +#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
29647 +#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
29648 +#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
29649 +#define bfd_section_name(bfd, ptr) ((ptr)->name)
29650 +#define bfd_section_size(bfd, ptr) ((ptr)->size)
29651 +#define bfd_get_section_size(ptr) ((ptr)->size)
29652 +#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
29653 +#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
29654 +#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
29655 +#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
29656 +#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
29658 +#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
29660 +#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
29661 +#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
29662 +#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
29663 +/* Find the address one past the end of SEC. */
29664 +#define bfd_get_section_limit(bfd, sec) \
29665 + (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \
29666 + / bfd_octets_per_byte (bfd))
29668 +typedef struct stat stat_type;
29670 +typedef enum bfd_print_symbol
29672 + bfd_print_symbol_name,
29673 + bfd_print_symbol_more,
29674 + bfd_print_symbol_all
29675 +} bfd_print_symbol_type;
29677 +/* Information about a symbol that nm needs. */
29679 +typedef struct _symbol_info
29683 + const char *name; /* Symbol name. */
29684 + unsigned char stab_type; /* Stab type. */
29685 + char stab_other; /* Stab other. */
29686 + short stab_desc; /* Stab desc. */
29687 + const char *stab_name; /* String for stab type. */
29690 +/* Get the name of a stabs type code. */
29692 +extern const char *bfd_get_stab_name (int);
29694 +/* Hash table routines. There is no way to free up a hash table. */
29696 +/* An element in the hash table. Most uses will actually use a larger
29697 + structure, and an instance of this will be the first field. */
29699 +struct bfd_hash_entry
29701 + /* Next entry for this hash code. */
29702 + struct bfd_hash_entry *next;
29703 + /* String being hashed. */
29704 + const char *string;
29705 + /* Hash code. This is the full hash code, not the index into the
29707 + unsigned long hash;
29710 +/* A hash table. */
29712 +struct bfd_hash_table
29714 + /* The hash array. */
29715 + struct bfd_hash_entry **table;
29716 + /* The number of slots in the hash table. */
29717 + unsigned int size;
29718 + /* A function used to create new elements in the hash table. The
29719 + first entry is itself a pointer to an element. When this
29720 + function is first invoked, this pointer will be NULL. However,
29721 + having the pointer permits a hierarchy of method functions to be
29722 + built each of which calls the function in the superclass. Thus
29723 + each function should be written to allocate a new block of memory
29724 + only if the argument is NULL. */
29725 + struct bfd_hash_entry *(*newfunc)
29726 + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
29727 + /* An objalloc for this hash table. This is a struct objalloc *,
29728 + but we use void * to avoid requiring the inclusion of objalloc.h. */
29732 +/* Initialize a hash table. */
29733 +extern bfd_boolean bfd_hash_table_init
29734 + (struct bfd_hash_table *,
29735 + struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
29736 + struct bfd_hash_table *,
29739 +/* Initialize a hash table specifying a size. */
29740 +extern bfd_boolean bfd_hash_table_init_n
29741 + (struct bfd_hash_table *,
29742 + struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
29743 + struct bfd_hash_table *,
29745 + unsigned int size);
29747 +/* Free up a hash table. */
29748 +extern void bfd_hash_table_free
29749 + (struct bfd_hash_table *);
29751 +/* Look up a string in a hash table. If CREATE is TRUE, a new entry
29752 + will be created for this string if one does not already exist. The
29753 + COPY argument must be TRUE if this routine should copy the string
29754 + into newly allocated memory when adding an entry. */
29755 +extern struct bfd_hash_entry *bfd_hash_lookup
29756 + (struct bfd_hash_table *, const char *, bfd_boolean create,
29757 + bfd_boolean copy);
29759 +/* Replace an entry in a hash table. */
29760 +extern void bfd_hash_replace
29761 + (struct bfd_hash_table *, struct bfd_hash_entry *old,
29762 + struct bfd_hash_entry *nw);
29764 +/* Base method for creating a hash table entry. */
29765 +extern struct bfd_hash_entry *bfd_hash_newfunc
29766 + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
29768 +/* Grab some space for a hash table entry. */
29769 +extern void *bfd_hash_allocate
29770 + (struct bfd_hash_table *, unsigned int);
29772 +/* Traverse a hash table in a random order, calling a function on each
29773 + element. If the function returns FALSE, the traversal stops. The
29774 + INFO argument is passed to the function. */
29775 +extern void bfd_hash_traverse
29776 + (struct bfd_hash_table *,
29777 + bfd_boolean (*) (struct bfd_hash_entry *, void *),
29780 +/* Allows the default size of a hash table to be configured. New hash
29781 + tables allocated using bfd_hash_table_init will be created with
29783 +extern void bfd_hash_set_default_size (bfd_size_type);
29785 +/* This structure is used to keep track of stabs in sections
29786 + information while linking. */
29790 + /* A hash table used to hold stabs strings. */
29791 + struct bfd_strtab_hash *strings;
29792 + /* The header file hash table. */
29793 + struct bfd_hash_table includes;
29794 + /* The first .stabstr section. */
29795 + struct bfd_section *stabstr;
29798 +#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table
29800 +/* User program access to BFD facilities. */
29802 +/* Direct I/O routines, for programs which know more about the object
29803 + file than BFD does. Use higher level routines if possible. */
29805 +extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
29806 +extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
29807 +extern int bfd_seek (bfd *, file_ptr, int);
29808 +extern file_ptr bfd_tell (bfd *);
29809 +extern int bfd_flush (bfd *);
29810 +extern int bfd_stat (bfd *, struct stat *);
29812 +/* Deprecated old routines. */
29814 +#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
29815 + (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
29816 + bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
29817 +#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
29818 + (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
29819 + bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
29821 +#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
29822 + (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
29823 + bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
29824 +#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
29825 + (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
29826 + bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
29828 +extern void warn_deprecated (const char *, const char *, int, const char *);
29830 +/* Cast from const char * to char * so that caller can assign to
29831 + a char * without a warning. */
29832 +#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
29833 +#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
29834 +#define bfd_get_format(abfd) ((abfd)->format)
29835 +#define bfd_get_target(abfd) ((abfd)->xvec->name)
29836 +#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
29837 +#define bfd_family_coff(abfd) \
29838 + (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \
29839 + bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
29840 +#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
29841 +#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
29842 +#define bfd_header_big_endian(abfd) \
29843 + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
29844 +#define bfd_header_little_endian(abfd) \
29845 + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
29846 +#define bfd_get_file_flags(abfd) ((abfd)->flags)
29847 +#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
29848 +#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
29849 +#define bfd_my_archive(abfd) ((abfd)->my_archive)
29850 +#define bfd_has_map(abfd) ((abfd)->has_armap)
29852 +#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
29853 +#define bfd_usrdata(abfd) ((abfd)->usrdata)
29855 +#define bfd_get_start_address(abfd) ((abfd)->start_address)
29856 +#define bfd_get_symcount(abfd) ((abfd)->symcount)
29857 +#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
29858 +#define bfd_count_sections(abfd) ((abfd)->section_count)
29860 +#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount)
29862 +#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
29864 +#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
29866 +extern bfd_boolean bfd_cache_close
29868 +/* NB: This declaration should match the autogenerated one in libbfd.h. */
29870 +extern bfd_boolean bfd_cache_close_all (void);
29872 +extern bfd_boolean bfd_record_phdr
29873 + (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
29874 + bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
29876 +/* Byte swapping routines. */
29878 +bfd_uint64_t bfd_getb64 (const void *);
29879 +bfd_uint64_t bfd_getl64 (const void *);
29880 +bfd_int64_t bfd_getb_signed_64 (const void *);
29881 +bfd_int64_t bfd_getl_signed_64 (const void *);
29882 +bfd_vma bfd_getb32 (const void *);
29883 +bfd_vma bfd_getl32 (const void *);
29884 +bfd_signed_vma bfd_getb_signed_32 (const void *);
29885 +bfd_signed_vma bfd_getl_signed_32 (const void *);
29886 +bfd_vma bfd_getb16 (const void *);
29887 +bfd_vma bfd_getl16 (const void *);
29888 +bfd_signed_vma bfd_getb_signed_16 (const void *);
29889 +bfd_signed_vma bfd_getl_signed_16 (const void *);
29890 +void bfd_putb64 (bfd_uint64_t, void *);
29891 +void bfd_putl64 (bfd_uint64_t, void *);
29892 +void bfd_putb32 (bfd_vma, void *);
29893 +void bfd_putl32 (bfd_vma, void *);
29894 +void bfd_putb16 (bfd_vma, void *);
29895 +void bfd_putl16 (bfd_vma, void *);
29897 +/* Byte swapping routines which take size and endiannes as arguments. */
29899 +bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean);
29900 +void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean);
29902 +extern bfd_boolean bfd_section_already_linked_table_init (void);
29903 +extern void bfd_section_already_linked_table_free (void);
29905 +/* Externally visible ECOFF routines. */
29907 +#if defined(__STDC__) || defined(ALMOST_STDC)
29908 +struct ecoff_debug_info;
29909 +struct ecoff_debug_swap;
29910 +struct ecoff_extr;
29911 +struct bfd_symbol;
29912 +struct bfd_link_info;
29913 +struct bfd_link_hash_entry;
29914 +struct bfd_elf_version_tree;
29916 +extern bfd_vma bfd_ecoff_get_gp_value
29918 +extern bfd_boolean bfd_ecoff_set_gp_value
29919 + (bfd *abfd, bfd_vma gp_value);
29920 +extern bfd_boolean bfd_ecoff_set_regmasks
29921 + (bfd *abfd, unsigned long gprmask, unsigned long fprmask,
29922 + unsigned long *cprmask);
29923 +extern void *bfd_ecoff_debug_init
29924 + (bfd *output_bfd, struct ecoff_debug_info *output_debug,
29925 + const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
29926 +extern void bfd_ecoff_debug_free
29927 + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
29928 + const struct ecoff_debug_swap *output_swap, struct bfd_link_info *);
29929 +extern bfd_boolean bfd_ecoff_debug_accumulate
29930 + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
29931 + const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
29932 + struct ecoff_debug_info *input_debug,
29933 + const struct ecoff_debug_swap *input_swap, struct bfd_link_info *);
29934 +extern bfd_boolean bfd_ecoff_debug_accumulate_other
29935 + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
29936 + const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
29937 + struct bfd_link_info *);
29938 +extern bfd_boolean bfd_ecoff_debug_externals
29939 + (bfd *abfd, struct ecoff_debug_info *debug,
29940 + const struct ecoff_debug_swap *swap, bfd_boolean relocatable,
29941 + bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *),
29942 + void (*set_index) (struct bfd_symbol *, bfd_size_type));
29943 +extern bfd_boolean bfd_ecoff_debug_one_external
29944 + (bfd *abfd, struct ecoff_debug_info *debug,
29945 + const struct ecoff_debug_swap *swap, const char *name,
29946 + struct ecoff_extr *esym);
29947 +extern bfd_size_type bfd_ecoff_debug_size
29948 + (bfd *abfd, struct ecoff_debug_info *debug,
29949 + const struct ecoff_debug_swap *swap);
29950 +extern bfd_boolean bfd_ecoff_write_debug
29951 + (bfd *abfd, struct ecoff_debug_info *debug,
29952 + const struct ecoff_debug_swap *swap, file_ptr where);
29953 +extern bfd_boolean bfd_ecoff_write_accumulated_debug
29954 + (void *handle, bfd *abfd, struct ecoff_debug_info *debug,
29955 + const struct ecoff_debug_swap *swap,
29956 + struct bfd_link_info *info, file_ptr where);
29958 +/* Externally visible ELF routines. */
29960 +struct bfd_link_needed_list
29962 + struct bfd_link_needed_list *next;
29964 + const char *name;
29967 +enum dynamic_lib_link_class {
29969 + DYN_AS_NEEDED = 1,
29970 + DYN_DT_NEEDED = 2,
29971 + DYN_NO_ADD_NEEDED = 4,
29972 + DYN_NO_NEEDED = 8
29975 +extern bfd_boolean bfd_elf_record_link_assignment
29976 + (struct bfd_link_info *, const char *, bfd_boolean);
29977 +extern struct bfd_link_needed_list *bfd_elf_get_needed_list
29978 + (bfd *, struct bfd_link_info *);
29979 +extern bfd_boolean bfd_elf_get_bfd_needed_list
29980 + (bfd *, struct bfd_link_needed_list **);
29981 +extern bfd_boolean bfd_elf_size_dynamic_sections
29982 + (bfd *, const char *, const char *, const char *, const char * const *,
29983 + struct bfd_link_info *, struct bfd_section **,
29984 + struct bfd_elf_version_tree *);
29985 +extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr
29986 + (bfd *, struct bfd_link_info *);
29987 +extern void bfd_elf_set_dt_needed_name
29988 + (bfd *, const char *);
29989 +extern const char *bfd_elf_get_dt_soname
29991 +extern void bfd_elf_set_dyn_lib_class
29993 +extern int bfd_elf_get_dyn_lib_class
29995 +extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
29996 + (bfd *, struct bfd_link_info *);
29997 +extern bfd_boolean bfd_elf_discard_info
29998 + (bfd *, struct bfd_link_info *);
29999 +extern unsigned int _bfd_elf_default_action_discarded
30000 + (struct bfd_section *);
30002 +/* Return an upper bound on the number of bytes required to store a
30003 + copy of ABFD's program header table entries. Return -1 if an error
30004 + occurs; bfd_get_error will return an appropriate code. */
30005 +extern long bfd_get_elf_phdr_upper_bound
30008 +/* Copy ABFD's program header table entries to *PHDRS. The entries
30009 + will be stored as an array of Elf_Internal_Phdr structures, as
30010 + defined in include/elf/internal.h. To find out how large the
30011 + buffer needs to be, call bfd_get_elf_phdr_upper_bound.
30013 + Return the number of program header table entries read, or -1 if an
30014 + error occurs; bfd_get_error will return an appropriate code. */
30015 +extern int bfd_get_elf_phdrs
30016 + (bfd *abfd, void *phdrs);
30018 +/* Create a new BFD as if by bfd_openr. Rather than opening a file,
30019 + reconstruct an ELF file by reading the segments out of remote memory
30020 + based on the ELF file header at EHDR_VMA and the ELF program headers it
30021 + points to. If not null, *LOADBASEP is filled in with the difference
30022 + between the VMAs from which the segments were read, and the VMAs the
30023 + file headers (and hence BFD's idea of each section's VMA) put them at.
30025 + The function TARGET_READ_MEMORY is called to copy LEN bytes from the
30026 + remote memory at target address VMA into the local buffer at MYADDR; it
30027 + should return zero on success or an `errno' code on failure. TEMPL must
30028 + be a BFD for an ELF target with the word size and byte order found in
30029 + the remote memory. */
30030 +extern bfd *bfd_elf_bfd_from_remote_memory
30031 + (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
30032 + int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
30034 +/* Return the arch_size field of an elf bfd, or -1 if not elf. */
30035 +extern int bfd_get_arch_size
30038 +/* Return TRUE if address "naturally" sign extends, or -1 if not elf. */
30039 +extern int bfd_get_sign_extend_vma
30042 +extern struct bfd_section *_bfd_elf_tls_setup
30043 + (bfd *, struct bfd_link_info *);
30045 +extern void _bfd_elf_provide_symbol
30046 + (struct bfd_link_info *, const char *, bfd_vma, struct bfd_section *);
30048 +extern void _bfd_elf_provide_section_bound_symbols
30049 + (struct bfd_link_info *, struct bfd_section *, const char *, const char *);
30051 +extern void _bfd_elf_fix_excluded_sec_syms
30052 + (bfd *, struct bfd_link_info *);
30054 +extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs
30055 + (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *,
30058 +/* SunOS shared library support routines for the linker. */
30060 +extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
30061 + (bfd *, struct bfd_link_info *);
30062 +extern bfd_boolean bfd_sunos_record_link_assignment
30063 + (bfd *, struct bfd_link_info *, const char *);
30064 +extern bfd_boolean bfd_sunos_size_dynamic_sections
30065 + (bfd *, struct bfd_link_info *, struct bfd_section **,
30066 + struct bfd_section **, struct bfd_section **);
30068 +/* Linux shared library support routines for the linker. */
30070 +extern bfd_boolean bfd_i386linux_size_dynamic_sections
30071 + (bfd *, struct bfd_link_info *);
30072 +extern bfd_boolean bfd_m68klinux_size_dynamic_sections
30073 + (bfd *, struct bfd_link_info *);
30074 +extern bfd_boolean bfd_sparclinux_size_dynamic_sections
30075 + (bfd *, struct bfd_link_info *);
30079 +struct _bfd_window_internal;
30080 +typedef struct _bfd_window_internal bfd_window_internal;
30082 +typedef struct _bfd_window
30084 + /* What the user asked for. */
30086 + bfd_size_type size;
30087 + /* The actual window used by BFD. Small user-requested read-only
30088 + regions sharing a page may share a single window into the object
30089 + file. Read-write versions shouldn't until I've fixed things to
30090 + keep track of which portions have been claimed by the
30091 + application; don't want to give the same region back when the
30092 + application wants two writable copies! */
30093 + struct _bfd_window_internal *i;
30097 +extern void bfd_init_window
30099 +extern void bfd_free_window
30101 +extern bfd_boolean bfd_get_file_window
30102 + (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean);
30104 +/* XCOFF support routines for the linker. */
30106 +extern bfd_boolean bfd_xcoff_link_record_set
30107 + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type);
30108 +extern bfd_boolean bfd_xcoff_import_symbol
30109 + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma,
30110 + const char *, const char *, const char *, unsigned int);
30111 +extern bfd_boolean bfd_xcoff_export_symbol
30112 + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
30113 +extern bfd_boolean bfd_xcoff_link_count_reloc
30114 + (bfd *, struct bfd_link_info *, const char *);
30115 +extern bfd_boolean bfd_xcoff_record_link_assignment
30116 + (bfd *, struct bfd_link_info *, const char *);
30117 +extern bfd_boolean bfd_xcoff_size_dynamic_sections
30118 + (bfd *, struct bfd_link_info *, const char *, const char *,
30119 + unsigned long, unsigned long, unsigned long, bfd_boolean,
30120 + int, bfd_boolean, bfd_boolean, struct bfd_section **, bfd_boolean);
30121 +extern bfd_boolean bfd_xcoff_link_generate_rtinit
30122 + (bfd *, const char *, const char *, bfd_boolean);
30124 +/* XCOFF support routines for ar. */
30125 +extern bfd_boolean bfd_xcoff_ar_archive_set_magic
30128 +/* Externally visible COFF routines. */
30130 +#if defined(__STDC__) || defined(ALMOST_STDC)
30131 +struct internal_syment;
30132 +union internal_auxent;
30135 +extern bfd_boolean bfd_coff_get_syment
30136 + (bfd *, struct bfd_symbol *, struct internal_syment *);
30138 +extern bfd_boolean bfd_coff_get_auxent
30139 + (bfd *, struct bfd_symbol *, int, union internal_auxent *);
30141 +extern bfd_boolean bfd_coff_set_symbol_class
30142 + (bfd *, struct bfd_symbol *, unsigned int);
30144 +extern bfd_boolean bfd_m68k_coff_create_embedded_relocs
30145 + (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **);
30147 +/* ARM Interworking support. Called from linker. */
30148 +extern bfd_boolean bfd_arm_allocate_interworking_sections
30149 + (struct bfd_link_info *);
30151 +extern bfd_boolean bfd_arm_process_before_allocation
30152 + (bfd *, struct bfd_link_info *, int);
30154 +extern bfd_boolean bfd_arm_get_bfd_for_interworking
30155 + (bfd *, struct bfd_link_info *);
30157 +/* PE ARM Interworking support. Called from linker. */
30158 +extern bfd_boolean bfd_arm_pe_allocate_interworking_sections
30159 + (struct bfd_link_info *);
30161 +extern bfd_boolean bfd_arm_pe_process_before_allocation
30162 + (bfd *, struct bfd_link_info *, int);
30164 +extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking
30165 + (bfd *, struct bfd_link_info *);
30167 +/* ELF ARM Interworking support. Called from linker. */
30168 +extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections
30169 + (struct bfd_link_info *);
30171 +extern bfd_boolean bfd_elf32_arm_process_before_allocation
30172 + (bfd *, struct bfd_link_info *, int);
30174 +void bfd_elf32_arm_set_target_relocs
30175 + (struct bfd_link_info *, int, char *, int, int);
30177 +extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking
30178 + (bfd *, struct bfd_link_info *);
30180 +extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd
30181 + (bfd *, struct bfd_link_info *);
30183 +/* ELF ARM mapping symbol support */
30184 +extern bfd_boolean bfd_is_arm_mapping_symbol_name
30185 + (const char * name);
30187 +/* ARM Note section processing. */
30188 +extern bfd_boolean bfd_arm_merge_machines
30191 +extern bfd_boolean bfd_arm_update_notes
30192 + (bfd *, const char *);
30194 +extern unsigned int bfd_arm_get_mach_from_notes
30195 + (bfd *, const char *);
30197 +/* TI COFF load page support. */
30198 +extern void bfd_ticoff_set_section_load_page
30199 + (struct bfd_section *, int);
30201 +extern int bfd_ticoff_get_section_load_page
30202 + (struct bfd_section *);
30204 +/* H8/300 functions. */
30205 +extern bfd_vma bfd_h8300_pad_address
30206 + (bfd *, bfd_vma);
30208 +/* IA64 Itanium code generation. Called from linker. */
30209 +extern void bfd_elf32_ia64_after_parse
30212 +extern void bfd_elf64_ia64_after_parse
30215 +/* This structure is used for a comdat section, as in PE. A comdat
30216 + section is associated with a particular symbol. When the linker
30217 + sees a comdat section, it keeps only one of the sections with a
30218 + given name and associated with a given symbol. */
30220 +struct coff_comdat_info
30222 + /* The name of the symbol associated with a comdat section. */
30223 + const char *name;
30225 + /* The local symbol table index of the symbol associated with a
30226 + comdat section. This is only meaningful to the object file format
30227 + specific code; it is not an index into the list returned by
30228 + bfd_canonicalize_symtab. */
30232 +extern struct coff_comdat_info *bfd_coff_get_comdat_section
30233 + (bfd *, struct bfd_section *);
30235 +/* Extracted from init.c. */
30236 +void bfd_init (void);
30238 +/* Extracted from opncls.c. */
30239 +bfd *bfd_fopen (const char *filename, const char *target,
30240 + const char *mode, int fd);
30242 +bfd *bfd_openr (const char *filename, const char *target);
30244 +bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
30246 +bfd *bfd_openstreamr (const char *, const char *, void *);
30248 +bfd *bfd_openr_iovec (const char *filename, const char *target,
30249 + void *(*open) (struct bfd *nbfd,
30250 + void *open_closure),
30251 + void *open_closure,
30252 + file_ptr (*pread) (struct bfd *nbfd,
30256 + file_ptr offset),
30257 + int (*close) (struct bfd *nbfd,
30260 +bfd *bfd_openw (const char *filename, const char *target);
30262 +bfd_boolean bfd_close (bfd *abfd);
30264 +bfd_boolean bfd_close_all_done (bfd *);
30266 +bfd *bfd_create (const char *filename, bfd *templ);
30268 +bfd_boolean bfd_make_writable (bfd *abfd);
30270 +bfd_boolean bfd_make_readable (bfd *abfd);
30272 +unsigned long bfd_calc_gnu_debuglink_crc32
30273 + (unsigned long crc, const unsigned char *buf, bfd_size_type len);
30275 +char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir);
30277 +struct bfd_section *bfd_create_gnu_debuglink_section
30278 + (bfd *abfd, const char *filename);
30280 +bfd_boolean bfd_fill_in_gnu_debuglink_section
30281 + (bfd *abfd, struct bfd_section *sect, const char *filename);
30283 +/* Extracted from libbfd.c. */
30285 +/* Byte swapping macros for user section data. */
30287 +#define bfd_put_8(abfd, val, ptr) \
30288 + ((void) (*((unsigned char *) (ptr)) = (val) & 0xff))
30289 +#define bfd_put_signed_8 \
30291 +#define bfd_get_8(abfd, ptr) \
30292 + (*(unsigned char *) (ptr) & 0xff)
30293 +#define bfd_get_signed_8(abfd, ptr) \
30294 + (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
30296 +#define bfd_put_16(abfd, val, ptr) \
30297 + BFD_SEND (abfd, bfd_putx16, ((val),(ptr)))
30298 +#define bfd_put_signed_16 \
30300 +#define bfd_get_16(abfd, ptr) \
30301 + BFD_SEND (abfd, bfd_getx16, (ptr))
30302 +#define bfd_get_signed_16(abfd, ptr) \
30303 + BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
30305 +#define bfd_put_32(abfd, val, ptr) \
30306 + BFD_SEND (abfd, bfd_putx32, ((val),(ptr)))
30307 +#define bfd_put_signed_32 \
30309 +#define bfd_get_32(abfd, ptr) \
30310 + BFD_SEND (abfd, bfd_getx32, (ptr))
30311 +#define bfd_get_signed_32(abfd, ptr) \
30312 + BFD_SEND (abfd, bfd_getx_signed_32, (ptr))
30314 +#define bfd_put_64(abfd, val, ptr) \
30315 + BFD_SEND (abfd, bfd_putx64, ((val), (ptr)))
30316 +#define bfd_put_signed_64 \
30318 +#define bfd_get_64(abfd, ptr) \
30319 + BFD_SEND (abfd, bfd_getx64, (ptr))
30320 +#define bfd_get_signed_64(abfd, ptr) \
30321 + BFD_SEND (abfd, bfd_getx_signed_64, (ptr))
30323 +#define bfd_get(bits, abfd, ptr) \
30324 + ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \
30325 + : (bits) == 16 ? bfd_get_16 (abfd, ptr) \
30326 + : (bits) == 32 ? bfd_get_32 (abfd, ptr) \
30327 + : (bits) == 64 ? bfd_get_64 (abfd, ptr) \
30328 + : (abort (), (bfd_vma) - 1))
30330 +#define bfd_put(bits, abfd, val, ptr) \
30331 + ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \
30332 + : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \
30333 + : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \
30334 + : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \
30335 + : (abort (), (void) 0))
30338 +/* Byte swapping macros for file header data. */
30340 +#define bfd_h_put_8(abfd, val, ptr) \
30341 + bfd_put_8 (abfd, val, ptr)
30342 +#define bfd_h_put_signed_8(abfd, val, ptr) \
30343 + bfd_put_8 (abfd, val, ptr)
30344 +#define bfd_h_get_8(abfd, ptr) \
30345 + bfd_get_8 (abfd, ptr)
30346 +#define bfd_h_get_signed_8(abfd, ptr) \
30347 + bfd_get_signed_8 (abfd, ptr)
30349 +#define bfd_h_put_16(abfd, val, ptr) \
30350 + BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
30351 +#define bfd_h_put_signed_16 \
30353 +#define bfd_h_get_16(abfd, ptr) \
30354 + BFD_SEND (abfd, bfd_h_getx16, (ptr))
30355 +#define bfd_h_get_signed_16(abfd, ptr) \
30356 + BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
30358 +#define bfd_h_put_32(abfd, val, ptr) \
30359 + BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
30360 +#define bfd_h_put_signed_32 \
30362 +#define bfd_h_get_32(abfd, ptr) \
30363 + BFD_SEND (abfd, bfd_h_getx32, (ptr))
30364 +#define bfd_h_get_signed_32(abfd, ptr) \
30365 + BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
30367 +#define bfd_h_put_64(abfd, val, ptr) \
30368 + BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
30369 +#define bfd_h_put_signed_64 \
30371 +#define bfd_h_get_64(abfd, ptr) \
30372 + BFD_SEND (abfd, bfd_h_getx64, (ptr))
30373 +#define bfd_h_get_signed_64(abfd, ptr) \
30374 + BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
30376 +/* Aliases for the above, which should eventually go away. */
30378 +#define H_PUT_64 bfd_h_put_64
30379 +#define H_PUT_32 bfd_h_put_32
30380 +#define H_PUT_16 bfd_h_put_16
30381 +#define H_PUT_8 bfd_h_put_8
30382 +#define H_PUT_S64 bfd_h_put_signed_64
30383 +#define H_PUT_S32 bfd_h_put_signed_32
30384 +#define H_PUT_S16 bfd_h_put_signed_16
30385 +#define H_PUT_S8 bfd_h_put_signed_8
30386 +#define H_GET_64 bfd_h_get_64
30387 +#define H_GET_32 bfd_h_get_32
30388 +#define H_GET_16 bfd_h_get_16
30389 +#define H_GET_8 bfd_h_get_8
30390 +#define H_GET_S64 bfd_h_get_signed_64
30391 +#define H_GET_S32 bfd_h_get_signed_32
30392 +#define H_GET_S16 bfd_h_get_signed_16
30393 +#define H_GET_S8 bfd_h_get_signed_8
30396 +/* Extracted from bfdio.c. */
30397 +long bfd_get_mtime (bfd *abfd);
30399 +long bfd_get_size (bfd *abfd);
30401 +/* Extracted from bfdwin.c. */
30402 +/* Extracted from section.c. */
30403 +typedef struct bfd_section
30405 + /* The name of the section; the name isn't a copy, the pointer is
30406 + the same as that passed to bfd_make_section. */
30407 + const char *name;
30409 + /* A unique sequence number. */
30412 + /* Which section in the bfd; 0..n-1 as sections are created in a bfd. */
30415 + /* The next section in the list belonging to the BFD, or NULL. */
30416 + struct bfd_section *next;
30418 + /* The previous section in the list belonging to the BFD, or NULL. */
30419 + struct bfd_section *prev;
30421 + /* The field flags contains attributes of the section. Some
30422 + flags are read in from the object file, and some are
30423 + synthesized from other information. */
30426 +#define SEC_NO_FLAGS 0x000
30428 + /* Tells the OS to allocate space for this section when loading.
30429 + This is clear for a section containing debug information only. */
30430 +#define SEC_ALLOC 0x001
30432 + /* Tells the OS to load the section from the file when loading.
30433 + This is clear for a .bss section. */
30434 +#define SEC_LOAD 0x002
30436 + /* The section contains data still to be relocated, so there is
30437 + some relocation information too. */
30438 +#define SEC_RELOC 0x004
30440 + /* A signal to the OS that the section contains read only data. */
30441 +#define SEC_READONLY 0x008
30443 + /* The section contains code only. */
30444 +#define SEC_CODE 0x010
30446 + /* The section contains data only. */
30447 +#define SEC_DATA 0x020
30449 + /* The section will reside in ROM. */
30450 +#define SEC_ROM 0x040
30452 + /* The section contains constructor information. This section
30453 + type is used by the linker to create lists of constructors and
30454 + destructors used by <<g++>>. When a back end sees a symbol
30455 + which should be used in a constructor list, it creates a new
30456 + section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
30457 + the symbol to it, and builds a relocation. To build the lists
30458 + of constructors, all the linker has to do is catenate all the
30459 + sections called <<__CTOR_LIST__>> and relocate the data
30460 + contained within - exactly the operations it would peform on
30461 + standard data. */
30462 +#define SEC_CONSTRUCTOR 0x080
30464 + /* The section has contents - a data section could be
30465 + <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
30466 + <<SEC_HAS_CONTENTS>> */
30467 +#define SEC_HAS_CONTENTS 0x100
30469 + /* An instruction to the linker to not output the section
30470 + even if it has information which would normally be written. */
30471 +#define SEC_NEVER_LOAD 0x200
30473 + /* The section contains thread local data. */
30474 +#define SEC_THREAD_LOCAL 0x400
30476 + /* The section has GOT references. This flag is only for the
30477 + linker, and is currently only used by the elf32-hppa back end.
30478 + It will be set if global offset table references were detected
30479 + in this section, which indicate to the linker that the section
30480 + contains PIC code, and must be handled specially when doing a
30482 +#define SEC_HAS_GOT_REF 0x800
30484 + /* The section contains common symbols (symbols may be defined
30485 + multiple times, the value of a symbol is the amount of
30486 + space it requires, and the largest symbol value is the one
30487 + used). Most targets have exactly one of these (which we
30488 + translate to bfd_com_section_ptr), but ECOFF has two. */
30489 +#define SEC_IS_COMMON 0x1000
30491 + /* The section contains only debugging information. For
30492 + example, this is set for ELF .debug and .stab sections.
30493 + strip tests this flag to see if a section can be
30495 +#define SEC_DEBUGGING 0x2000
30497 + /* The contents of this section are held in memory pointed to
30498 + by the contents field. This is checked by bfd_get_section_contents,
30499 + and the data is retrieved from memory if appropriate. */
30500 +#define SEC_IN_MEMORY 0x4000
30502 + /* The contents of this section are to be excluded by the
30503 + linker for executable and shared objects unless those
30504 + objects are to be further relocated. */
30505 +#define SEC_EXCLUDE 0x8000
30507 + /* The contents of this section are to be sorted based on the sum of
30508 + the symbol and addend values specified by the associated relocation
30509 + entries. Entries without associated relocation entries will be
30510 + appended to the end of the section in an unspecified order. */
30511 +#define SEC_SORT_ENTRIES 0x10000
30513 + /* When linking, duplicate sections of the same name should be
30514 + discarded, rather than being combined into a single section as
30515 + is usually done. This is similar to how common symbols are
30516 + handled. See SEC_LINK_DUPLICATES below. */
30517 +#define SEC_LINK_ONCE 0x20000
30519 + /* If SEC_LINK_ONCE is set, this bitfield describes how the linker
30520 + should handle duplicate sections. */
30521 +#define SEC_LINK_DUPLICATES 0x40000
30523 + /* This value for SEC_LINK_DUPLICATES means that duplicate
30524 + sections with the same name should simply be discarded. */
30525 +#define SEC_LINK_DUPLICATES_DISCARD 0x0
30527 + /* This value for SEC_LINK_DUPLICATES means that the linker
30528 + should warn if there are any duplicate sections, although
30529 + it should still only link one copy. */
30530 +#define SEC_LINK_DUPLICATES_ONE_ONLY 0x80000
30532 + /* This value for SEC_LINK_DUPLICATES means that the linker
30533 + should warn if any duplicate sections are a different size. */
30534 +#define SEC_LINK_DUPLICATES_SAME_SIZE 0x100000
30536 + /* This value for SEC_LINK_DUPLICATES means that the linker
30537 + should warn if any duplicate sections contain different
30539 +#define SEC_LINK_DUPLICATES_SAME_CONTENTS \
30540 + (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE)
30542 + /* This section was created by the linker as part of dynamic
30543 + relocation or other arcane processing. It is skipped when
30544 + going through the first-pass output, trusting that someone
30545 + else up the line will take care of it later. */
30546 +#define SEC_LINKER_CREATED 0x200000
30548 + /* This section should not be subject to garbage collection. */
30549 +#define SEC_KEEP 0x400000
30551 + /* This section contains "short" data, and should be placed
30552 + "near" the GP. */
30553 +#define SEC_SMALL_DATA 0x800000
30555 + /* Attempt to merge identical entities in the section.
30556 + Entity size is given in the entsize field. */
30557 +#define SEC_MERGE 0x1000000
30559 + /* If given with SEC_MERGE, entities to merge are zero terminated
30560 + strings where entsize specifies character size instead of fixed
30562 +#define SEC_STRINGS 0x2000000
30564 + /* This section contains data about section groups. */
30565 +#define SEC_GROUP 0x4000000
30567 + /* The section is a COFF shared library section. This flag is
30568 + only for the linker. If this type of section appears in
30569 + the input file, the linker must copy it to the output file
30570 + without changing the vma or size. FIXME: Although this
30571 + was originally intended to be general, it really is COFF
30572 + specific (and the flag was renamed to indicate this). It
30573 + might be cleaner to have some more general mechanism to
30574 + allow the back end to control what the linker does with
30576 +#define SEC_COFF_SHARED_LIBRARY 0x10000000
30578 + /* This section contains data which may be shared with other
30579 + executables or shared objects. This is for COFF only. */
30580 +#define SEC_COFF_SHARED 0x20000000
30582 + /* When a section with this flag is being linked, then if the size of
30583 + the input section is less than a page, it should not cross a page
30584 + boundary. If the size of the input section is one page or more,
30585 + it should be aligned on a page boundary. This is for TI
30586 + TMS320C54X only. */
30587 +#define SEC_TIC54X_BLOCK 0x40000000
30589 + /* Conditionally link this section; do not link if there are no
30590 + references found to any symbol in the section. This is for TI
30591 + TMS320C54X only. */
30592 +#define SEC_TIC54X_CLINK 0x80000000
30594 + /* End of section flags. */
30596 + /* Some internal packed boolean fields. */
30598 + /* See the vma field. */
30599 + unsigned int user_set_vma : 1;
30601 + /* A mark flag used by some of the linker backends. */
30602 + unsigned int linker_mark : 1;
30604 + /* Another mark flag used by some of the linker backends. Set for
30605 + output sections that have an input section. */
30606 + unsigned int linker_has_input : 1;
30608 + /* Mark flags used by some linker backends for garbage collection. */
30609 + unsigned int gc_mark : 1;
30610 + unsigned int gc_mark_from_eh : 1;
30612 + /* The following flags are used by the ELF linker. */
30614 + /* Mark sections which have been allocated to segments. */
30615 + unsigned int segment_mark : 1;
30617 + /* Type of sec_info information. */
30618 + unsigned int sec_info_type:3;
30619 +#define ELF_INFO_TYPE_NONE 0
30620 +#define ELF_INFO_TYPE_STABS 1
30621 +#define ELF_INFO_TYPE_MERGE 2
30622 +#define ELF_INFO_TYPE_EH_FRAME 3
30623 +#define ELF_INFO_TYPE_JUST_SYMS 4
30625 + /* Nonzero if this section uses RELA relocations, rather than REL. */
30626 + unsigned int use_rela_p:1;
30628 + /* Bits used by various backends. The generic code doesn't touch
30631 + /* Nonzero if this section has TLS related relocations. */
30632 + unsigned int has_tls_reloc:1;
30634 + /* Nonzero if this section has a gp reloc. */
30635 + unsigned int has_gp_reloc:1;
30637 + /* Nonzero if this section needs the relax finalize pass. */
30638 + unsigned int need_finalize_relax:1;
30640 + /* Whether relocations have been processed. */
30641 + unsigned int reloc_done : 1;
30643 + /* End of internal packed boolean fields. */
30645 + /* The virtual memory address of the section - where it will be
30646 + at run time. The symbols are relocated against this. The
30647 + user_set_vma flag is maintained by bfd; if it's not set, the
30648 + backend can assign addresses (for example, in <<a.out>>, where
30649 + the default address for <<.data>> is dependent on the specific
30650 + target and various flags). */
30653 + /* The load address of the section - where it would be in a
30654 + rom image; really only used for writing section header
30658 + /* The size of the section in octets, as it will be output.
30659 + Contains a value even if the section has no contents (e.g., the
30660 + size of <<.bss>>). */
30661 + bfd_size_type size;
30663 + /* For input sections, the original size on disk of the section, in
30664 + octets. This field is used by the linker relaxation code. It is
30665 + currently only set for sections where the linker relaxation scheme
30666 + doesn't cache altered section and reloc contents (stabs, eh_frame,
30667 + SEC_MERGE, some coff relaxing targets), and thus the original size
30668 + needs to be kept to read the section multiple times.
30669 + For output sections, rawsize holds the section size calculated on
30670 + a previous linker relaxation pass. */
30671 + bfd_size_type rawsize;
30673 + /* If this section is going to be output, then this value is the
30674 + offset in *bytes* into the output section of the first byte in the
30675 + input section (byte ==> smallest addressable unit on the
30676 + target). In most cases, if this was going to start at the
30677 + 100th octet (8-bit quantity) in the output section, this value
30678 + would be 100. However, if the target byte size is 16 bits
30679 + (bfd_octets_per_byte is "2"), this value would be 50. */
30680 + bfd_vma output_offset;
30682 + /* The output section through which to map on output. */
30683 + struct bfd_section *output_section;
30685 + /* The alignment requirement of the section, as an exponent of 2 -
30686 + e.g., 3 aligns to 2^3 (or 8). */
30687 + unsigned int alignment_power;
30689 + /* If an input section, a pointer to a vector of relocation
30690 + records for the data in this section. */
30691 + struct reloc_cache_entry *relocation;
30693 + /* If an output section, a pointer to a vector of pointers to
30694 + relocation records for the data in this section. */
30695 + struct reloc_cache_entry **orelocation;
30697 + /* The number of relocation records in one of the above. */
30698 + unsigned reloc_count;
30700 + /* Information below is back end specific - and not always used
30703 + /* File position of section data. */
30704 + file_ptr filepos;
30706 + /* File position of relocation info. */
30707 + file_ptr rel_filepos;
30709 + /* File position of line data. */
30710 + file_ptr line_filepos;
30712 + /* Pointer to data for applications. */
30715 + /* If the SEC_IN_MEMORY flag is set, this points to the actual
30717 + unsigned char *contents;
30719 + /* Attached line number information. */
30722 + /* Number of line number records. */
30723 + unsigned int lineno_count;
30725 + /* Entity size for merging purposes. */
30726 + unsigned int entsize;
30728 + /* Points to the kept section if this section is a link-once section,
30729 + and is discarded. */
30730 + struct bfd_section *kept_section;
30732 + /* When a section is being output, this value changes as more
30733 + linenumbers are written out. */
30734 + file_ptr moving_line_filepos;
30736 + /* What the section number is in the target world. */
30737 + int target_index;
30739 + void *used_by_bfd;
30741 + /* If this is a constructor section then here is a list of the
30742 + relocations created to relocate items within it. */
30743 + struct relent_chain *constructor_chain;
30745 + /* The BFD which owns the section. */
30748 + /* A symbol which points at this section only. */
30749 + struct bfd_symbol *symbol;
30750 + struct bfd_symbol **symbol_ptr_ptr;
30752 + /* Early in the link process, map_head and map_tail are used to build
30753 + a list of input sections attached to an output section. Later,
30754 + output sections use these fields for a list of bfd_link_order
30757 + struct bfd_link_order *link_order;
30758 + struct bfd_section *s;
30759 + } map_head, map_tail;
30762 +/* These sections are global, and are managed by BFD. The application
30763 + and target back end are not permitted to change the values in
30764 + these sections. New code should use the section_ptr macros rather
30765 + than referring directly to the const sections. The const sections
30766 + may eventually vanish. */
30767 +#define BFD_ABS_SECTION_NAME "*ABS*"
30768 +#define BFD_UND_SECTION_NAME "*UND*"
30769 +#define BFD_COM_SECTION_NAME "*COM*"
30770 +#define BFD_IND_SECTION_NAME "*IND*"
30772 +/* The absolute section. */
30773 +extern asection bfd_abs_section;
30774 +#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
30775 +#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
30776 +/* Pointer to the undefined section. */
30777 +extern asection bfd_und_section;
30778 +#define bfd_und_section_ptr ((asection *) &bfd_und_section)
30779 +#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
30780 +/* Pointer to the common section. */
30781 +extern asection bfd_com_section;
30782 +#define bfd_com_section_ptr ((asection *) &bfd_com_section)
30783 +/* Pointer to the indirect section. */
30784 +extern asection bfd_ind_section;
30785 +#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
30786 +#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
30788 +#define bfd_is_const_section(SEC) \
30789 + ( ((SEC) == bfd_abs_section_ptr) \
30790 + || ((SEC) == bfd_und_section_ptr) \
30791 + || ((SEC) == bfd_com_section_ptr) \
30792 + || ((SEC) == bfd_ind_section_ptr))
30794 +extern const struct bfd_symbol * const bfd_abs_symbol;
30795 +extern const struct bfd_symbol * const bfd_com_symbol;
30796 +extern const struct bfd_symbol * const bfd_und_symbol;
30797 +extern const struct bfd_symbol * const bfd_ind_symbol;
30799 +/* Macros to handle insertion and deletion of a bfd's sections. These
30800 + only handle the list pointers, ie. do not adjust section_count,
30801 + target_index etc. */
30802 +#define bfd_section_list_remove(ABFD, S) \
30805 + asection *_s = S; \
30806 + asection *_next = _s->next; \
30807 + asection *_prev = _s->prev; \
30809 + _prev->next = _next; \
30811 + (ABFD)->sections = _next; \
30813 + _next->prev = _prev; \
30815 + (ABFD)->section_last = _prev; \
30818 +#define bfd_section_list_append(ABFD, S) \
30821 + asection *_s = S; \
30822 + bfd *_abfd = ABFD; \
30823 + _s->next = NULL; \
30824 + if (_abfd->section_last) \
30826 + _s->prev = _abfd->section_last; \
30827 + _abfd->section_last->next = _s; \
30831 + _s->prev = NULL; \
30832 + _abfd->sections = _s; \
30834 + _abfd->section_last = _s; \
30837 +#define bfd_section_list_prepend(ABFD, S) \
30840 + asection *_s = S; \
30841 + bfd *_abfd = ABFD; \
30842 + _s->prev = NULL; \
30843 + if (_abfd->sections) \
30845 + _s->next = _abfd->sections; \
30846 + _abfd->sections->prev = _s; \
30850 + _s->next = NULL; \
30851 + _abfd->section_last = _s; \
30853 + _abfd->sections = _s; \
30856 +#define bfd_section_list_insert_after(ABFD, A, S) \
30859 + asection *_a = A; \
30860 + asection *_s = S; \
30861 + asection *_next = _a->next; \
30862 + _s->next = _next; \
30866 + _next->prev = _s; \
30868 + (ABFD)->section_last = _s; \
30871 +#define bfd_section_list_insert_before(ABFD, B, S) \
30874 + asection *_b = B; \
30875 + asection *_s = S; \
30876 + asection *_prev = _b->prev; \
30877 + _s->prev = _prev; \
30881 + _prev->next = _s; \
30883 + (ABFD)->sections = _s; \
30886 +#define bfd_section_removed_from_list(ABFD, S) \
30887 + ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S))
30889 +void bfd_section_list_clear (bfd *);
30891 +asection *bfd_get_section_by_name (bfd *abfd, const char *name);
30893 +asection *bfd_get_section_by_name_if
30895 + const char *name,
30896 + bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj),
30899 +char *bfd_get_unique_section_name
30900 + (bfd *abfd, const char *templat, int *count);
30902 +asection *bfd_make_section_old_way (bfd *abfd, const char *name);
30904 +asection *bfd_make_section_anyway_with_flags
30905 + (bfd *abfd, const char *name, flagword flags);
30907 +asection *bfd_make_section_anyway (bfd *abfd, const char *name);
30909 +asection *bfd_make_section_with_flags
30910 + (bfd *, const char *name, flagword flags);
30912 +asection *bfd_make_section (bfd *, const char *name);
30914 +bfd_boolean bfd_set_section_flags
30915 + (bfd *abfd, asection *sec, flagword flags);
30917 +void bfd_map_over_sections
30919 + void (*func) (bfd *abfd, asection *sect, void *obj),
30922 +asection *bfd_sections_find_if
30924 + bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj),
30927 +bfd_boolean bfd_set_section_size
30928 + (bfd *abfd, asection *sec, bfd_size_type val);
30930 +bfd_boolean bfd_set_section_contents
30931 + (bfd *abfd, asection *section, const void *data,
30932 + file_ptr offset, bfd_size_type count);
30934 +bfd_boolean bfd_get_section_contents
30935 + (bfd *abfd, asection *section, void *location, file_ptr offset,
30936 + bfd_size_type count);
30938 +bfd_boolean bfd_malloc_and_get_section
30939 + (bfd *abfd, asection *section, bfd_byte **buf);
30941 +bfd_boolean bfd_copy_private_section_data
30942 + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
30944 +#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
30945 + BFD_SEND (obfd, _bfd_copy_private_section_data, \
30946 + (ibfd, isection, obfd, osection))
30947 +bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec);
30949 +bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group);
30951 +/* Extracted from archures.c. */
30952 +enum bfd_architecture
30954 + bfd_arch_unknown, /* File arch not known. */
30955 + bfd_arch_obscure, /* Arch known, not one of these. */
30956 + bfd_arch_m68k, /* Motorola 68xxx */
30957 +#define bfd_mach_m68000 1
30958 +#define bfd_mach_m68008 2
30959 +#define bfd_mach_m68010 3
30960 +#define bfd_mach_m68020 4
30961 +#define bfd_mach_m68030 5
30962 +#define bfd_mach_m68040 6
30963 +#define bfd_mach_m68060 7
30964 +#define bfd_mach_cpu32 8
30965 +#define bfd_mach_mcf5200 9
30966 +#define bfd_mach_mcf5206e 10
30967 +#define bfd_mach_mcf5307 11
30968 +#define bfd_mach_mcf5407 12
30969 +#define bfd_mach_mcf528x 13
30970 +#define bfd_mach_mcfv4e 14
30971 +#define bfd_mach_mcf521x 15
30972 +#define bfd_mach_mcf5249 16
30973 +#define bfd_mach_mcf547x 17
30974 +#define bfd_mach_mcf548x 18
30975 + bfd_arch_vax, /* DEC Vax */
30976 + bfd_arch_i960, /* Intel 960 */
30977 + /* The order of the following is important.
30978 + lower number indicates a machine type that
30979 + only accepts a subset of the instructions
30980 + available to machines with higher numbers.
30981 + The exception is the "ca", which is
30982 + incompatible with all other machines except
30985 +#define bfd_mach_i960_core 1
30986 +#define bfd_mach_i960_ka_sa 2
30987 +#define bfd_mach_i960_kb_sb 3
30988 +#define bfd_mach_i960_mc 4
30989 +#define bfd_mach_i960_xa 5
30990 +#define bfd_mach_i960_ca 6
30991 +#define bfd_mach_i960_jx 7
30992 +#define bfd_mach_i960_hx 8
30994 + bfd_arch_or32, /* OpenRISC 32 */
30996 + bfd_arch_a29k, /* AMD 29000 */
30997 + bfd_arch_sparc, /* SPARC */
30998 +#define bfd_mach_sparc 1
30999 +/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */
31000 +#define bfd_mach_sparc_sparclet 2
31001 +#define bfd_mach_sparc_sparclite 3
31002 +#define bfd_mach_sparc_v8plus 4
31003 +#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns. */
31004 +#define bfd_mach_sparc_sparclite_le 6
31005 +#define bfd_mach_sparc_v9 7
31006 +#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns. */
31007 +#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns. */
31008 +#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns. */
31009 +/* Nonzero if MACH has the v9 instruction set. */
31010 +#define bfd_mach_sparc_v9_p(mach) \
31011 + ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \
31012 + && (mach) != bfd_mach_sparc_sparclite_le)
31013 +/* Nonzero if MACH is a 64 bit sparc architecture. */
31014 +#define bfd_mach_sparc_64bit_p(mach) \
31015 + ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb)
31016 + bfd_arch_mips, /* MIPS Rxxxx */
31017 +#define bfd_mach_mips3000 3000
31018 +#define bfd_mach_mips3900 3900
31019 +#define bfd_mach_mips4000 4000
31020 +#define bfd_mach_mips4010 4010
31021 +#define bfd_mach_mips4100 4100
31022 +#define bfd_mach_mips4111 4111
31023 +#define bfd_mach_mips4120 4120
31024 +#define bfd_mach_mips4300 4300
31025 +#define bfd_mach_mips4400 4400
31026 +#define bfd_mach_mips4600 4600
31027 +#define bfd_mach_mips4650 4650
31028 +#define bfd_mach_mips5000 5000
31029 +#define bfd_mach_mips5400 5400
31030 +#define bfd_mach_mips5500 5500
31031 +#define bfd_mach_mips6000 6000
31032 +#define bfd_mach_mips7000 7000
31033 +#define bfd_mach_mips8000 8000
31034 +#define bfd_mach_mips9000 9000
31035 +#define bfd_mach_mips10000 10000
31036 +#define bfd_mach_mips12000 12000
31037 +#define bfd_mach_mips16 16
31038 +#define bfd_mach_mips5 5
31039 +#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01 */
31040 +#define bfd_mach_mipsisa32 32
31041 +#define bfd_mach_mipsisa32r2 33
31042 +#define bfd_mach_mipsisa64 64
31043 +#define bfd_mach_mipsisa64r2 65
31044 + bfd_arch_i386, /* Intel 386 */
31045 +#define bfd_mach_i386_i386 1
31046 +#define bfd_mach_i386_i8086 2
31047 +#define bfd_mach_i386_i386_intel_syntax 3
31048 +#define bfd_mach_x86_64 64
31049 +#define bfd_mach_x86_64_intel_syntax 65
31050 + bfd_arch_we32k, /* AT&T WE32xxx */
31051 + bfd_arch_tahoe, /* CCI/Harris Tahoe */
31052 + bfd_arch_i860, /* Intel 860 */
31053 + bfd_arch_i370, /* IBM 360/370 Mainframes */
31054 + bfd_arch_romp, /* IBM ROMP PC/RT */
31055 + bfd_arch_alliant, /* Alliant */
31056 + bfd_arch_convex, /* Convex */
31057 + bfd_arch_m88k, /* Motorola 88xxx */
31058 + bfd_arch_m98k, /* Motorola 98xxx */
31059 + bfd_arch_pyramid, /* Pyramid Technology */
31060 + bfd_arch_h8300, /* Renesas H8/300 (formerly Hitachi H8/300) */
31061 +#define bfd_mach_h8300 1
31062 +#define bfd_mach_h8300h 2
31063 +#define bfd_mach_h8300s 3
31064 +#define bfd_mach_h8300hn 4
31065 +#define bfd_mach_h8300sn 5
31066 +#define bfd_mach_h8300sx 6
31067 +#define bfd_mach_h8300sxn 7
31068 + bfd_arch_pdp11, /* DEC PDP-11 */
31069 + bfd_arch_powerpc, /* PowerPC */
31070 +#define bfd_mach_ppc 32
31071 +#define bfd_mach_ppc64 64
31072 +#define bfd_mach_ppc_403 403
31073 +#define bfd_mach_ppc_403gc 4030
31074 +#define bfd_mach_ppc_505 505
31075 +#define bfd_mach_ppc_601 601
31076 +#define bfd_mach_ppc_602 602
31077 +#define bfd_mach_ppc_603 603
31078 +#define bfd_mach_ppc_ec603e 6031
31079 +#define bfd_mach_ppc_604 604
31080 +#define bfd_mach_ppc_620 620
31081 +#define bfd_mach_ppc_630 630
31082 +#define bfd_mach_ppc_750 750
31083 +#define bfd_mach_ppc_860 860
31084 +#define bfd_mach_ppc_a35 35
31085 +#define bfd_mach_ppc_rs64ii 642
31086 +#define bfd_mach_ppc_rs64iii 643
31087 +#define bfd_mach_ppc_7400 7400
31088 +#define bfd_mach_ppc_e500 500
31089 + bfd_arch_rs6000, /* IBM RS/6000 */
31090 +#define bfd_mach_rs6k 6000
31091 +#define bfd_mach_rs6k_rs1 6001
31092 +#define bfd_mach_rs6k_rsc 6003
31093 +#define bfd_mach_rs6k_rs2 6002
31094 + bfd_arch_hppa, /* HP PA RISC */
31095 +#define bfd_mach_hppa10 10
31096 +#define bfd_mach_hppa11 11
31097 +#define bfd_mach_hppa20 20
31098 +#define bfd_mach_hppa20w 25
31099 + bfd_arch_d10v, /* Mitsubishi D10V */
31100 +#define bfd_mach_d10v 1
31101 +#define bfd_mach_d10v_ts2 2
31102 +#define bfd_mach_d10v_ts3 3
31103 + bfd_arch_d30v, /* Mitsubishi D30V */
31104 + bfd_arch_dlx, /* DLX */
31105 + bfd_arch_m68hc11, /* Motorola 68HC11 */
31106 + bfd_arch_m68hc12, /* Motorola 68HC12 */
31107 +#define bfd_mach_m6812_default 0
31108 +#define bfd_mach_m6812 1
31109 +#define bfd_mach_m6812s 2
31110 + bfd_arch_z8k, /* Zilog Z8000 */
31111 +#define bfd_mach_z8001 1
31112 +#define bfd_mach_z8002 2
31113 + bfd_arch_h8500, /* Renesas H8/500 (formerly Hitachi H8/500) */
31114 + bfd_arch_sh, /* Renesas / SuperH SH (formerly Hitachi SH) */
31115 +#define bfd_mach_sh 1
31116 +#define bfd_mach_sh2 0x20
31117 +#define bfd_mach_sh_dsp 0x2d
31118 +#define bfd_mach_sh2a 0x2a
31119 +#define bfd_mach_sh2a_nofpu 0x2b
31120 +#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1
31121 +#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2
31122 +#define bfd_mach_sh2a_or_sh4 0x2a3
31123 +#define bfd_mach_sh2a_or_sh3e 0x2a4
31124 +#define bfd_mach_sh2e 0x2e
31125 +#define bfd_mach_sh3 0x30
31126 +#define bfd_mach_sh3_nommu 0x31
31127 +#define bfd_mach_sh3_dsp 0x3d
31128 +#define bfd_mach_sh3e 0x3e
31129 +#define bfd_mach_sh4 0x40
31130 +#define bfd_mach_sh4_nofpu 0x41
31131 +#define bfd_mach_sh4_nommu_nofpu 0x42
31132 +#define bfd_mach_sh4a 0x4a
31133 +#define bfd_mach_sh4a_nofpu 0x4b
31134 +#define bfd_mach_sh4al_dsp 0x4d
31135 +#define bfd_mach_sh5 0x50
31136 + bfd_arch_alpha, /* Dec Alpha */
31137 +#define bfd_mach_alpha_ev4 0x10
31138 +#define bfd_mach_alpha_ev5 0x20
31139 +#define bfd_mach_alpha_ev6 0x30
31140 + bfd_arch_arm, /* Advanced Risc Machines ARM. */
31141 +#define bfd_mach_arm_unknown 0
31142 +#define bfd_mach_arm_2 1
31143 +#define bfd_mach_arm_2a 2
31144 +#define bfd_mach_arm_3 3
31145 +#define bfd_mach_arm_3M 4
31146 +#define bfd_mach_arm_4 5
31147 +#define bfd_mach_arm_4T 6
31148 +#define bfd_mach_arm_5 7
31149 +#define bfd_mach_arm_5T 8
31150 +#define bfd_mach_arm_5TE 9
31151 +#define bfd_mach_arm_XScale 10
31152 +#define bfd_mach_arm_ep9312 11
31153 +#define bfd_mach_arm_iWMMXt 12
31154 + bfd_arch_ns32k, /* National Semiconductors ns32000 */
31155 + bfd_arch_w65, /* WDC 65816 */
31156 + bfd_arch_tic30, /* Texas Instruments TMS320C30 */
31157 + bfd_arch_tic4x, /* Texas Instruments TMS320C3X/4X */
31158 +#define bfd_mach_tic3x 30
31159 +#define bfd_mach_tic4x 40
31160 + bfd_arch_tic54x, /* Texas Instruments TMS320C54X */
31161 + bfd_arch_tic80, /* TI TMS320c80 (MVP) */
31162 + bfd_arch_v850, /* NEC V850 */
31163 +#define bfd_mach_v850 1
31164 +#define bfd_mach_v850e 'E'
31165 +#define bfd_mach_v850e1 '1'
31166 + bfd_arch_arc, /* ARC Cores */
31167 +#define bfd_mach_arc_5 5
31168 +#define bfd_mach_arc_6 6
31169 +#define bfd_mach_arc_7 7
31170 +#define bfd_mach_arc_8 8
31171 + bfd_arch_m32c, /* Renesas M16C/M32C. */
31172 +#define bfd_mach_m16c 0x75
31173 +#define bfd_mach_m32c 0x78
31174 + bfd_arch_m32r, /* Renesas M32R (formerly Mitsubishi M32R/D) */
31175 +#define bfd_mach_m32r 1 /* For backwards compatibility. */
31176 +#define bfd_mach_m32rx 'x'
31177 +#define bfd_mach_m32r2 '2'
31178 + bfd_arch_mn10200, /* Matsushita MN10200 */
31179 + bfd_arch_mn10300, /* Matsushita MN10300 */
31180 +#define bfd_mach_mn10300 300
31181 +#define bfd_mach_am33 330
31182 +#define bfd_mach_am33_2 332
31184 +#define bfd_mach_fr30 0x46523330
31186 +#define bfd_mach_frv 1
31187 +#define bfd_mach_frvsimple 2
31188 +#define bfd_mach_fr300 300
31189 +#define bfd_mach_fr400 400
31190 +#define bfd_mach_fr450 450
31191 +#define bfd_mach_frvtomcat 499 /* fr500 prototype */
31192 +#define bfd_mach_fr500 500
31193 +#define bfd_mach_fr550 550
31195 + bfd_arch_ia64, /* HP/Intel ia64 */
31196 +#define bfd_mach_ia64_elf64 64
31197 +#define bfd_mach_ia64_elf32 32
31198 + bfd_arch_ip2k, /* Ubicom IP2K microcontrollers. */
31199 +#define bfd_mach_ip2022 1
31200 +#define bfd_mach_ip2022ext 2
31201 + bfd_arch_iq2000, /* Vitesse IQ2000. */
31202 +#define bfd_mach_iq2000 1
31203 +#define bfd_mach_iq10 2
31205 +#define bfd_mach_ms1 1
31206 +#define bfd_mach_mrisc2 2
31208 + bfd_arch_avr, /* Atmel AVR microcontrollers. */
31209 +#define bfd_mach_avr1 1
31210 +#define bfd_mach_avr2 2
31211 +#define bfd_mach_avr3 3
31212 +#define bfd_mach_avr4 4
31213 +#define bfd_mach_avr5 5
31214 + bfd_arch_cr16c, /* National Semiconductor CompactRISC. */
31215 +#define bfd_mach_cr16c 1
31216 + bfd_arch_crx, /* National Semiconductor CRX. */
31217 +#define bfd_mach_crx 1
31218 + bfd_arch_cris, /* Axis CRIS */
31219 +#define bfd_mach_cris_v0_v10 255
31220 +#define bfd_mach_cris_v32 32
31221 +#define bfd_mach_cris_v10_v32 1032
31222 + bfd_arch_s390, /* IBM s390 */
31223 +#define bfd_mach_s390_31 31
31224 +#define bfd_mach_s390_64 64
31225 + bfd_arch_openrisc, /* OpenRISC */
31226 + bfd_arch_mmix, /* Donald Knuth's educational processor. */
31227 + bfd_arch_xstormy16,
31228 +#define bfd_mach_xstormy16 1
31229 + bfd_arch_msp430, /* Texas Instruments MSP430 architecture. */
31230 +#define bfd_mach_msp11 11
31231 +#define bfd_mach_msp110 110
31232 +#define bfd_mach_msp12 12
31233 +#define bfd_mach_msp13 13
31234 +#define bfd_mach_msp14 14
31235 +#define bfd_mach_msp15 15
31236 +#define bfd_mach_msp16 16
31237 +#define bfd_mach_msp31 31
31238 +#define bfd_mach_msp32 32
31239 +#define bfd_mach_msp33 33
31240 +#define bfd_mach_msp41 41
31241 +#define bfd_mach_msp42 42
31242 +#define bfd_mach_msp43 43
31243 +#define bfd_mach_msp44 44
31244 + bfd_arch_xtensa, /* Tensilica's Xtensa cores. */
31245 +#define bfd_mach_xtensa 1
31246 + bfd_arch_maxq, /* Dallas MAXQ 10/20 */
31247 +#define bfd_mach_maxq10 10
31248 +#define bfd_mach_maxq20 20
31252 +typedef struct bfd_arch_info
31254 + int bits_per_word;
31255 + int bits_per_address;
31256 + int bits_per_byte;
31257 + enum bfd_architecture arch;
31258 + unsigned long mach;
31259 + const char *arch_name;
31260 + const char *printable_name;
31261 + unsigned int section_align_power;
31262 + /* TRUE if this is the default machine for the architecture.
31263 + The default arch should be the first entry for an arch so that
31264 + all the entries for that arch can be accessed via <<next>>. */
31265 + bfd_boolean the_default;
31266 + const struct bfd_arch_info * (*compatible)
31267 + (const struct bfd_arch_info *a, const struct bfd_arch_info *b);
31269 + bfd_boolean (*scan) (const struct bfd_arch_info *, const char *);
31271 + const struct bfd_arch_info *next;
31273 +bfd_arch_info_type;
31275 +const char *bfd_printable_name (bfd *abfd);
31277 +const bfd_arch_info_type *bfd_scan_arch (const char *string);
31279 +const char **bfd_arch_list (void);
31281 +const bfd_arch_info_type *bfd_arch_get_compatible
31282 + (const bfd *abfd, const bfd *bbfd, bfd_boolean accept_unknowns);
31284 +void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg);
31286 +enum bfd_architecture bfd_get_arch (bfd *abfd);
31288 +unsigned long bfd_get_mach (bfd *abfd);
31290 +unsigned int bfd_arch_bits_per_byte (bfd *abfd);
31292 +unsigned int bfd_arch_bits_per_address (bfd *abfd);
31294 +const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd);
31296 +const bfd_arch_info_type *bfd_lookup_arch
31297 + (enum bfd_architecture arch, unsigned long machine);
31299 +const char *bfd_printable_arch_mach
31300 + (enum bfd_architecture arch, unsigned long machine);
31302 +unsigned int bfd_octets_per_byte (bfd *abfd);
31304 +unsigned int bfd_arch_mach_octets_per_byte
31305 + (enum bfd_architecture arch, unsigned long machine);
31307 +/* Extracted from reloc.c. */
31308 +typedef enum bfd_reloc_status
31310 + /* No errors detected. */
31313 + /* The relocation was performed, but there was an overflow. */
31314 + bfd_reloc_overflow,
31316 + /* The address to relocate was not within the section supplied. */
31317 + bfd_reloc_outofrange,
31319 + /* Used by special functions. */
31320 + bfd_reloc_continue,
31322 + /* Unsupported relocation size requested. */
31323 + bfd_reloc_notsupported,
31328 + /* The symbol to relocate against was undefined. */
31329 + bfd_reloc_undefined,
31331 + /* The relocation was performed, but may not be ok - presently
31332 + generated only when linking i960 coff files with i960 b.out
31333 + symbols. If this type is returned, the error_message argument
31334 + to bfd_perform_relocation will be set. */
31335 + bfd_reloc_dangerous
31337 + bfd_reloc_status_type;
31340 +typedef struct reloc_cache_entry
31342 + /* A pointer into the canonical table of pointers. */
31343 + struct bfd_symbol **sym_ptr_ptr;
31345 + /* offset in section. */
31346 + bfd_size_type address;
31348 + /* addend for relocation value. */
31351 + /* Pointer to how to perform the required relocation. */
31352 + reloc_howto_type *howto;
31357 +enum complain_overflow
31359 + /* Do not complain on overflow. */
31360 + complain_overflow_dont,
31362 + /* Complain if the bitfield overflows, whether it is considered
31363 + as signed or unsigned. */
31364 + complain_overflow_bitfield,
31366 + /* Complain if the value overflows when considered as signed
31368 + complain_overflow_signed,
31370 + /* Complain if the value overflows when considered as an
31371 + unsigned number. */
31372 + complain_overflow_unsigned
31375 +struct reloc_howto_struct
31377 + /* The type field has mainly a documentary use - the back end can
31378 + do what it wants with it, though normally the back end's
31379 + external idea of what a reloc number is stored
31380 + in this field. For example, a PC relative word relocation
31381 + in a coff environment has the type 023 - because that's
31382 + what the outside world calls a R_PCRWORD reloc. */
31383 + unsigned int type;
31385 + /* The value the final relocation is shifted right by. This drops
31386 + unwanted data from the relocation. */
31387 + unsigned int rightshift;
31389 + /* The size of the item to be relocated. This is *not* a
31390 + power-of-two measure. To get the number of bytes operated
31391 + on by a type of relocation, use bfd_get_reloc_size. */
31394 + /* The number of bits in the item to be relocated. This is used
31395 + when doing overflow checking. */
31396 + unsigned int bitsize;
31398 + /* Notes that the relocation is relative to the location in the
31399 + data section of the addend. The relocation function will
31400 + subtract from the relocation value the address of the location
31401 + being relocated. */
31402 + bfd_boolean pc_relative;
31404 + /* The bit position of the reloc value in the destination.
31405 + The relocated value is left shifted by this amount. */
31406 + unsigned int bitpos;
31408 + /* What type of overflow error should be checked for when
31410 + enum complain_overflow complain_on_overflow;
31412 + /* If this field is non null, then the supplied function is
31413 + called rather than the normal function. This allows really
31414 + strange relocation methods to be accommodated (e.g., i960 callj
31415 + instructions). */
31416 + bfd_reloc_status_type (*special_function)
31417 + (bfd *, arelent *, struct bfd_symbol *, void *, asection *,
31420 + /* The textual name of the relocation type. */
31423 + /* Some formats record a relocation addend in the section contents
31424 + rather than with the relocation. For ELF formats this is the
31425 + distinction between USE_REL and USE_RELA (though the code checks
31426 + for USE_REL == 1/0). The value of this field is TRUE if the
31427 + addend is recorded with the section contents; when performing a
31428 + partial link (ld -r) the section contents (the data) will be
31429 + modified. The value of this field is FALSE if addends are
31430 + recorded with the relocation (in arelent.addend); when performing
31431 + a partial link the relocation will be modified.
31432 + All relocations for all ELF USE_RELA targets should set this field
31433 + to FALSE (values of TRUE should be looked on with suspicion).
31434 + However, the converse is not true: not all relocations of all ELF
31435 + USE_REL targets set this field to TRUE. Why this is so is peculiar
31436 + to each particular target. For relocs that aren't used in partial
31437 + links (e.g. GOT stuff) it doesn't matter what this is set to. */
31438 + bfd_boolean partial_inplace;
31440 + /* src_mask selects the part of the instruction (or data) to be used
31441 + in the relocation sum. If the target relocations don't have an
31442 + addend in the reloc, eg. ELF USE_REL, src_mask will normally equal
31443 + dst_mask to extract the addend from the section contents. If
31444 + relocations do have an addend in the reloc, eg. ELF USE_RELA, this
31445 + field should be zero. Non-zero values for ELF USE_RELA targets are
31446 + bogus as in those cases the value in the dst_mask part of the
31447 + section contents should be treated as garbage. */
31448 + bfd_vma src_mask;
31450 + /* dst_mask selects which parts of the instruction (or data) are
31451 + replaced with a relocated value. */
31452 + bfd_vma dst_mask;
31454 + /* When some formats create PC relative instructions, they leave
31455 + the value of the pc of the place being relocated in the offset
31456 + slot of the instruction, so that a PC relative relocation can
31457 + be made just by adding in an ordinary offset (e.g., sun3 a.out).
31458 + Some formats leave the displacement part of an instruction
31459 + empty (e.g., m88k bcs); this flag signals the fact. */
31460 + bfd_boolean pcrel_offset;
31463 +#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
31464 + { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC }
31465 +#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \
31466 + HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \
31467 + NAME, FALSE, 0, 0, IN)
31469 +#define EMPTY_HOWTO(C) \
31470 + HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \
31471 + NULL, FALSE, 0, 0, FALSE)
31473 +#define HOWTO_PREPARE(relocation, symbol) \
31475 + if (symbol != NULL) \
31477 + if (bfd_is_com_section (symbol->section)) \
31479 + relocation = 0; \
31483 + relocation = symbol->value; \
31488 +unsigned int bfd_get_reloc_size (reloc_howto_type *);
31490 +typedef struct relent_chain
31493 + struct relent_chain *next;
31497 +bfd_reloc_status_type bfd_check_overflow
31498 + (enum complain_overflow how,
31499 + unsigned int bitsize,
31500 + unsigned int rightshift,
31501 + unsigned int addrsize,
31502 + bfd_vma relocation);
31504 +bfd_reloc_status_type bfd_perform_relocation
31506 + arelent *reloc_entry,
31508 + asection *input_section,
31510 + char **error_message);
31512 +bfd_reloc_status_type bfd_install_relocation
31514 + arelent *reloc_entry,
31515 + void *data, bfd_vma data_start,
31516 + asection *input_section,
31517 + char **error_message);
31519 +enum bfd_reloc_code_real {
31520 + _dummy_first_bfd_reloc_code_real,
31523 +/* Basic absolute relocations of N bits. */
31532 +/* PC-relative relocations. Sometimes these are relative to the address
31533 +of the relocation itself; sometimes they are relative to the start of
31534 +the section containing the relocation. It depends on the specific target.
31536 +The 24-bit relocation is used in some Intel 960 configurations. */
31537 + BFD_RELOC_64_PCREL,
31538 + BFD_RELOC_32_PCREL,
31539 + BFD_RELOC_24_PCREL,
31540 + BFD_RELOC_16_PCREL,
31541 + BFD_RELOC_12_PCREL,
31542 + BFD_RELOC_8_PCREL,
31544 +/* Section relative relocations. Some targets need this for DWARF2. */
31545 + BFD_RELOC_32_SECREL,
31548 + BFD_RELOC_32_GOT_PCREL,
31549 + BFD_RELOC_16_GOT_PCREL,
31550 + BFD_RELOC_8_GOT_PCREL,
31551 + BFD_RELOC_32_GOTOFF,
31552 + BFD_RELOC_16_GOTOFF,
31553 + BFD_RELOC_LO16_GOTOFF,
31554 + BFD_RELOC_HI16_GOTOFF,
31555 + BFD_RELOC_HI16_S_GOTOFF,
31556 + BFD_RELOC_8_GOTOFF,
31557 + BFD_RELOC_64_PLT_PCREL,
31558 + BFD_RELOC_32_PLT_PCREL,
31559 + BFD_RELOC_24_PLT_PCREL,
31560 + BFD_RELOC_16_PLT_PCREL,
31561 + BFD_RELOC_8_PLT_PCREL,
31562 + BFD_RELOC_64_PLTOFF,
31563 + BFD_RELOC_32_PLTOFF,
31564 + BFD_RELOC_16_PLTOFF,
31565 + BFD_RELOC_LO16_PLTOFF,
31566 + BFD_RELOC_HI16_PLTOFF,
31567 + BFD_RELOC_HI16_S_PLTOFF,
31568 + BFD_RELOC_8_PLTOFF,
31570 +/* Relocations used by 68K ELF. */
31571 + BFD_RELOC_68K_GLOB_DAT,
31572 + BFD_RELOC_68K_JMP_SLOT,
31573 + BFD_RELOC_68K_RELATIVE,
31575 +/* Linkage-table relative. */
31576 + BFD_RELOC_32_BASEREL,
31577 + BFD_RELOC_16_BASEREL,
31578 + BFD_RELOC_LO16_BASEREL,
31579 + BFD_RELOC_HI16_BASEREL,
31580 + BFD_RELOC_HI16_S_BASEREL,
31581 + BFD_RELOC_8_BASEREL,
31584 +/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */
31585 + BFD_RELOC_8_FFnn,
31587 +/* These PC-relative relocations are stored as word displacements --
31588 +i.e., byte displacements shifted right two bits. The 30-bit word
31589 +displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
31590 +SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
31591 +signed 16-bit displacement is used on the MIPS, and the 23-bit
31592 +displacement is used on the Alpha. */
31593 + BFD_RELOC_32_PCREL_S2,
31594 + BFD_RELOC_16_PCREL_S2,
31595 + BFD_RELOC_23_PCREL_S2,
31597 +/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
31598 +the target word. These are used on the SPARC. */
31602 +/* For systems that allocate a Global Pointer register, these are
31603 +displacements off that register. These relocation types are
31604 +handled specially, because the value the register will have is
31605 +decided relatively late. */
31606 + BFD_RELOC_GPREL16,
31607 + BFD_RELOC_GPREL32,
31609 +/* Reloc types used for i960/b.out. */
31610 + BFD_RELOC_I960_CALLJ,
31612 +/* SPARC ELF relocations. There is probably some overlap with other
31613 +relocation types already defined. */
31615 + BFD_RELOC_SPARC_WDISP22,
31616 + BFD_RELOC_SPARC22,
31617 + BFD_RELOC_SPARC13,
31618 + BFD_RELOC_SPARC_GOT10,
31619 + BFD_RELOC_SPARC_GOT13,
31620 + BFD_RELOC_SPARC_GOT22,
31621 + BFD_RELOC_SPARC_PC10,
31622 + BFD_RELOC_SPARC_PC22,
31623 + BFD_RELOC_SPARC_WPLT30,
31624 + BFD_RELOC_SPARC_COPY,
31625 + BFD_RELOC_SPARC_GLOB_DAT,
31626 + BFD_RELOC_SPARC_JMP_SLOT,
31627 + BFD_RELOC_SPARC_RELATIVE,
31628 + BFD_RELOC_SPARC_UA16,
31629 + BFD_RELOC_SPARC_UA32,
31630 + BFD_RELOC_SPARC_UA64,
31632 +/* I think these are specific to SPARC a.out (e.g., Sun 4). */
31633 + BFD_RELOC_SPARC_BASE13,
31634 + BFD_RELOC_SPARC_BASE22,
31636 +/* SPARC64 relocations */
31637 +#define BFD_RELOC_SPARC_64 BFD_RELOC_64
31638 + BFD_RELOC_SPARC_10,
31639 + BFD_RELOC_SPARC_11,
31640 + BFD_RELOC_SPARC_OLO10,
31641 + BFD_RELOC_SPARC_HH22,
31642 + BFD_RELOC_SPARC_HM10,
31643 + BFD_RELOC_SPARC_LM22,
31644 + BFD_RELOC_SPARC_PC_HH22,
31645 + BFD_RELOC_SPARC_PC_HM10,
31646 + BFD_RELOC_SPARC_PC_LM22,
31647 + BFD_RELOC_SPARC_WDISP16,
31648 + BFD_RELOC_SPARC_WDISP19,
31649 + BFD_RELOC_SPARC_7,
31650 + BFD_RELOC_SPARC_6,
31651 + BFD_RELOC_SPARC_5,
31652 +#define BFD_RELOC_SPARC_DISP64 BFD_RELOC_64_PCREL
31653 + BFD_RELOC_SPARC_PLT32,
31654 + BFD_RELOC_SPARC_PLT64,
31655 + BFD_RELOC_SPARC_HIX22,
31656 + BFD_RELOC_SPARC_LOX10,
31657 + BFD_RELOC_SPARC_H44,
31658 + BFD_RELOC_SPARC_M44,
31659 + BFD_RELOC_SPARC_L44,
31660 + BFD_RELOC_SPARC_REGISTER,
31662 +/* SPARC little endian relocation */
31663 + BFD_RELOC_SPARC_REV32,
31665 +/* SPARC TLS relocations */
31666 + BFD_RELOC_SPARC_TLS_GD_HI22,
31667 + BFD_RELOC_SPARC_TLS_GD_LO10,
31668 + BFD_RELOC_SPARC_TLS_GD_ADD,
31669 + BFD_RELOC_SPARC_TLS_GD_CALL,
31670 + BFD_RELOC_SPARC_TLS_LDM_HI22,
31671 + BFD_RELOC_SPARC_TLS_LDM_LO10,
31672 + BFD_RELOC_SPARC_TLS_LDM_ADD,
31673 + BFD_RELOC_SPARC_TLS_LDM_CALL,
31674 + BFD_RELOC_SPARC_TLS_LDO_HIX22,
31675 + BFD_RELOC_SPARC_TLS_LDO_LOX10,
31676 + BFD_RELOC_SPARC_TLS_LDO_ADD,
31677 + BFD_RELOC_SPARC_TLS_IE_HI22,
31678 + BFD_RELOC_SPARC_TLS_IE_LO10,
31679 + BFD_RELOC_SPARC_TLS_IE_LD,
31680 + BFD_RELOC_SPARC_TLS_IE_LDX,
31681 + BFD_RELOC_SPARC_TLS_IE_ADD,
31682 + BFD_RELOC_SPARC_TLS_LE_HIX22,
31683 + BFD_RELOC_SPARC_TLS_LE_LOX10,
31684 + BFD_RELOC_SPARC_TLS_DTPMOD32,
31685 + BFD_RELOC_SPARC_TLS_DTPMOD64,
31686 + BFD_RELOC_SPARC_TLS_DTPOFF32,
31687 + BFD_RELOC_SPARC_TLS_DTPOFF64,
31688 + BFD_RELOC_SPARC_TLS_TPOFF32,
31689 + BFD_RELOC_SPARC_TLS_TPOFF64,
31691 +/* Alpha ECOFF and ELF relocations. Some of these treat the symbol or
31692 +"addend" in some special way.
31693 +For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
31694 +writing; when reading, it will be the absolute section symbol. The
31695 +addend is the displacement in bytes of the "lda" instruction from
31696 +the "ldah" instruction (which is at the address of this reloc). */
31697 + BFD_RELOC_ALPHA_GPDISP_HI16,
31699 +/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
31700 +with GPDISP_HI16 relocs. The addend is ignored when writing the
31701 +relocations out, and is filled in with the file's GP value on
31702 +reading, for convenience. */
31703 + BFD_RELOC_ALPHA_GPDISP_LO16,
31705 +/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
31706 +relocation except that there is no accompanying GPDISP_LO16
31708 + BFD_RELOC_ALPHA_GPDISP,
31710 +/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
31711 +the assembler turns it into a LDQ instruction to load the address of
31712 +the symbol, and then fills in a register in the real instruction.
31714 +The LITERAL reloc, at the LDQ instruction, refers to the .lita
31715 +section symbol. The addend is ignored when writing, but is filled
31716 +in with the file's GP value on reading, for convenience, as with the
31717 +GPDISP_LO16 reloc.
31719 +The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
31720 +It should refer to the symbol to be referenced, as with 16_GOTOFF,
31721 +but it generates output not based on the position within the .got
31722 +section, but relative to the GP value chosen for the file during the
31725 +The LITUSE reloc, on the instruction using the loaded address, gives
31726 +information to the linker that it might be able to use to optimize
31727 +away some literal section references. The symbol is ignored (read
31728 +as the absolute section symbol), and the "addend" indicates the type
31729 +of instruction using the register:
31730 +1 - "memory" fmt insn
31731 +2 - byte-manipulation (byte offset reg)
31732 +3 - jsr (target of branch) */
31733 + BFD_RELOC_ALPHA_LITERAL,
31734 + BFD_RELOC_ALPHA_ELF_LITERAL,
31735 + BFD_RELOC_ALPHA_LITUSE,
31737 +/* The HINT relocation indicates a value that should be filled into the
31738 +"hint" field of a jmp/jsr/ret instruction, for possible branch-
31739 +prediction logic which may be provided on some processors. */
31740 + BFD_RELOC_ALPHA_HINT,
31742 +/* The LINKAGE relocation outputs a linkage pair in the object file,
31743 +which is filled by the linker. */
31744 + BFD_RELOC_ALPHA_LINKAGE,
31746 +/* The CODEADDR relocation outputs a STO_CA in the object file,
31747 +which is filled by the linker. */
31748 + BFD_RELOC_ALPHA_CODEADDR,
31750 +/* The GPREL_HI/LO relocations together form a 32-bit offset from the
31752 + BFD_RELOC_ALPHA_GPREL_HI16,
31753 + BFD_RELOC_ALPHA_GPREL_LO16,
31755 +/* Like BFD_RELOC_23_PCREL_S2, except that the source and target must
31756 +share a common GP, and the target address is adjusted for
31757 +STO_ALPHA_STD_GPLOAD. */
31758 + BFD_RELOC_ALPHA_BRSGP,
31760 +/* Alpha thread-local storage relocations. */
31761 + BFD_RELOC_ALPHA_TLSGD,
31762 + BFD_RELOC_ALPHA_TLSLDM,
31763 + BFD_RELOC_ALPHA_DTPMOD64,
31764 + BFD_RELOC_ALPHA_GOTDTPREL16,
31765 + BFD_RELOC_ALPHA_DTPREL64,
31766 + BFD_RELOC_ALPHA_DTPREL_HI16,
31767 + BFD_RELOC_ALPHA_DTPREL_LO16,
31768 + BFD_RELOC_ALPHA_DTPREL16,
31769 + BFD_RELOC_ALPHA_GOTTPREL16,
31770 + BFD_RELOC_ALPHA_TPREL64,
31771 + BFD_RELOC_ALPHA_TPREL_HI16,
31772 + BFD_RELOC_ALPHA_TPREL_LO16,
31773 + BFD_RELOC_ALPHA_TPREL16,
31775 +/* Bits 27..2 of the relocation address shifted right 2 bits;
31776 +simple reloc otherwise. */
31777 + BFD_RELOC_MIPS_JMP,
31779 +/* The MIPS16 jump instruction. */
31780 + BFD_RELOC_MIPS16_JMP,
31782 +/* MIPS16 GP relative reloc. */
31783 + BFD_RELOC_MIPS16_GPREL,
31785 +/* High 16 bits of 32-bit value; simple reloc. */
31788 +/* High 16 bits of 32-bit value but the low 16 bits will be sign
31789 +extended and added to form the final result. If the low 16
31790 +bits form a negative number, we need to add one to the high value
31791 +to compensate for the borrow when the low bits are added. */
31792 + BFD_RELOC_HI16_S,
31794 +/* Low 16 bits. */
31797 +/* High 16 bits of 32-bit pc-relative value */
31798 + BFD_RELOC_HI16_PCREL,
31800 +/* High 16 bits of 32-bit pc-relative value, adjusted */
31801 + BFD_RELOC_HI16_S_PCREL,
31803 +/* Low 16 bits of pc-relative value */
31804 + BFD_RELOC_LO16_PCREL,
31806 +/* MIPS16 high 16 bits of 32-bit value. */
31807 + BFD_RELOC_MIPS16_HI16,
31809 +/* MIPS16 high 16 bits of 32-bit value but the low 16 bits will be sign
31810 +extended and added to form the final result. If the low 16
31811 +bits form a negative number, we need to add one to the high value
31812 +to compensate for the borrow when the low bits are added. */
31813 + BFD_RELOC_MIPS16_HI16_S,
31815 +/* MIPS16 low 16 bits. */
31816 + BFD_RELOC_MIPS16_LO16,
31818 +/* Relocation against a MIPS literal section. */
31819 + BFD_RELOC_MIPS_LITERAL,
31821 +/* MIPS ELF relocations. */
31822 + BFD_RELOC_MIPS_GOT16,
31823 + BFD_RELOC_MIPS_CALL16,
31824 + BFD_RELOC_MIPS_GOT_HI16,
31825 + BFD_RELOC_MIPS_GOT_LO16,
31826 + BFD_RELOC_MIPS_CALL_HI16,
31827 + BFD_RELOC_MIPS_CALL_LO16,
31828 + BFD_RELOC_MIPS_SUB,
31829 + BFD_RELOC_MIPS_GOT_PAGE,
31830 + BFD_RELOC_MIPS_GOT_OFST,
31831 + BFD_RELOC_MIPS_GOT_DISP,
31832 + BFD_RELOC_MIPS_SHIFT5,
31833 + BFD_RELOC_MIPS_SHIFT6,
31834 + BFD_RELOC_MIPS_INSERT_A,
31835 + BFD_RELOC_MIPS_INSERT_B,
31836 + BFD_RELOC_MIPS_DELETE,
31837 + BFD_RELOC_MIPS_HIGHEST,
31838 + BFD_RELOC_MIPS_HIGHER,
31839 + BFD_RELOC_MIPS_SCN_DISP,
31840 + BFD_RELOC_MIPS_REL16,
31841 + BFD_RELOC_MIPS_RELGOT,
31842 + BFD_RELOC_MIPS_JALR,
31843 + BFD_RELOC_MIPS_TLS_DTPMOD32,
31844 + BFD_RELOC_MIPS_TLS_DTPREL32,
31845 + BFD_RELOC_MIPS_TLS_DTPMOD64,
31846 + BFD_RELOC_MIPS_TLS_DTPREL64,
31847 + BFD_RELOC_MIPS_TLS_GD,
31848 + BFD_RELOC_MIPS_TLS_LDM,
31849 + BFD_RELOC_MIPS_TLS_DTPREL_HI16,
31850 + BFD_RELOC_MIPS_TLS_DTPREL_LO16,
31851 + BFD_RELOC_MIPS_TLS_GOTTPREL,
31852 + BFD_RELOC_MIPS_TLS_TPREL32,
31853 + BFD_RELOC_MIPS_TLS_TPREL64,
31854 + BFD_RELOC_MIPS_TLS_TPREL_HI16,
31855 + BFD_RELOC_MIPS_TLS_TPREL_LO16,
31858 +/* Fujitsu Frv Relocations. */
31859 + BFD_RELOC_FRV_LABEL16,
31860 + BFD_RELOC_FRV_LABEL24,
31861 + BFD_RELOC_FRV_LO16,
31862 + BFD_RELOC_FRV_HI16,
31863 + BFD_RELOC_FRV_GPREL12,
31864 + BFD_RELOC_FRV_GPRELU12,
31865 + BFD_RELOC_FRV_GPREL32,
31866 + BFD_RELOC_FRV_GPRELHI,
31867 + BFD_RELOC_FRV_GPRELLO,
31868 + BFD_RELOC_FRV_GOT12,
31869 + BFD_RELOC_FRV_GOTHI,
31870 + BFD_RELOC_FRV_GOTLO,
31871 + BFD_RELOC_FRV_FUNCDESC,
31872 + BFD_RELOC_FRV_FUNCDESC_GOT12,
31873 + BFD_RELOC_FRV_FUNCDESC_GOTHI,
31874 + BFD_RELOC_FRV_FUNCDESC_GOTLO,
31875 + BFD_RELOC_FRV_FUNCDESC_VALUE,
31876 + BFD_RELOC_FRV_FUNCDESC_GOTOFF12,
31877 + BFD_RELOC_FRV_FUNCDESC_GOTOFFHI,
31878 + BFD_RELOC_FRV_FUNCDESC_GOTOFFLO,
31879 + BFD_RELOC_FRV_GOTOFF12,
31880 + BFD_RELOC_FRV_GOTOFFHI,
31881 + BFD_RELOC_FRV_GOTOFFLO,
31882 + BFD_RELOC_FRV_GETTLSOFF,
31883 + BFD_RELOC_FRV_TLSDESC_VALUE,
31884 + BFD_RELOC_FRV_GOTTLSDESC12,
31885 + BFD_RELOC_FRV_GOTTLSDESCHI,
31886 + BFD_RELOC_FRV_GOTTLSDESCLO,
31887 + BFD_RELOC_FRV_TLSMOFF12,
31888 + BFD_RELOC_FRV_TLSMOFFHI,
31889 + BFD_RELOC_FRV_TLSMOFFLO,
31890 + BFD_RELOC_FRV_GOTTLSOFF12,
31891 + BFD_RELOC_FRV_GOTTLSOFFHI,
31892 + BFD_RELOC_FRV_GOTTLSOFFLO,
31893 + BFD_RELOC_FRV_TLSOFF,
31894 + BFD_RELOC_FRV_TLSDESC_RELAX,
31895 + BFD_RELOC_FRV_GETTLSOFF_RELAX,
31896 + BFD_RELOC_FRV_TLSOFF_RELAX,
31897 + BFD_RELOC_FRV_TLSMOFF,
31900 +/* This is a 24bit GOT-relative reloc for the mn10300. */
31901 + BFD_RELOC_MN10300_GOTOFF24,
31903 +/* This is a 32bit GOT-relative reloc for the mn10300, offset by two bytes
31904 +in the instruction. */
31905 + BFD_RELOC_MN10300_GOT32,
31907 +/* This is a 24bit GOT-relative reloc for the mn10300, offset by two bytes
31908 +in the instruction. */
31909 + BFD_RELOC_MN10300_GOT24,
31911 +/* This is a 16bit GOT-relative reloc for the mn10300, offset by two bytes
31912 +in the instruction. */
31913 + BFD_RELOC_MN10300_GOT16,
31915 +/* Copy symbol at runtime. */
31916 + BFD_RELOC_MN10300_COPY,
31918 +/* Create GOT entry. */
31919 + BFD_RELOC_MN10300_GLOB_DAT,
31921 +/* Create PLT entry. */
31922 + BFD_RELOC_MN10300_JMP_SLOT,
31924 +/* Adjust by program base. */
31925 + BFD_RELOC_MN10300_RELATIVE,
31928 +/* i386/elf relocations */
31929 + BFD_RELOC_386_GOT32,
31930 + BFD_RELOC_386_PLT32,
31931 + BFD_RELOC_386_COPY,
31932 + BFD_RELOC_386_GLOB_DAT,
31933 + BFD_RELOC_386_JUMP_SLOT,
31934 + BFD_RELOC_386_RELATIVE,
31935 + BFD_RELOC_386_GOTOFF,
31936 + BFD_RELOC_386_GOTPC,
31937 + BFD_RELOC_386_TLS_TPOFF,
31938 + BFD_RELOC_386_TLS_IE,
31939 + BFD_RELOC_386_TLS_GOTIE,
31940 + BFD_RELOC_386_TLS_LE,
31941 + BFD_RELOC_386_TLS_GD,
31942 + BFD_RELOC_386_TLS_LDM,
31943 + BFD_RELOC_386_TLS_LDO_32,
31944 + BFD_RELOC_386_TLS_IE_32,
31945 + BFD_RELOC_386_TLS_LE_32,
31946 + BFD_RELOC_386_TLS_DTPMOD32,
31947 + BFD_RELOC_386_TLS_DTPOFF32,
31948 + BFD_RELOC_386_TLS_TPOFF32,
31950 +/* x86-64/elf relocations */
31951 + BFD_RELOC_X86_64_GOT32,
31952 + BFD_RELOC_X86_64_PLT32,
31953 + BFD_RELOC_X86_64_COPY,
31954 + BFD_RELOC_X86_64_GLOB_DAT,
31955 + BFD_RELOC_X86_64_JUMP_SLOT,
31956 + BFD_RELOC_X86_64_RELATIVE,
31957 + BFD_RELOC_X86_64_GOTPCREL,
31958 + BFD_RELOC_X86_64_32S,
31959 + BFD_RELOC_X86_64_DTPMOD64,
31960 + BFD_RELOC_X86_64_DTPOFF64,
31961 + BFD_RELOC_X86_64_TPOFF64,
31962 + BFD_RELOC_X86_64_TLSGD,
31963 + BFD_RELOC_X86_64_TLSLD,
31964 + BFD_RELOC_X86_64_DTPOFF32,
31965 + BFD_RELOC_X86_64_GOTTPOFF,
31966 + BFD_RELOC_X86_64_TPOFF32,
31967 + BFD_RELOC_X86_64_GOTOFF64,
31968 + BFD_RELOC_X86_64_GOTPC32,
31970 +/* ns32k relocations */
31971 + BFD_RELOC_NS32K_IMM_8,
31972 + BFD_RELOC_NS32K_IMM_16,
31973 + BFD_RELOC_NS32K_IMM_32,
31974 + BFD_RELOC_NS32K_IMM_8_PCREL,
31975 + BFD_RELOC_NS32K_IMM_16_PCREL,
31976 + BFD_RELOC_NS32K_IMM_32_PCREL,
31977 + BFD_RELOC_NS32K_DISP_8,
31978 + BFD_RELOC_NS32K_DISP_16,
31979 + BFD_RELOC_NS32K_DISP_32,
31980 + BFD_RELOC_NS32K_DISP_8_PCREL,
31981 + BFD_RELOC_NS32K_DISP_16_PCREL,
31982 + BFD_RELOC_NS32K_DISP_32_PCREL,
31984 +/* PDP11 relocations */
31985 + BFD_RELOC_PDP11_DISP_8_PCREL,
31986 + BFD_RELOC_PDP11_DISP_6_PCREL,
31988 +/* Picojava relocs. Not all of these appear in object files. */
31989 + BFD_RELOC_PJ_CODE_HI16,
31990 + BFD_RELOC_PJ_CODE_LO16,
31991 + BFD_RELOC_PJ_CODE_DIR16,
31992 + BFD_RELOC_PJ_CODE_DIR32,
31993 + BFD_RELOC_PJ_CODE_REL16,
31994 + BFD_RELOC_PJ_CODE_REL32,
31996 +/* Power(rs6000) and PowerPC relocations. */
31997 + BFD_RELOC_PPC_B26,
31998 + BFD_RELOC_PPC_BA26,
31999 + BFD_RELOC_PPC_TOC16,
32000 + BFD_RELOC_PPC_B16,
32001 + BFD_RELOC_PPC_B16_BRTAKEN,
32002 + BFD_RELOC_PPC_B16_BRNTAKEN,
32003 + BFD_RELOC_PPC_BA16,
32004 + BFD_RELOC_PPC_BA16_BRTAKEN,
32005 + BFD_RELOC_PPC_BA16_BRNTAKEN,
32006 + BFD_RELOC_PPC_COPY,
32007 + BFD_RELOC_PPC_GLOB_DAT,
32008 + BFD_RELOC_PPC_JMP_SLOT,
32009 + BFD_RELOC_PPC_RELATIVE,
32010 + BFD_RELOC_PPC_LOCAL24PC,
32011 + BFD_RELOC_PPC_EMB_NADDR32,
32012 + BFD_RELOC_PPC_EMB_NADDR16,
32013 + BFD_RELOC_PPC_EMB_NADDR16_LO,
32014 + BFD_RELOC_PPC_EMB_NADDR16_HI,
32015 + BFD_RELOC_PPC_EMB_NADDR16_HA,
32016 + BFD_RELOC_PPC_EMB_SDAI16,
32017 + BFD_RELOC_PPC_EMB_SDA2I16,
32018 + BFD_RELOC_PPC_EMB_SDA2REL,
32019 + BFD_RELOC_PPC_EMB_SDA21,
32020 + BFD_RELOC_PPC_EMB_MRKREF,
32021 + BFD_RELOC_PPC_EMB_RELSEC16,
32022 + BFD_RELOC_PPC_EMB_RELST_LO,
32023 + BFD_RELOC_PPC_EMB_RELST_HI,
32024 + BFD_RELOC_PPC_EMB_RELST_HA,
32025 + BFD_RELOC_PPC_EMB_BIT_FLD,
32026 + BFD_RELOC_PPC_EMB_RELSDA,
32027 + BFD_RELOC_PPC64_HIGHER,
32028 + BFD_RELOC_PPC64_HIGHER_S,
32029 + BFD_RELOC_PPC64_HIGHEST,
32030 + BFD_RELOC_PPC64_HIGHEST_S,
32031 + BFD_RELOC_PPC64_TOC16_LO,
32032 + BFD_RELOC_PPC64_TOC16_HI,
32033 + BFD_RELOC_PPC64_TOC16_HA,
32034 + BFD_RELOC_PPC64_TOC,
32035 + BFD_RELOC_PPC64_PLTGOT16,
32036 + BFD_RELOC_PPC64_PLTGOT16_LO,
32037 + BFD_RELOC_PPC64_PLTGOT16_HI,
32038 + BFD_RELOC_PPC64_PLTGOT16_HA,
32039 + BFD_RELOC_PPC64_ADDR16_DS,
32040 + BFD_RELOC_PPC64_ADDR16_LO_DS,
32041 + BFD_RELOC_PPC64_GOT16_DS,
32042 + BFD_RELOC_PPC64_GOT16_LO_DS,
32043 + BFD_RELOC_PPC64_PLT16_LO_DS,
32044 + BFD_RELOC_PPC64_SECTOFF_DS,
32045 + BFD_RELOC_PPC64_SECTOFF_LO_DS,
32046 + BFD_RELOC_PPC64_TOC16_DS,
32047 + BFD_RELOC_PPC64_TOC16_LO_DS,
32048 + BFD_RELOC_PPC64_PLTGOT16_DS,
32049 + BFD_RELOC_PPC64_PLTGOT16_LO_DS,
32051 +/* PowerPC and PowerPC64 thread-local storage relocations. */
32052 + BFD_RELOC_PPC_TLS,
32053 + BFD_RELOC_PPC_DTPMOD,
32054 + BFD_RELOC_PPC_TPREL16,
32055 + BFD_RELOC_PPC_TPREL16_LO,
32056 + BFD_RELOC_PPC_TPREL16_HI,
32057 + BFD_RELOC_PPC_TPREL16_HA,
32058 + BFD_RELOC_PPC_TPREL,
32059 + BFD_RELOC_PPC_DTPREL16,
32060 + BFD_RELOC_PPC_DTPREL16_LO,
32061 + BFD_RELOC_PPC_DTPREL16_HI,
32062 + BFD_RELOC_PPC_DTPREL16_HA,
32063 + BFD_RELOC_PPC_DTPREL,
32064 + BFD_RELOC_PPC_GOT_TLSGD16,
32065 + BFD_RELOC_PPC_GOT_TLSGD16_LO,
32066 + BFD_RELOC_PPC_GOT_TLSGD16_HI,
32067 + BFD_RELOC_PPC_GOT_TLSGD16_HA,
32068 + BFD_RELOC_PPC_GOT_TLSLD16,
32069 + BFD_RELOC_PPC_GOT_TLSLD16_LO,
32070 + BFD_RELOC_PPC_GOT_TLSLD16_HI,
32071 + BFD_RELOC_PPC_GOT_TLSLD16_HA,
32072 + BFD_RELOC_PPC_GOT_TPREL16,
32073 + BFD_RELOC_PPC_GOT_TPREL16_LO,
32074 + BFD_RELOC_PPC_GOT_TPREL16_HI,
32075 + BFD_RELOC_PPC_GOT_TPREL16_HA,
32076 + BFD_RELOC_PPC_GOT_DTPREL16,
32077 + BFD_RELOC_PPC_GOT_DTPREL16_LO,
32078 + BFD_RELOC_PPC_GOT_DTPREL16_HI,
32079 + BFD_RELOC_PPC_GOT_DTPREL16_HA,
32080 + BFD_RELOC_PPC64_TPREL16_DS,
32081 + BFD_RELOC_PPC64_TPREL16_LO_DS,
32082 + BFD_RELOC_PPC64_TPREL16_HIGHER,
32083 + BFD_RELOC_PPC64_TPREL16_HIGHERA,
32084 + BFD_RELOC_PPC64_TPREL16_HIGHEST,
32085 + BFD_RELOC_PPC64_TPREL16_HIGHESTA,
32086 + BFD_RELOC_PPC64_DTPREL16_DS,
32087 + BFD_RELOC_PPC64_DTPREL16_LO_DS,
32088 + BFD_RELOC_PPC64_DTPREL16_HIGHER,
32089 + BFD_RELOC_PPC64_DTPREL16_HIGHERA,
32090 + BFD_RELOC_PPC64_DTPREL16_HIGHEST,
32091 + BFD_RELOC_PPC64_DTPREL16_HIGHESTA,
32093 +/* IBM 370/390 relocations */
32094 + BFD_RELOC_I370_D12,
32096 +/* The type of reloc used to build a constructor table - at the moment
32097 +probably a 32 bit wide absolute relocation, but the target can choose.
32098 +It generally does map to one of the other relocation types. */
32101 +/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
32102 +not stored in the instruction. */
32103 + BFD_RELOC_ARM_PCREL_BRANCH,
32105 +/* ARM 26 bit pc-relative branch. The lowest bit must be zero and is
32106 +not stored in the instruction. The 2nd lowest bit comes from a 1 bit
32107 +field in the instruction. */
32108 + BFD_RELOC_ARM_PCREL_BLX,
32110 +/* Thumb 22 bit pc-relative branch. The lowest bit must be zero and is
32111 +not stored in the instruction. The 2nd lowest bit comes from a 1 bit
32112 +field in the instruction. */
32113 + BFD_RELOC_THUMB_PCREL_BLX,
32115 +/* Thumb 7-, 9-, 12-, 20-, 23-, and 25-bit pc-relative branches.
32116 +The lowest bit must be zero and is not stored in the instruction.
32117 +Note that the corresponding ELF R_ARM_THM_JUMPnn constant has an
32118 +"nn" one smaller in all cases. Note further that BRANCH23
32119 +corresponds to R_ARM_THM_CALL. */
32120 + BFD_RELOC_THUMB_PCREL_BRANCH7,
32121 + BFD_RELOC_THUMB_PCREL_BRANCH9,
32122 + BFD_RELOC_THUMB_PCREL_BRANCH12,
32123 + BFD_RELOC_THUMB_PCREL_BRANCH20,
32124 + BFD_RELOC_THUMB_PCREL_BRANCH23,
32125 + BFD_RELOC_THUMB_PCREL_BRANCH25,
32127 +/* 12-bit immediate offset, used in ARM-format ldr and str instructions. */
32128 + BFD_RELOC_ARM_OFFSET_IMM,
32130 +/* 5-bit immediate offset, used in Thumb-format ldr and str instructions. */
32131 + BFD_RELOC_ARM_THUMB_OFFSET,
32133 +/* Pc-relative or absolute relocation depending on target. Used for
32134 +entries in .init_array sections. */
32135 + BFD_RELOC_ARM_TARGET1,
32137 +/* Read-only segment base relative address. */
32138 + BFD_RELOC_ARM_ROSEGREL32,
32140 +/* Data segment base relative address. */
32141 + BFD_RELOC_ARM_SBREL32,
32143 +/* This reloc is used for references to RTTI data from exception handling
32144 +tables. The actual definition depends on the target. It may be a
32145 +pc-relative or some form of GOT-indirect relocation. */
32146 + BFD_RELOC_ARM_TARGET2,
32148 +/* 31-bit PC relative address. */
32149 + BFD_RELOC_ARM_PREL31,
32151 +/* Relocations for setting up GOTs and PLTs for shared libraries. */
32152 + BFD_RELOC_ARM_JUMP_SLOT,
32153 + BFD_RELOC_ARM_GLOB_DAT,
32154 + BFD_RELOC_ARM_GOT32,
32155 + BFD_RELOC_ARM_PLT32,
32156 + BFD_RELOC_ARM_RELATIVE,
32157 + BFD_RELOC_ARM_GOTOFF,
32158 + BFD_RELOC_ARM_GOTPC,
32160 +/* ARM thread-local storage relocations. */
32161 + BFD_RELOC_ARM_TLS_GD32,
32162 + BFD_RELOC_ARM_TLS_LDO32,
32163 + BFD_RELOC_ARM_TLS_LDM32,
32164 + BFD_RELOC_ARM_TLS_DTPOFF32,
32165 + BFD_RELOC_ARM_TLS_DTPMOD32,
32166 + BFD_RELOC_ARM_TLS_TPOFF32,
32167 + BFD_RELOC_ARM_TLS_IE32,
32168 + BFD_RELOC_ARM_TLS_LE32,
32170 +/* These relocs are only used within the ARM assembler. They are not
32171 +(at present) written to any object files. */
32172 + BFD_RELOC_ARM_IMMEDIATE,
32173 + BFD_RELOC_ARM_ADRL_IMMEDIATE,
32174 + BFD_RELOC_ARM_T32_IMMEDIATE,
32175 + BFD_RELOC_ARM_SHIFT_IMM,
32176 + BFD_RELOC_ARM_SMI,
32177 + BFD_RELOC_ARM_SWI,
32178 + BFD_RELOC_ARM_MULTI,
32179 + BFD_RELOC_ARM_CP_OFF_IMM,
32180 + BFD_RELOC_ARM_CP_OFF_IMM_S2,
32181 + BFD_RELOC_ARM_ADR_IMM,
32182 + BFD_RELOC_ARM_LDR_IMM,
32183 + BFD_RELOC_ARM_LITERAL,
32184 + BFD_RELOC_ARM_IN_POOL,
32185 + BFD_RELOC_ARM_OFFSET_IMM8,
32186 + BFD_RELOC_ARM_T32_OFFSET_U8,
32187 + BFD_RELOC_ARM_T32_OFFSET_IMM,
32188 + BFD_RELOC_ARM_HWLITERAL,
32189 + BFD_RELOC_ARM_THUMB_ADD,
32190 + BFD_RELOC_ARM_THUMB_IMM,
32191 + BFD_RELOC_ARM_THUMB_SHIFT,
32193 +/* Renesas / SuperH SH relocs. Not all of these appear in object files. */
32194 + BFD_RELOC_SH_PCDISP8BY2,
32195 + BFD_RELOC_SH_PCDISP12BY2,
32196 + BFD_RELOC_SH_IMM3,
32197 + BFD_RELOC_SH_IMM3U,
32198 + BFD_RELOC_SH_DISP12,
32199 + BFD_RELOC_SH_DISP12BY2,
32200 + BFD_RELOC_SH_DISP12BY4,
32201 + BFD_RELOC_SH_DISP12BY8,
32202 + BFD_RELOC_SH_DISP20,
32203 + BFD_RELOC_SH_DISP20BY8,
32204 + BFD_RELOC_SH_IMM4,
32205 + BFD_RELOC_SH_IMM4BY2,
32206 + BFD_RELOC_SH_IMM4BY4,
32207 + BFD_RELOC_SH_IMM8,
32208 + BFD_RELOC_SH_IMM8BY2,
32209 + BFD_RELOC_SH_IMM8BY4,
32210 + BFD_RELOC_SH_PCRELIMM8BY2,
32211 + BFD_RELOC_SH_PCRELIMM8BY4,
32212 + BFD_RELOC_SH_SWITCH16,
32213 + BFD_RELOC_SH_SWITCH32,
32214 + BFD_RELOC_SH_USES,
32215 + BFD_RELOC_SH_COUNT,
32216 + BFD_RELOC_SH_ALIGN,
32217 + BFD_RELOC_SH_CODE,
32218 + BFD_RELOC_SH_DATA,
32219 + BFD_RELOC_SH_LABEL,
32220 + BFD_RELOC_SH_LOOP_START,
32221 + BFD_RELOC_SH_LOOP_END,
32222 + BFD_RELOC_SH_COPY,
32223 + BFD_RELOC_SH_GLOB_DAT,
32224 + BFD_RELOC_SH_JMP_SLOT,
32225 + BFD_RELOC_SH_RELATIVE,
32226 + BFD_RELOC_SH_GOTPC,
32227 + BFD_RELOC_SH_GOT_LOW16,
32228 + BFD_RELOC_SH_GOT_MEDLOW16,
32229 + BFD_RELOC_SH_GOT_MEDHI16,
32230 + BFD_RELOC_SH_GOT_HI16,
32231 + BFD_RELOC_SH_GOTPLT_LOW16,
32232 + BFD_RELOC_SH_GOTPLT_MEDLOW16,
32233 + BFD_RELOC_SH_GOTPLT_MEDHI16,
32234 + BFD_RELOC_SH_GOTPLT_HI16,
32235 + BFD_RELOC_SH_PLT_LOW16,
32236 + BFD_RELOC_SH_PLT_MEDLOW16,
32237 + BFD_RELOC_SH_PLT_MEDHI16,
32238 + BFD_RELOC_SH_PLT_HI16,
32239 + BFD_RELOC_SH_GOTOFF_LOW16,
32240 + BFD_RELOC_SH_GOTOFF_MEDLOW16,
32241 + BFD_RELOC_SH_GOTOFF_MEDHI16,
32242 + BFD_RELOC_SH_GOTOFF_HI16,
32243 + BFD_RELOC_SH_GOTPC_LOW16,
32244 + BFD_RELOC_SH_GOTPC_MEDLOW16,
32245 + BFD_RELOC_SH_GOTPC_MEDHI16,
32246 + BFD_RELOC_SH_GOTPC_HI16,
32247 + BFD_RELOC_SH_COPY64,
32248 + BFD_RELOC_SH_GLOB_DAT64,
32249 + BFD_RELOC_SH_JMP_SLOT64,
32250 + BFD_RELOC_SH_RELATIVE64,
32251 + BFD_RELOC_SH_GOT10BY4,
32252 + BFD_RELOC_SH_GOT10BY8,
32253 + BFD_RELOC_SH_GOTPLT10BY4,
32254 + BFD_RELOC_SH_GOTPLT10BY8,
32255 + BFD_RELOC_SH_GOTPLT32,
32256 + BFD_RELOC_SH_SHMEDIA_CODE,
32257 + BFD_RELOC_SH_IMMU5,
32258 + BFD_RELOC_SH_IMMS6,
32259 + BFD_RELOC_SH_IMMS6BY32,
32260 + BFD_RELOC_SH_IMMU6,
32261 + BFD_RELOC_SH_IMMS10,
32262 + BFD_RELOC_SH_IMMS10BY2,
32263 + BFD_RELOC_SH_IMMS10BY4,
32264 + BFD_RELOC_SH_IMMS10BY8,
32265 + BFD_RELOC_SH_IMMS16,
32266 + BFD_RELOC_SH_IMMU16,
32267 + BFD_RELOC_SH_IMM_LOW16,
32268 + BFD_RELOC_SH_IMM_LOW16_PCREL,
32269 + BFD_RELOC_SH_IMM_MEDLOW16,
32270 + BFD_RELOC_SH_IMM_MEDLOW16_PCREL,
32271 + BFD_RELOC_SH_IMM_MEDHI16,
32272 + BFD_RELOC_SH_IMM_MEDHI16_PCREL,
32273 + BFD_RELOC_SH_IMM_HI16,
32274 + BFD_RELOC_SH_IMM_HI16_PCREL,
32275 + BFD_RELOC_SH_PT_16,
32276 + BFD_RELOC_SH_TLS_GD_32,
32277 + BFD_RELOC_SH_TLS_LD_32,
32278 + BFD_RELOC_SH_TLS_LDO_32,
32279 + BFD_RELOC_SH_TLS_IE_32,
32280 + BFD_RELOC_SH_TLS_LE_32,
32281 + BFD_RELOC_SH_TLS_DTPMOD32,
32282 + BFD_RELOC_SH_TLS_DTPOFF32,
32283 + BFD_RELOC_SH_TLS_TPOFF32,
32285 +/* ARC Cores relocs.
32286 +ARC 22 bit pc-relative branch. The lowest two bits must be zero and are
32287 +not stored in the instruction. The high 20 bits are installed in bits 26
32288 +through 7 of the instruction. */
32289 + BFD_RELOC_ARC_B22_PCREL,
32291 +/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not
32292 +stored in the instruction. The high 24 bits are installed in bits 23
32294 + BFD_RELOC_ARC_B26,
32296 +/* Mitsubishi D10V relocs.
32297 +This is a 10-bit reloc with the right 2 bits
32298 +assumed to be 0. */
32299 + BFD_RELOC_D10V_10_PCREL_R,
32301 +/* Mitsubishi D10V relocs.
32302 +This is a 10-bit reloc with the right 2 bits
32303 +assumed to be 0. This is the same as the previous reloc
32304 +except it is in the left container, i.e.,
32305 +shifted left 15 bits. */
32306 + BFD_RELOC_D10V_10_PCREL_L,
32308 +/* This is an 18-bit reloc with the right 2 bits
32309 +assumed to be 0. */
32310 + BFD_RELOC_D10V_18,
32312 +/* This is an 18-bit reloc with the right 2 bits
32313 +assumed to be 0. */
32314 + BFD_RELOC_D10V_18_PCREL,
32316 +/* Mitsubishi D30V relocs.
32317 +This is a 6-bit absolute reloc. */
32318 + BFD_RELOC_D30V_6,
32320 +/* This is a 6-bit pc-relative reloc with
32321 +the right 3 bits assumed to be 0. */
32322 + BFD_RELOC_D30V_9_PCREL,
32324 +/* This is a 6-bit pc-relative reloc with
32325 +the right 3 bits assumed to be 0. Same
32326 +as the previous reloc but on the right side
32327 +of the container. */
32328 + BFD_RELOC_D30V_9_PCREL_R,
32330 +/* This is a 12-bit absolute reloc with the
32331 +right 3 bitsassumed to be 0. */
32332 + BFD_RELOC_D30V_15,
32334 +/* This is a 12-bit pc-relative reloc with
32335 +the right 3 bits assumed to be 0. */
32336 + BFD_RELOC_D30V_15_PCREL,
32338 +/* This is a 12-bit pc-relative reloc with
32339 +the right 3 bits assumed to be 0. Same
32340 +as the previous reloc but on the right side
32341 +of the container. */
32342 + BFD_RELOC_D30V_15_PCREL_R,
32344 +/* This is an 18-bit absolute reloc with
32345 +the right 3 bits assumed to be 0. */
32346 + BFD_RELOC_D30V_21,
32348 +/* This is an 18-bit pc-relative reloc with
32349 +the right 3 bits assumed to be 0. */
32350 + BFD_RELOC_D30V_21_PCREL,
32352 +/* This is an 18-bit pc-relative reloc with
32353 +the right 3 bits assumed to be 0. Same
32354 +as the previous reloc but on the right side
32355 +of the container. */
32356 + BFD_RELOC_D30V_21_PCREL_R,
32358 +/* This is a 32-bit absolute reloc. */
32359 + BFD_RELOC_D30V_32,
32361 +/* This is a 32-bit pc-relative reloc. */
32362 + BFD_RELOC_D30V_32_PCREL,
32365 + BFD_RELOC_DLX_HI16_S,
32368 + BFD_RELOC_DLX_LO16,
32371 + BFD_RELOC_DLX_JMP26,
32373 +/* Renesas M16C/M32C Relocations. */
32374 + BFD_RELOC_M16C_8_PCREL8,
32375 + BFD_RELOC_M16C_16_PCREL8,
32376 + BFD_RELOC_M16C_8_PCREL16,
32377 + BFD_RELOC_M16C_8_ELABEL24,
32378 + BFD_RELOC_M16C_8_ABS16,
32379 + BFD_RELOC_M16C_16_ABS16,
32380 + BFD_RELOC_M16C_16_ABS24,
32381 + BFD_RELOC_M16C_16_ABS32,
32382 + BFD_RELOC_M16C_24_ABS16,
32383 + BFD_RELOC_M16C_24_ABS24,
32384 + BFD_RELOC_M16C_24_ABS32,
32385 + BFD_RELOC_M16C_32_ABS16,
32386 + BFD_RELOC_M16C_32_ABS24,
32387 + BFD_RELOC_M16C_32_ABS32,
32388 + BFD_RELOC_M16C_40_ABS16,
32389 + BFD_RELOC_M16C_40_ABS24,
32390 + BFD_RELOC_M16C_40_ABS32,
32392 +/* Renesas M32R (formerly Mitsubishi M32R) relocs.
32393 +This is a 24 bit absolute address. */
32394 + BFD_RELOC_M32R_24,
32396 +/* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. */
32397 + BFD_RELOC_M32R_10_PCREL,
32399 +/* This is an 18-bit reloc with the right 2 bits assumed to be 0. */
32400 + BFD_RELOC_M32R_18_PCREL,
32402 +/* This is a 26-bit reloc with the right 2 bits assumed to be 0. */
32403 + BFD_RELOC_M32R_26_PCREL,
32405 +/* This is a 16-bit reloc containing the high 16 bits of an address
32406 +used when the lower 16 bits are treated as unsigned. */
32407 + BFD_RELOC_M32R_HI16_ULO,
32409 +/* This is a 16-bit reloc containing the high 16 bits of an address
32410 +used when the lower 16 bits are treated as signed. */
32411 + BFD_RELOC_M32R_HI16_SLO,
32413 +/* This is a 16-bit reloc containing the lower 16 bits of an address. */
32414 + BFD_RELOC_M32R_LO16,
32416 +/* This is a 16-bit reloc containing the small data area offset for use in
32417 +add3, load, and store instructions. */
32418 + BFD_RELOC_M32R_SDA16,
32421 + BFD_RELOC_M32R_GOT24,
32422 + BFD_RELOC_M32R_26_PLTREL,
32423 + BFD_RELOC_M32R_COPY,
32424 + BFD_RELOC_M32R_GLOB_DAT,
32425 + BFD_RELOC_M32R_JMP_SLOT,
32426 + BFD_RELOC_M32R_RELATIVE,
32427 + BFD_RELOC_M32R_GOTOFF,
32428 + BFD_RELOC_M32R_GOTOFF_HI_ULO,
32429 + BFD_RELOC_M32R_GOTOFF_HI_SLO,
32430 + BFD_RELOC_M32R_GOTOFF_LO,
32431 + BFD_RELOC_M32R_GOTPC24,
32432 + BFD_RELOC_M32R_GOT16_HI_ULO,
32433 + BFD_RELOC_M32R_GOT16_HI_SLO,
32434 + BFD_RELOC_M32R_GOT16_LO,
32435 + BFD_RELOC_M32R_GOTPC_HI_ULO,
32436 + BFD_RELOC_M32R_GOTPC_HI_SLO,
32437 + BFD_RELOC_M32R_GOTPC_LO,
32439 +/* This is a 9-bit reloc */
32440 + BFD_RELOC_V850_9_PCREL,
32442 +/* This is a 22-bit reloc */
32443 + BFD_RELOC_V850_22_PCREL,
32445 +/* This is a 16 bit offset from the short data area pointer. */
32446 + BFD_RELOC_V850_SDA_16_16_OFFSET,
32448 +/* This is a 16 bit offset (of which only 15 bits are used) from the
32449 +short data area pointer. */
32450 + BFD_RELOC_V850_SDA_15_16_OFFSET,
32452 +/* This is a 16 bit offset from the zero data area pointer. */
32453 + BFD_RELOC_V850_ZDA_16_16_OFFSET,
32455 +/* This is a 16 bit offset (of which only 15 bits are used) from the
32456 +zero data area pointer. */
32457 + BFD_RELOC_V850_ZDA_15_16_OFFSET,
32459 +/* This is an 8 bit offset (of which only 6 bits are used) from the
32460 +tiny data area pointer. */
32461 + BFD_RELOC_V850_TDA_6_8_OFFSET,
32463 +/* This is an 8bit offset (of which only 7 bits are used) from the tiny
32464 +data area pointer. */
32465 + BFD_RELOC_V850_TDA_7_8_OFFSET,
32467 +/* This is a 7 bit offset from the tiny data area pointer. */
32468 + BFD_RELOC_V850_TDA_7_7_OFFSET,
32470 +/* This is a 16 bit offset from the tiny data area pointer. */
32471 + BFD_RELOC_V850_TDA_16_16_OFFSET,
32473 +/* This is a 5 bit offset (of which only 4 bits are used) from the tiny
32474 +data area pointer. */
32475 + BFD_RELOC_V850_TDA_4_5_OFFSET,
32477 +/* This is a 4 bit offset from the tiny data area pointer. */
32478 + BFD_RELOC_V850_TDA_4_4_OFFSET,
32480 +/* This is a 16 bit offset from the short data area pointer, with the
32481 +bits placed non-contiguously in the instruction. */
32482 + BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET,
32484 +/* This is a 16 bit offset from the zero data area pointer, with the
32485 +bits placed non-contiguously in the instruction. */
32486 + BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET,
32488 +/* This is a 6 bit offset from the call table base pointer. */
32489 + BFD_RELOC_V850_CALLT_6_7_OFFSET,
32491 +/* This is a 16 bit offset from the call table base pointer. */
32492 + BFD_RELOC_V850_CALLT_16_16_OFFSET,
32494 +/* Used for relaxing indirect function calls. */
32495 + BFD_RELOC_V850_LONGCALL,
32497 +/* Used for relaxing indirect jumps. */
32498 + BFD_RELOC_V850_LONGJUMP,
32500 +/* Used to maintain alignment whilst relaxing. */
32501 + BFD_RELOC_V850_ALIGN,
32503 +/* This is a variation of BFD_RELOC_LO16 that can be used in v850e ld.bu
32505 + BFD_RELOC_V850_LO16_SPLIT_OFFSET,
32507 +/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
32509 + BFD_RELOC_MN10300_32_PCREL,
32511 +/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
32513 + BFD_RELOC_MN10300_16_PCREL,
32515 +/* This is a 8bit DP reloc for the tms320c30, where the most
32516 +significant 8 bits of a 24 bit word are placed into the least
32517 +significant 8 bits of the opcode. */
32518 + BFD_RELOC_TIC30_LDP,
32520 +/* This is a 7bit reloc for the tms320c54x, where the least
32521 +significant 7 bits of a 16 bit word are placed into the least
32522 +significant 7 bits of the opcode. */
32523 + BFD_RELOC_TIC54X_PARTLS7,
32525 +/* This is a 9bit DP reloc for the tms320c54x, where the most
32526 +significant 9 bits of a 16 bit word are placed into the least
32527 +significant 9 bits of the opcode. */
32528 + BFD_RELOC_TIC54X_PARTMS9,
32530 +/* This is an extended address 23-bit reloc for the tms320c54x. */
32531 + BFD_RELOC_TIC54X_23,
32533 +/* This is a 16-bit reloc for the tms320c54x, where the least
32534 +significant 16 bits of a 23-bit extended address are placed into
32536 + BFD_RELOC_TIC54X_16_OF_23,
32538 +/* This is a reloc for the tms320c54x, where the most
32539 +significant 7 bits of a 23-bit extended address are placed into
32541 + BFD_RELOC_TIC54X_MS7_OF_23,
32543 +/* This is a 48 bit reloc for the FR30 that stores 32 bits. */
32544 + BFD_RELOC_FR30_48,
32546 +/* This is a 32 bit reloc for the FR30 that stores 20 bits split up into
32548 + BFD_RELOC_FR30_20,
32550 +/* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
32552 + BFD_RELOC_FR30_6_IN_4,
32554 +/* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
32556 + BFD_RELOC_FR30_8_IN_8,
32558 +/* This is a 16 bit reloc for the FR30 that stores a 9 bit short offset
32560 + BFD_RELOC_FR30_9_IN_8,
32562 +/* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
32564 + BFD_RELOC_FR30_10_IN_8,
32566 +/* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
32567 +short offset into 8 bits. */
32568 + BFD_RELOC_FR30_9_PCREL,
32570 +/* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
32571 +short offset into 11 bits. */
32572 + BFD_RELOC_FR30_12_PCREL,
32574 +/* Motorola Mcore relocations. */
32575 + BFD_RELOC_MCORE_PCREL_IMM8BY4,
32576 + BFD_RELOC_MCORE_PCREL_IMM11BY2,
32577 + BFD_RELOC_MCORE_PCREL_IMM4BY2,
32578 + BFD_RELOC_MCORE_PCREL_32,
32579 + BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2,
32580 + BFD_RELOC_MCORE_RVA,
32582 +/* These are relocations for the GETA instruction. */
32583 + BFD_RELOC_MMIX_GETA,
32584 + BFD_RELOC_MMIX_GETA_1,
32585 + BFD_RELOC_MMIX_GETA_2,
32586 + BFD_RELOC_MMIX_GETA_3,
32588 +/* These are relocations for a conditional branch instruction. */
32589 + BFD_RELOC_MMIX_CBRANCH,
32590 + BFD_RELOC_MMIX_CBRANCH_J,
32591 + BFD_RELOC_MMIX_CBRANCH_1,
32592 + BFD_RELOC_MMIX_CBRANCH_2,
32593 + BFD_RELOC_MMIX_CBRANCH_3,
32595 +/* These are relocations for the PUSHJ instruction. */
32596 + BFD_RELOC_MMIX_PUSHJ,
32597 + BFD_RELOC_MMIX_PUSHJ_1,
32598 + BFD_RELOC_MMIX_PUSHJ_2,
32599 + BFD_RELOC_MMIX_PUSHJ_3,
32600 + BFD_RELOC_MMIX_PUSHJ_STUBBABLE,
32602 +/* These are relocations for the JMP instruction. */
32603 + BFD_RELOC_MMIX_JMP,
32604 + BFD_RELOC_MMIX_JMP_1,
32605 + BFD_RELOC_MMIX_JMP_2,
32606 + BFD_RELOC_MMIX_JMP_3,
32608 +/* This is a relocation for a relative address as in a GETA instruction or
32610 + BFD_RELOC_MMIX_ADDR19,
32612 +/* This is a relocation for a relative address as in a JMP instruction. */
32613 + BFD_RELOC_MMIX_ADDR27,
32615 +/* This is a relocation for an instruction field that may be a general
32616 +register or a value 0..255. */
32617 + BFD_RELOC_MMIX_REG_OR_BYTE,
32619 +/* This is a relocation for an instruction field that may be a general
32621 + BFD_RELOC_MMIX_REG,
32623 +/* This is a relocation for two instruction fields holding a register and
32624 +an offset, the equivalent of the relocation. */
32625 + BFD_RELOC_MMIX_BASE_PLUS_OFFSET,
32627 +/* This relocation is an assertion that the expression is not allocated as
32628 +a global register. It does not modify contents. */
32629 + BFD_RELOC_MMIX_LOCAL,
32631 +/* This is a 16 bit reloc for the AVR that stores 8 bit pc relative
32632 +short offset into 7 bits. */
32633 + BFD_RELOC_AVR_7_PCREL,
32635 +/* This is a 16 bit reloc for the AVR that stores 13 bit pc relative
32636 +short offset into 12 bits. */
32637 + BFD_RELOC_AVR_13_PCREL,
32639 +/* This is a 16 bit reloc for the AVR that stores 17 bit value (usually
32640 +program memory address) into 16 bits. */
32641 + BFD_RELOC_AVR_16_PM,
32643 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually
32644 +data memory address) into 8 bit immediate value of LDI insn. */
32645 + BFD_RELOC_AVR_LO8_LDI,
32647 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
32648 +of data memory address) into 8 bit immediate value of LDI insn. */
32649 + BFD_RELOC_AVR_HI8_LDI,
32651 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
32652 +of program memory address) into 8 bit immediate value of LDI insn. */
32653 + BFD_RELOC_AVR_HH8_LDI,
32655 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
32656 +(usually data memory address) into 8 bit immediate value of SUBI insn. */
32657 + BFD_RELOC_AVR_LO8_LDI_NEG,
32659 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
32660 +(high 8 bit of data memory address) into 8 bit immediate value of
32662 + BFD_RELOC_AVR_HI8_LDI_NEG,
32664 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
32665 +(most high 8 bit of program memory address) into 8 bit immediate value
32666 +of LDI or SUBI insn. */
32667 + BFD_RELOC_AVR_HH8_LDI_NEG,
32669 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually
32670 +command address) into 8 bit immediate value of LDI insn. */
32671 + BFD_RELOC_AVR_LO8_LDI_PM,
32673 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
32674 +of command address) into 8 bit immediate value of LDI insn. */
32675 + BFD_RELOC_AVR_HI8_LDI_PM,
32677 +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
32678 +of command address) into 8 bit immediate value of LDI insn. */
32679 + BFD_RELOC_AVR_HH8_LDI_PM,
32681 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
32682 +(usually command address) into 8 bit immediate value of SUBI insn. */
32683 + BFD_RELOC_AVR_LO8_LDI_PM_NEG,
32685 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
32686 +(high 8 bit of 16 bit command address) into 8 bit immediate value
32688 + BFD_RELOC_AVR_HI8_LDI_PM_NEG,
32690 +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value
32691 +(high 6 bit of 22 bit command address) into 8 bit immediate
32692 +value of SUBI insn. */
32693 + BFD_RELOC_AVR_HH8_LDI_PM_NEG,
32695 +/* This is a 32 bit reloc for the AVR that stores 23 bit value
32697 + BFD_RELOC_AVR_CALL,
32699 +/* This is a 16 bit reloc for the AVR that stores all needed bits
32700 +for absolute addressing with ldi with overflow check to linktime */
32701 + BFD_RELOC_AVR_LDI,
32703 +/* This is a 6 bit reloc for the AVR that stores offset for ldd/std
32707 +/* This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw
32709 + BFD_RELOC_AVR_6_ADIW,
32711 +/* Direct 12 bit. */
32712 + BFD_RELOC_390_12,
32714 +/* 12 bit GOT offset. */
32715 + BFD_RELOC_390_GOT12,
32717 +/* 32 bit PC relative PLT address. */
32718 + BFD_RELOC_390_PLT32,
32720 +/* Copy symbol at runtime. */
32721 + BFD_RELOC_390_COPY,
32723 +/* Create GOT entry. */
32724 + BFD_RELOC_390_GLOB_DAT,
32726 +/* Create PLT entry. */
32727 + BFD_RELOC_390_JMP_SLOT,
32729 +/* Adjust by program base. */
32730 + BFD_RELOC_390_RELATIVE,
32732 +/* 32 bit PC relative offset to GOT. */
32733 + BFD_RELOC_390_GOTPC,
32735 +/* 16 bit GOT offset. */
32736 + BFD_RELOC_390_GOT16,
32738 +/* PC relative 16 bit shifted by 1. */
32739 + BFD_RELOC_390_PC16DBL,
32741 +/* 16 bit PC rel. PLT shifted by 1. */
32742 + BFD_RELOC_390_PLT16DBL,
32744 +/* PC relative 32 bit shifted by 1. */
32745 + BFD_RELOC_390_PC32DBL,
32747 +/* 32 bit PC rel. PLT shifted by 1. */
32748 + BFD_RELOC_390_PLT32DBL,
32750 +/* 32 bit PC rel. GOT shifted by 1. */
32751 + BFD_RELOC_390_GOTPCDBL,
32753 +/* 64 bit GOT offset. */
32754 + BFD_RELOC_390_GOT64,
32756 +/* 64 bit PC relative PLT address. */
32757 + BFD_RELOC_390_PLT64,
32759 +/* 32 bit rel. offset to GOT entry. */
32760 + BFD_RELOC_390_GOTENT,
32762 +/* 64 bit offset to GOT. */
32763 + BFD_RELOC_390_GOTOFF64,
32765 +/* 12-bit offset to symbol-entry within GOT, with PLT handling. */
32766 + BFD_RELOC_390_GOTPLT12,
32768 +/* 16-bit offset to symbol-entry within GOT, with PLT handling. */
32769 + BFD_RELOC_390_GOTPLT16,
32771 +/* 32-bit offset to symbol-entry within GOT, with PLT handling. */
32772 + BFD_RELOC_390_GOTPLT32,
32774 +/* 64-bit offset to symbol-entry within GOT, with PLT handling. */
32775 + BFD_RELOC_390_GOTPLT64,
32777 +/* 32-bit rel. offset to symbol-entry within GOT, with PLT handling. */
32778 + BFD_RELOC_390_GOTPLTENT,
32780 +/* 16-bit rel. offset from the GOT to a PLT entry. */
32781 + BFD_RELOC_390_PLTOFF16,
32783 +/* 32-bit rel. offset from the GOT to a PLT entry. */
32784 + BFD_RELOC_390_PLTOFF32,
32786 +/* 64-bit rel. offset from the GOT to a PLT entry. */
32787 + BFD_RELOC_390_PLTOFF64,
32789 +/* s390 tls relocations. */
32790 + BFD_RELOC_390_TLS_LOAD,
32791 + BFD_RELOC_390_TLS_GDCALL,
32792 + BFD_RELOC_390_TLS_LDCALL,
32793 + BFD_RELOC_390_TLS_GD32,
32794 + BFD_RELOC_390_TLS_GD64,
32795 + BFD_RELOC_390_TLS_GOTIE12,
32796 + BFD_RELOC_390_TLS_GOTIE32,
32797 + BFD_RELOC_390_TLS_GOTIE64,
32798 + BFD_RELOC_390_TLS_LDM32,
32799 + BFD_RELOC_390_TLS_LDM64,
32800 + BFD_RELOC_390_TLS_IE32,
32801 + BFD_RELOC_390_TLS_IE64,
32802 + BFD_RELOC_390_TLS_IEENT,
32803 + BFD_RELOC_390_TLS_LE32,
32804 + BFD_RELOC_390_TLS_LE64,
32805 + BFD_RELOC_390_TLS_LDO32,
32806 + BFD_RELOC_390_TLS_LDO64,
32807 + BFD_RELOC_390_TLS_DTPMOD,
32808 + BFD_RELOC_390_TLS_DTPOFF,
32809 + BFD_RELOC_390_TLS_TPOFF,
32811 +/* Long displacement extension. */
32812 + BFD_RELOC_390_20,
32813 + BFD_RELOC_390_GOT20,
32814 + BFD_RELOC_390_GOTPLT20,
32815 + BFD_RELOC_390_TLS_GOTIE20,
32817 +/* Scenix IP2K - 9-bit register number / data address */
32818 + BFD_RELOC_IP2K_FR9,
32820 +/* Scenix IP2K - 4-bit register/data bank number */
32821 + BFD_RELOC_IP2K_BANK,
32823 +/* Scenix IP2K - low 13 bits of instruction word address */
32824 + BFD_RELOC_IP2K_ADDR16CJP,
32826 +/* Scenix IP2K - high 3 bits of instruction word address */
32827 + BFD_RELOC_IP2K_PAGE3,
32829 +/* Scenix IP2K - ext/low/high 8 bits of data address */
32830 + BFD_RELOC_IP2K_LO8DATA,
32831 + BFD_RELOC_IP2K_HI8DATA,
32832 + BFD_RELOC_IP2K_EX8DATA,
32834 +/* Scenix IP2K - low/high 8 bits of instruction word address */
32835 + BFD_RELOC_IP2K_LO8INSN,
32836 + BFD_RELOC_IP2K_HI8INSN,
32838 +/* Scenix IP2K - even/odd PC modifier to modify snb pcl.0 */
32839 + BFD_RELOC_IP2K_PC_SKIP,
32841 +/* Scenix IP2K - 16 bit word address in text section. */
32842 + BFD_RELOC_IP2K_TEXT,
32844 +/* Scenix IP2K - 7-bit sp or dp offset */
32845 + BFD_RELOC_IP2K_FR_OFFSET,
32847 +/* Scenix VPE4K coprocessor - data/insn-space addressing */
32848 + BFD_RELOC_VPE4KMATH_DATA,
32849 + BFD_RELOC_VPE4KMATH_INSN,
32851 +/* These two relocations are used by the linker to determine which of
32852 +the entries in a C++ virtual function table are actually used. When
32853 +the --gc-sections option is given, the linker will zero out the entries
32854 +that are not used, so that the code for those functions need not be
32855 +included in the output.
32857 +VTABLE_INHERIT is a zero-space relocation used to describe to the
32858 +linker the inheritance tree of a C++ virtual function table. The
32859 +relocation's symbol should be the parent class' vtable, and the
32860 +relocation should be located at the child vtable.
32862 +VTABLE_ENTRY is a zero-space relocation that describes the use of a
32863 +virtual function table entry. The reloc's symbol should refer to the
32864 +table of the class mentioned in the code. Off of that base, an offset
32865 +describes the entry that is being used. For Rela hosts, this offset
32866 +is stored in the reloc's addend. For Rel hosts, we are forced to put
32867 +this offset in the reloc's section offset. */
32868 + BFD_RELOC_VTABLE_INHERIT,
32869 + BFD_RELOC_VTABLE_ENTRY,
32871 +/* Intel IA64 Relocations. */
32872 + BFD_RELOC_IA64_IMM14,
32873 + BFD_RELOC_IA64_IMM22,
32874 + BFD_RELOC_IA64_IMM64,
32875 + BFD_RELOC_IA64_DIR32MSB,
32876 + BFD_RELOC_IA64_DIR32LSB,
32877 + BFD_RELOC_IA64_DIR64MSB,
32878 + BFD_RELOC_IA64_DIR64LSB,
32879 + BFD_RELOC_IA64_GPREL22,
32880 + BFD_RELOC_IA64_GPREL64I,
32881 + BFD_RELOC_IA64_GPREL32MSB,
32882 + BFD_RELOC_IA64_GPREL32LSB,
32883 + BFD_RELOC_IA64_GPREL64MSB,
32884 + BFD_RELOC_IA64_GPREL64LSB,
32885 + BFD_RELOC_IA64_LTOFF22,
32886 + BFD_RELOC_IA64_LTOFF64I,
32887 + BFD_RELOC_IA64_PLTOFF22,
32888 + BFD_RELOC_IA64_PLTOFF64I,
32889 + BFD_RELOC_IA64_PLTOFF64MSB,
32890 + BFD_RELOC_IA64_PLTOFF64LSB,
32891 + BFD_RELOC_IA64_FPTR64I,
32892 + BFD_RELOC_IA64_FPTR32MSB,
32893 + BFD_RELOC_IA64_FPTR32LSB,
32894 + BFD_RELOC_IA64_FPTR64MSB,
32895 + BFD_RELOC_IA64_FPTR64LSB,
32896 + BFD_RELOC_IA64_PCREL21B,
32897 + BFD_RELOC_IA64_PCREL21BI,
32898 + BFD_RELOC_IA64_PCREL21M,
32899 + BFD_RELOC_IA64_PCREL21F,
32900 + BFD_RELOC_IA64_PCREL22,
32901 + BFD_RELOC_IA64_PCREL60B,
32902 + BFD_RELOC_IA64_PCREL64I,
32903 + BFD_RELOC_IA64_PCREL32MSB,
32904 + BFD_RELOC_IA64_PCREL32LSB,
32905 + BFD_RELOC_IA64_PCREL64MSB,
32906 + BFD_RELOC_IA64_PCREL64LSB,
32907 + BFD_RELOC_IA64_LTOFF_FPTR22,
32908 + BFD_RELOC_IA64_LTOFF_FPTR64I,
32909 + BFD_RELOC_IA64_LTOFF_FPTR32MSB,
32910 + BFD_RELOC_IA64_LTOFF_FPTR32LSB,
32911 + BFD_RELOC_IA64_LTOFF_FPTR64MSB,
32912 + BFD_RELOC_IA64_LTOFF_FPTR64LSB,
32913 + BFD_RELOC_IA64_SEGREL32MSB,
32914 + BFD_RELOC_IA64_SEGREL32LSB,
32915 + BFD_RELOC_IA64_SEGREL64MSB,
32916 + BFD_RELOC_IA64_SEGREL64LSB,
32917 + BFD_RELOC_IA64_SECREL32MSB,
32918 + BFD_RELOC_IA64_SECREL32LSB,
32919 + BFD_RELOC_IA64_SECREL64MSB,
32920 + BFD_RELOC_IA64_SECREL64LSB,
32921 + BFD_RELOC_IA64_REL32MSB,
32922 + BFD_RELOC_IA64_REL32LSB,
32923 + BFD_RELOC_IA64_REL64MSB,
32924 + BFD_RELOC_IA64_REL64LSB,
32925 + BFD_RELOC_IA64_LTV32MSB,
32926 + BFD_RELOC_IA64_LTV32LSB,
32927 + BFD_RELOC_IA64_LTV64MSB,
32928 + BFD_RELOC_IA64_LTV64LSB,
32929 + BFD_RELOC_IA64_IPLTMSB,
32930 + BFD_RELOC_IA64_IPLTLSB,
32931 + BFD_RELOC_IA64_COPY,
32932 + BFD_RELOC_IA64_LTOFF22X,
32933 + BFD_RELOC_IA64_LDXMOV,
32934 + BFD_RELOC_IA64_TPREL14,
32935 + BFD_RELOC_IA64_TPREL22,
32936 + BFD_RELOC_IA64_TPREL64I,
32937 + BFD_RELOC_IA64_TPREL64MSB,
32938 + BFD_RELOC_IA64_TPREL64LSB,
32939 + BFD_RELOC_IA64_LTOFF_TPREL22,
32940 + BFD_RELOC_IA64_DTPMOD64MSB,
32941 + BFD_RELOC_IA64_DTPMOD64LSB,
32942 + BFD_RELOC_IA64_LTOFF_DTPMOD22,
32943 + BFD_RELOC_IA64_DTPREL14,
32944 + BFD_RELOC_IA64_DTPREL22,
32945 + BFD_RELOC_IA64_DTPREL64I,
32946 + BFD_RELOC_IA64_DTPREL32MSB,
32947 + BFD_RELOC_IA64_DTPREL32LSB,
32948 + BFD_RELOC_IA64_DTPREL64MSB,
32949 + BFD_RELOC_IA64_DTPREL64LSB,
32950 + BFD_RELOC_IA64_LTOFF_DTPREL22,
32952 +/* Motorola 68HC11 reloc.
32953 +This is the 8 bit high part of an absolute address. */
32954 + BFD_RELOC_M68HC11_HI8,
32956 +/* Motorola 68HC11 reloc.
32957 +This is the 8 bit low part of an absolute address. */
32958 + BFD_RELOC_M68HC11_LO8,
32960 +/* Motorola 68HC11 reloc.
32961 +This is the 3 bit of a value. */
32962 + BFD_RELOC_M68HC11_3B,
32964 +/* Motorola 68HC11 reloc.
32965 +This reloc marks the beginning of a jump/call instruction.
32966 +It is used for linker relaxation to correctly identify beginning
32967 +of instruction and change some branches to use PC-relative
32968 +addressing mode. */
32969 + BFD_RELOC_M68HC11_RL_JUMP,
32971 +/* Motorola 68HC11 reloc.
32972 +This reloc marks a group of several instructions that gcc generates
32973 +and for which the linker relaxation pass can modify and/or remove
32975 + BFD_RELOC_M68HC11_RL_GROUP,
32977 +/* Motorola 68HC11 reloc.
32978 +This is the 16-bit lower part of an address. It is used for 'call'
32979 +instruction to specify the symbol address without any special
32980 +transformation (due to memory bank window). */
32981 + BFD_RELOC_M68HC11_LO16,
32983 +/* Motorola 68HC11 reloc.
32984 +This is a 8-bit reloc that specifies the page number of an address.
32985 +It is used by 'call' instruction to specify the page number of
32987 + BFD_RELOC_M68HC11_PAGE,
32989 +/* Motorola 68HC11 reloc.
32990 +This is a 24-bit reloc that represents the address with a 16-bit
32991 +value and a 8-bit page number. The symbol address is transformed
32992 +to follow the 16K memory bank of 68HC12 (seen as mapped in the window). */
32993 + BFD_RELOC_M68HC11_24,
32995 +/* Motorola 68HC12 reloc.
32996 +This is the 5 bits of a value. */
32997 + BFD_RELOC_M68HC12_5B,
32999 +/* NS CR16C Relocations. */
33000 + BFD_RELOC_16C_NUM08,
33001 + BFD_RELOC_16C_NUM08_C,
33002 + BFD_RELOC_16C_NUM16,
33003 + BFD_RELOC_16C_NUM16_C,
33004 + BFD_RELOC_16C_NUM32,
33005 + BFD_RELOC_16C_NUM32_C,
33006 + BFD_RELOC_16C_DISP04,
33007 + BFD_RELOC_16C_DISP04_C,
33008 + BFD_RELOC_16C_DISP08,
33009 + BFD_RELOC_16C_DISP08_C,
33010 + BFD_RELOC_16C_DISP16,
33011 + BFD_RELOC_16C_DISP16_C,
33012 + BFD_RELOC_16C_DISP24,
33013 + BFD_RELOC_16C_DISP24_C,
33014 + BFD_RELOC_16C_DISP24a,
33015 + BFD_RELOC_16C_DISP24a_C,
33016 + BFD_RELOC_16C_REG04,
33017 + BFD_RELOC_16C_REG04_C,
33018 + BFD_RELOC_16C_REG04a,
33019 + BFD_RELOC_16C_REG04a_C,
33020 + BFD_RELOC_16C_REG14,
33021 + BFD_RELOC_16C_REG14_C,
33022 + BFD_RELOC_16C_REG16,
33023 + BFD_RELOC_16C_REG16_C,
33024 + BFD_RELOC_16C_REG20,
33025 + BFD_RELOC_16C_REG20_C,
33026 + BFD_RELOC_16C_ABS20,
33027 + BFD_RELOC_16C_ABS20_C,
33028 + BFD_RELOC_16C_ABS24,
33029 + BFD_RELOC_16C_ABS24_C,
33030 + BFD_RELOC_16C_IMM04,
33031 + BFD_RELOC_16C_IMM04_C,
33032 + BFD_RELOC_16C_IMM16,
33033 + BFD_RELOC_16C_IMM16_C,
33034 + BFD_RELOC_16C_IMM20,
33035 + BFD_RELOC_16C_IMM20_C,
33036 + BFD_RELOC_16C_IMM24,
33037 + BFD_RELOC_16C_IMM24_C,
33038 + BFD_RELOC_16C_IMM32,
33039 + BFD_RELOC_16C_IMM32_C,
33041 +/* NS CRX Relocations. */
33042 + BFD_RELOC_CRX_REL4,
33043 + BFD_RELOC_CRX_REL8,
33044 + BFD_RELOC_CRX_REL8_CMP,
33045 + BFD_RELOC_CRX_REL16,
33046 + BFD_RELOC_CRX_REL24,
33047 + BFD_RELOC_CRX_REL32,
33048 + BFD_RELOC_CRX_REGREL12,
33049 + BFD_RELOC_CRX_REGREL22,
33050 + BFD_RELOC_CRX_REGREL28,
33051 + BFD_RELOC_CRX_REGREL32,
33052 + BFD_RELOC_CRX_ABS16,
33053 + BFD_RELOC_CRX_ABS32,
33054 + BFD_RELOC_CRX_NUM8,
33055 + BFD_RELOC_CRX_NUM16,
33056 + BFD_RELOC_CRX_NUM32,
33057 + BFD_RELOC_CRX_IMM16,
33058 + BFD_RELOC_CRX_IMM32,
33059 + BFD_RELOC_CRX_SWITCH8,
33060 + BFD_RELOC_CRX_SWITCH16,
33061 + BFD_RELOC_CRX_SWITCH32,
33063 +/* These relocs are only used within the CRIS assembler. They are not
33064 +(at present) written to any object files. */
33065 + BFD_RELOC_CRIS_BDISP8,
33066 + BFD_RELOC_CRIS_UNSIGNED_5,
33067 + BFD_RELOC_CRIS_SIGNED_6,
33068 + BFD_RELOC_CRIS_UNSIGNED_6,
33069 + BFD_RELOC_CRIS_SIGNED_8,
33070 + BFD_RELOC_CRIS_UNSIGNED_8,
33071 + BFD_RELOC_CRIS_SIGNED_16,
33072 + BFD_RELOC_CRIS_UNSIGNED_16,
33073 + BFD_RELOC_CRIS_LAPCQ_OFFSET,
33074 + BFD_RELOC_CRIS_UNSIGNED_4,
33076 +/* Relocs used in ELF shared libraries for CRIS. */
33077 + BFD_RELOC_CRIS_COPY,
33078 + BFD_RELOC_CRIS_GLOB_DAT,
33079 + BFD_RELOC_CRIS_JUMP_SLOT,
33080 + BFD_RELOC_CRIS_RELATIVE,
33082 +/* 32-bit offset to symbol-entry within GOT. */
33083 + BFD_RELOC_CRIS_32_GOT,
33085 +/* 16-bit offset to symbol-entry within GOT. */
33086 + BFD_RELOC_CRIS_16_GOT,
33088 +/* 32-bit offset to symbol-entry within GOT, with PLT handling. */
33089 + BFD_RELOC_CRIS_32_GOTPLT,
33091 +/* 16-bit offset to symbol-entry within GOT, with PLT handling. */
33092 + BFD_RELOC_CRIS_16_GOTPLT,
33094 +/* 32-bit offset to symbol, relative to GOT. */
33095 + BFD_RELOC_CRIS_32_GOTREL,
33097 +/* 32-bit offset to symbol with PLT entry, relative to GOT. */
33098 + BFD_RELOC_CRIS_32_PLT_GOTREL,
33100 +/* 32-bit offset to symbol with PLT entry, relative to this relocation. */
33101 + BFD_RELOC_CRIS_32_PLT_PCREL,
33103 +/* Intel i860 Relocations. */
33104 + BFD_RELOC_860_COPY,
33105 + BFD_RELOC_860_GLOB_DAT,
33106 + BFD_RELOC_860_JUMP_SLOT,
33107 + BFD_RELOC_860_RELATIVE,
33108 + BFD_RELOC_860_PC26,
33109 + BFD_RELOC_860_PLT26,
33110 + BFD_RELOC_860_PC16,
33111 + BFD_RELOC_860_LOW0,
33112 + BFD_RELOC_860_SPLIT0,
33113 + BFD_RELOC_860_LOW1,
33114 + BFD_RELOC_860_SPLIT1,
33115 + BFD_RELOC_860_LOW2,
33116 + BFD_RELOC_860_SPLIT2,
33117 + BFD_RELOC_860_LOW3,
33118 + BFD_RELOC_860_LOGOT0,
33119 + BFD_RELOC_860_SPGOT0,
33120 + BFD_RELOC_860_LOGOT1,
33121 + BFD_RELOC_860_SPGOT1,
33122 + BFD_RELOC_860_LOGOTOFF0,
33123 + BFD_RELOC_860_SPGOTOFF0,
33124 + BFD_RELOC_860_LOGOTOFF1,
33125 + BFD_RELOC_860_SPGOTOFF1,
33126 + BFD_RELOC_860_LOGOTOFF2,
33127 + BFD_RELOC_860_LOGOTOFF3,
33128 + BFD_RELOC_860_LOPC,
33129 + BFD_RELOC_860_HIGHADJ,
33130 + BFD_RELOC_860_HAGOT,
33131 + BFD_RELOC_860_HAGOTOFF,
33132 + BFD_RELOC_860_HAPC,
33133 + BFD_RELOC_860_HIGH,
33134 + BFD_RELOC_860_HIGOT,
33135 + BFD_RELOC_860_HIGOTOFF,
33137 +/* OpenRISC Relocations. */
33138 + BFD_RELOC_OPENRISC_ABS_26,
33139 + BFD_RELOC_OPENRISC_REL_26,
33141 +/* H8 elf Relocations. */
33142 + BFD_RELOC_H8_DIR16A8,
33143 + BFD_RELOC_H8_DIR16R8,
33144 + BFD_RELOC_H8_DIR24A8,
33145 + BFD_RELOC_H8_DIR24R8,
33146 + BFD_RELOC_H8_DIR32A16,
33148 +/* Sony Xstormy16 Relocations. */
33149 + BFD_RELOC_XSTORMY16_REL_12,
33150 + BFD_RELOC_XSTORMY16_12,
33151 + BFD_RELOC_XSTORMY16_24,
33152 + BFD_RELOC_XSTORMY16_FPTR16,
33154 +/* Relocations used by VAX ELF. */
33155 + BFD_RELOC_VAX_GLOB_DAT,
33156 + BFD_RELOC_VAX_JMP_SLOT,
33157 + BFD_RELOC_VAX_RELATIVE,
33159 +/* Morpho MS1 - 16 bit immediate relocation. */
33160 + BFD_RELOC_MS1_PC16,
33162 +/* Morpho MS1 - Hi 16 bits of an address. */
33163 + BFD_RELOC_MS1_HI16,
33165 +/* Morpho MS1 - Low 16 bits of an address. */
33166 + BFD_RELOC_MS1_LO16,
33168 +/* Morpho MS1 - Used to tell the linker which vtable entries are used. */
33169 + BFD_RELOC_MS1_GNU_VTINHERIT,
33171 +/* Morpho MS1 - Used to tell the linker which vtable entries are used. */
33172 + BFD_RELOC_MS1_GNU_VTENTRY,
33174 +/* msp430 specific relocation codes */
33175 + BFD_RELOC_MSP430_10_PCREL,
33176 + BFD_RELOC_MSP430_16_PCREL,
33177 + BFD_RELOC_MSP430_16,
33178 + BFD_RELOC_MSP430_16_PCREL_BYTE,
33179 + BFD_RELOC_MSP430_16_BYTE,
33180 + BFD_RELOC_MSP430_2X_PCREL,
33181 + BFD_RELOC_MSP430_RL_PCREL,
33183 +/* IQ2000 Relocations. */
33184 + BFD_RELOC_IQ2000_OFFSET_16,
33185 + BFD_RELOC_IQ2000_OFFSET_21,
33186 + BFD_RELOC_IQ2000_UHI16,
33188 +/* Special Xtensa relocation used only by PLT entries in ELF shared
33189 +objects to indicate that the runtime linker should set the value
33190 +to one of its own internal functions or data structures. */
33191 + BFD_RELOC_XTENSA_RTLD,
33193 +/* Xtensa relocations for ELF shared objects. */
33194 + BFD_RELOC_XTENSA_GLOB_DAT,
33195 + BFD_RELOC_XTENSA_JMP_SLOT,
33196 + BFD_RELOC_XTENSA_RELATIVE,
33198 +/* Xtensa relocation used in ELF object files for symbols that may require
33199 +PLT entries. Otherwise, this is just a generic 32-bit relocation. */
33200 + BFD_RELOC_XTENSA_PLT,
33202 +/* Xtensa relocations to mark the difference of two local symbols.
33203 +These are only needed to support linker relaxation and can be ignored
33204 +when not relaxing. The field is set to the value of the difference
33205 +assuming no relaxation. The relocation encodes the position of the
33206 +first symbol so the linker can determine whether to adjust the field
33208 + BFD_RELOC_XTENSA_DIFF8,
33209 + BFD_RELOC_XTENSA_DIFF16,
33210 + BFD_RELOC_XTENSA_DIFF32,
33212 +/* Generic Xtensa relocations for instruction operands. Only the slot
33213 +number is encoded in the relocation. The relocation applies to the
33214 +last PC-relative immediate operand, or if there are no PC-relative
33215 +immediates, to the last immediate operand. */
33216 + BFD_RELOC_XTENSA_SLOT0_OP,
33217 + BFD_RELOC_XTENSA_SLOT1_OP,
33218 + BFD_RELOC_XTENSA_SLOT2_OP,
33219 + BFD_RELOC_XTENSA_SLOT3_OP,
33220 + BFD_RELOC_XTENSA_SLOT4_OP,
33221 + BFD_RELOC_XTENSA_SLOT5_OP,
33222 + BFD_RELOC_XTENSA_SLOT6_OP,
33223 + BFD_RELOC_XTENSA_SLOT7_OP,
33224 + BFD_RELOC_XTENSA_SLOT8_OP,
33225 + BFD_RELOC_XTENSA_SLOT9_OP,
33226 + BFD_RELOC_XTENSA_SLOT10_OP,
33227 + BFD_RELOC_XTENSA_SLOT11_OP,
33228 + BFD_RELOC_XTENSA_SLOT12_OP,
33229 + BFD_RELOC_XTENSA_SLOT13_OP,
33230 + BFD_RELOC_XTENSA_SLOT14_OP,
33232 +/* Alternate Xtensa relocations. Only the slot is encoded in the
33233 +relocation. The meaning of these relocations is opcode-specific. */
33234 + BFD_RELOC_XTENSA_SLOT0_ALT,
33235 + BFD_RELOC_XTENSA_SLOT1_ALT,
33236 + BFD_RELOC_XTENSA_SLOT2_ALT,
33237 + BFD_RELOC_XTENSA_SLOT3_ALT,
33238 + BFD_RELOC_XTENSA_SLOT4_ALT,
33239 + BFD_RELOC_XTENSA_SLOT5_ALT,
33240 + BFD_RELOC_XTENSA_SLOT6_ALT,
33241 + BFD_RELOC_XTENSA_SLOT7_ALT,
33242 + BFD_RELOC_XTENSA_SLOT8_ALT,
33243 + BFD_RELOC_XTENSA_SLOT9_ALT,
33244 + BFD_RELOC_XTENSA_SLOT10_ALT,
33245 + BFD_RELOC_XTENSA_SLOT11_ALT,
33246 + BFD_RELOC_XTENSA_SLOT12_ALT,
33247 + BFD_RELOC_XTENSA_SLOT13_ALT,
33248 + BFD_RELOC_XTENSA_SLOT14_ALT,
33250 +/* Xtensa relocations for backward compatibility. These have all been
33251 +replaced by BFD_RELOC_XTENSA_SLOT0_OP. */
33252 + BFD_RELOC_XTENSA_OP0,
33253 + BFD_RELOC_XTENSA_OP1,
33254 + BFD_RELOC_XTENSA_OP2,
33256 +/* Xtensa relocation to mark that the assembler expanded the
33257 +instructions from an original target. The expansion size is
33258 +encoded in the reloc size. */
33259 + BFD_RELOC_XTENSA_ASM_EXPAND,
33261 +/* Xtensa relocation to mark that the linker should simplify
33262 +assembler-expanded instructions. This is commonly used
33263 +internally by the linker after analysis of a
33264 +BFD_RELOC_XTENSA_ASM_EXPAND. */
33265 + BFD_RELOC_XTENSA_ASM_SIMPLIFY,
33266 + BFD_RELOC_UNUSED };
33267 +typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
33268 +reloc_howto_type *bfd_reloc_type_lookup
33269 + (bfd *abfd, bfd_reloc_code_real_type code);
33271 +const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code);
33273 +/* Extracted from syms.c. */
33275 +typedef struct bfd_symbol
33277 + /* A pointer to the BFD which owns the symbol. This information
33278 + is necessary so that a back end can work out what additional
33279 + information (invisible to the application writer) is carried
33282 + This field is *almost* redundant, since you can use section->owner
33283 + instead, except that some symbols point to the global sections
33284 + bfd_{abs,com,und}_section. This could be fixed by making
33285 + these globals be per-bfd (or per-target-flavor). FIXME. */
33286 + struct bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */
33288 + /* The text of the symbol. The name is left alone, and not copied; the
33289 + application may not alter it. */
33290 + const char *name;
33292 + /* The value of the symbol. This really should be a union of a
33293 + numeric value with a pointer, since some flags indicate that
33294 + a pointer to another symbol is stored here. */
33297 + /* Attributes of a symbol. */
33298 +#define BSF_NO_FLAGS 0x00
33300 + /* The symbol has local scope; <<static>> in <<C>>. The value
33301 + is the offset into the section of the data. */
33302 +#define BSF_LOCAL 0x01
33304 + /* The symbol has global scope; initialized data in <<C>>. The
33305 + value is the offset into the section of the data. */
33306 +#define BSF_GLOBAL 0x02
33308 + /* The symbol has global scope and is exported. The value is
33309 + the offset into the section of the data. */
33310 +#define BSF_EXPORT BSF_GLOBAL /* No real difference. */
33312 + /* A normal C symbol would be one of:
33313 + <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
33314 + <<BSF_GLOBAL>>. */
33316 + /* The symbol is a debugging record. The value has an arbitrary
33317 + meaning, unless BSF_DEBUGGING_RELOC is also set. */
33318 +#define BSF_DEBUGGING 0x08
33320 + /* The symbol denotes a function entry point. Used in ELF,
33321 + perhaps others someday. */
33322 +#define BSF_FUNCTION 0x10
33324 + /* Used by the linker. */
33325 +#define BSF_KEEP 0x20
33326 +#define BSF_KEEP_G 0x40
33328 + /* A weak global symbol, overridable without warnings by
33329 + a regular global symbol of the same name. */
33330 +#define BSF_WEAK 0x80
33332 + /* This symbol was created to point to a section, e.g. ELF's
33333 + STT_SECTION symbols. */
33334 +#define BSF_SECTION_SYM 0x100
33336 + /* The symbol used to be a common symbol, but now it is
33338 +#define BSF_OLD_COMMON 0x200
33340 + /* The default value for common data. */
33341 +#define BFD_FORT_COMM_DEFAULT_VALUE 0
33343 + /* In some files the type of a symbol sometimes alters its
33344 + location in an output file - ie in coff a <<ISFCN>> symbol
33345 + which is also <<C_EXT>> symbol appears where it was
33346 + declared and not at the end of a section. This bit is set
33347 + by the target BFD part to convey this information. */
33348 +#define BSF_NOT_AT_END 0x400
33350 + /* Signal that the symbol is the label of constructor section. */
33351 +#define BSF_CONSTRUCTOR 0x800
33353 + /* Signal that the symbol is a warning symbol. The name is a
33354 + warning. The name of the next symbol is the one to warn about;
33355 + if a reference is made to a symbol with the same name as the next
33356 + symbol, a warning is issued by the linker. */
33357 +#define BSF_WARNING 0x1000
33359 + /* Signal that the symbol is indirect. This symbol is an indirect
33360 + pointer to the symbol with the same name as the next symbol. */
33361 +#define BSF_INDIRECT 0x2000
33363 + /* BSF_FILE marks symbols that contain a file name. This is used
33364 + for ELF STT_FILE symbols. */
33365 +#define BSF_FILE 0x4000
33367 + /* Symbol is from dynamic linking information. */
33368 +#define BSF_DYNAMIC 0x8000
33370 + /* The symbol denotes a data object. Used in ELF, and perhaps
33371 + others someday. */
33372 +#define BSF_OBJECT 0x10000
33374 + /* This symbol is a debugging symbol. The value is the offset
33375 + into the section of the data. BSF_DEBUGGING should be set
33377 +#define BSF_DEBUGGING_RELOC 0x20000
33379 + /* This symbol is thread local. Used in ELF. */
33380 +#define BSF_THREAD_LOCAL 0x40000
33384 + /* A pointer to the section to which this symbol is
33385 + relative. This will always be non NULL, there are special
33386 + sections for undefined and absolute symbols. */
33387 + struct bfd_section *section;
33389 + /* Back end special data. */
33399 +#define bfd_get_symtab_upper_bound(abfd) \
33400 + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
33402 +bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym);
33404 +bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name);
33406 +#define bfd_is_local_label_name(abfd, name) \
33407 + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
33409 +bfd_boolean bfd_is_target_special_symbol (bfd *abfd, asymbol *sym);
33411 +#define bfd_is_target_special_symbol(abfd, sym) \
33412 + BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym))
33414 +#define bfd_canonicalize_symtab(abfd, location) \
33415 + BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location))
33417 +bfd_boolean bfd_set_symtab
33418 + (bfd *abfd, asymbol **location, unsigned int count);
33420 +void bfd_print_symbol_vandf (bfd *abfd, void *file, asymbol *symbol);
33422 +#define bfd_make_empty_symbol(abfd) \
33423 + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
33425 +asymbol *_bfd_generic_make_empty_symbol (bfd *);
33427 +#define bfd_make_debug_symbol(abfd,ptr,size) \
33428 + BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
33430 +int bfd_decode_symclass (asymbol *symbol);
33432 +bfd_boolean bfd_is_undefined_symclass (int symclass);
33434 +void bfd_symbol_info (asymbol *symbol, symbol_info *ret);
33436 +bfd_boolean bfd_copy_private_symbol_data
33437 + (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
33439 +#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
33440 + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \
33441 + (ibfd, isymbol, obfd, osymbol))
33443 +/* Extracted from bfd.c. */
33446 + /* A unique identifier of the BFD */
33449 + /* The filename the application opened the BFD with. */
33450 + const char *filename;
33452 + /* A pointer to the target jump table. */
33453 + const struct bfd_target *xvec;
33455 + /* The IOSTREAM, and corresponding IO vector that provide access
33456 + to the file backing the BFD. */
33458 + const struct bfd_iovec *iovec;
33460 + /* Is the file descriptor being cached? That is, can it be closed as
33461 + needed, and re-opened when accessed later? */
33462 + bfd_boolean cacheable;
33464 + /* Marks whether there was a default target specified when the
33465 + BFD was opened. This is used to select which matching algorithm
33466 + to use to choose the back end. */
33467 + bfd_boolean target_defaulted;
33469 + /* The caching routines use these to maintain a
33470 + least-recently-used list of BFDs. */
33471 + struct bfd *lru_prev, *lru_next;
33473 + /* When a file is closed by the caching routines, BFD retains
33474 + state information on the file here... */
33477 + /* ... and here: (``once'' means at least once). */
33478 + bfd_boolean opened_once;
33480 + /* Set if we have a locally maintained mtime value, rather than
33481 + getting it from the file each time. */
33482 + bfd_boolean mtime_set;
33484 + /* File modified time, if mtime_set is TRUE. */
33487 + /* Reserved for an unimplemented file locking extension. */
33490 + /* The format which belongs to the BFD. (object, core, etc.) */
33491 + bfd_format format;
33493 + /* The direction with which the BFD was opened. */
33494 + enum bfd_direction
33496 + no_direction = 0,
33497 + read_direction = 1,
33498 + write_direction = 2,
33499 + both_direction = 3
33503 + /* Format_specific flags. */
33506 + /* Currently my_archive is tested before adding origin to
33507 + anything. I believe that this can become always an add of
33508 + origin, with origin set to 0 for non archive files. */
33509 + ufile_ptr origin;
33511 + /* Remember when output has begun, to stop strange things
33512 + from happening. */
33513 + bfd_boolean output_has_begun;
33515 + /* A hash table for section names. */
33516 + struct bfd_hash_table section_htab;
33518 + /* Pointer to linked list of sections. */
33519 + struct bfd_section *sections;
33521 + /* The last section on the section list. */
33522 + struct bfd_section *section_last;
33524 + /* The number of sections. */
33525 + unsigned int section_count;
33527 + /* Stuff only useful for object files:
33528 + The start address. */
33529 + bfd_vma start_address;
33531 + /* Used for input and output. */
33532 + unsigned int symcount;
33534 + /* Symbol table for output BFD (with symcount entries). */
33535 + struct bfd_symbol **outsymbols;
33537 + /* Used for slurped dynamic symbol tables. */
33538 + unsigned int dynsymcount;
33540 + /* Pointer to structure which contains architecture information. */
33541 + const struct bfd_arch_info *arch_info;
33543 + /* Flag set if symbols from this BFD should not be exported. */
33544 + bfd_boolean no_export;
33546 + /* Stuff only useful for archives. */
33547 + void *arelt_data;
33548 + struct bfd *my_archive; /* The containing archive BFD. */
33549 + struct bfd *next; /* The next BFD in the archive. */
33550 + struct bfd *archive_head; /* The first BFD in the archive. */
33551 + bfd_boolean has_armap;
33553 + /* A chain of BFD structures involved in a link. */
33554 + struct bfd *link_next;
33556 + /* A field used by _bfd_generic_link_add_archive_symbols. This will
33557 + be used only for archive elements. */
33558 + int archive_pass;
33560 + /* Used by the back end to hold private data. */
33563 + struct aout_data_struct *aout_data;
33564 + struct artdata *aout_ar_data;
33565 + struct _oasys_data *oasys_obj_data;
33566 + struct _oasys_ar_data *oasys_ar_data;
33567 + struct coff_tdata *coff_obj_data;
33568 + struct pe_tdata *pe_obj_data;
33569 + struct xcoff_tdata *xcoff_obj_data;
33570 + struct ecoff_tdata *ecoff_obj_data;
33571 + struct ieee_data_struct *ieee_data;
33572 + struct ieee_ar_data_struct *ieee_ar_data;
33573 + struct srec_data_struct *srec_data;
33574 + struct ihex_data_struct *ihex_data;
33575 + struct tekhex_data_struct *tekhex_data;
33576 + struct elf_obj_tdata *elf_obj_data;
33577 + struct nlm_obj_tdata *nlm_obj_data;
33578 + struct bout_data_struct *bout_data;
33579 + struct mmo_data_struct *mmo_data;
33580 + struct sun_core_struct *sun_core_data;
33581 + struct sco5_core_struct *sco5_core_data;
33582 + struct trad_core_struct *trad_core_data;
33583 + struct som_data_struct *som_data;
33584 + struct hpux_core_struct *hpux_core_data;
33585 + struct hppabsd_core_struct *hppabsd_core_data;
33586 + struct sgi_core_struct *sgi_core_data;
33587 + struct lynx_core_struct *lynx_core_data;
33588 + struct osf_core_struct *osf_core_data;
33589 + struct cisco_core_struct *cisco_core_data;
33590 + struct versados_data_struct *versados_data;
33591 + struct netbsd_core_struct *netbsd_core_data;
33592 + struct mach_o_data_struct *mach_o_data;
33593 + struct mach_o_fat_data_struct *mach_o_fat_data;
33594 + struct bfd_pef_data_struct *pef_data;
33595 + struct bfd_pef_xlib_data_struct *pef_xlib_data;
33596 + struct bfd_sym_data_struct *sym_data;
33601 + /* Used by the application to hold private data. */
33604 + /* Where all the allocated stuff under this BFD goes. This is a
33605 + struct objalloc *, but we use void * to avoid requiring the inclusion
33606 + of objalloc.h. */
33610 +typedef enum bfd_error
33612 + bfd_error_no_error = 0,
33613 + bfd_error_system_call,
33614 + bfd_error_invalid_target,
33615 + bfd_error_wrong_format,
33616 + bfd_error_wrong_object_format,
33617 + bfd_error_invalid_operation,
33618 + bfd_error_no_memory,
33619 + bfd_error_no_symbols,
33620 + bfd_error_no_armap,
33621 + bfd_error_no_more_archived_files,
33622 + bfd_error_malformed_archive,
33623 + bfd_error_file_not_recognized,
33624 + bfd_error_file_ambiguously_recognized,
33625 + bfd_error_no_contents,
33626 + bfd_error_nonrepresentable_section,
33627 + bfd_error_no_debug_section,
33628 + bfd_error_bad_value,
33629 + bfd_error_file_truncated,
33630 + bfd_error_file_too_big,
33631 + bfd_error_invalid_error_code
33635 +bfd_error_type bfd_get_error (void);
33637 +void bfd_set_error (bfd_error_type error_tag);
33639 +const char *bfd_errmsg (bfd_error_type error_tag);
33641 +void bfd_perror (const char *message);
33643 +typedef void (*bfd_error_handler_type) (const char *, ...);
33645 +bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
33647 +void bfd_set_error_program_name (const char *);
33649 +bfd_error_handler_type bfd_get_error_handler (void);
33651 +long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect);
33653 +long bfd_canonicalize_reloc
33654 + (bfd *abfd, asection *sec, arelent **loc, asymbol **syms);
33656 +void bfd_set_reloc
33657 + (bfd *abfd, asection *sec, arelent **rel, unsigned int count);
33659 +bfd_boolean bfd_set_file_flags (bfd *abfd, flagword flags);
33661 +int bfd_get_arch_size (bfd *abfd);
33663 +int bfd_get_sign_extend_vma (bfd *abfd);
33665 +bfd_boolean bfd_set_start_address (bfd *abfd, bfd_vma vma);
33667 +unsigned int bfd_get_gp_size (bfd *abfd);
33669 +void bfd_set_gp_size (bfd *abfd, unsigned int i);
33671 +bfd_vma bfd_scan_vma (const char *string, const char **end, int base);
33673 +bfd_boolean bfd_copy_private_header_data (bfd *ibfd, bfd *obfd);
33675 +#define bfd_copy_private_header_data(ibfd, obfd) \
33676 + BFD_SEND (obfd, _bfd_copy_private_header_data, \
33678 +bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd);
33680 +#define bfd_copy_private_bfd_data(ibfd, obfd) \
33681 + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \
33683 +bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
33685 +#define bfd_merge_private_bfd_data(ibfd, obfd) \
33686 + BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
33688 +bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags);
33690 +#define bfd_set_private_flags(abfd, flags) \
33691 + BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags))
33692 +#define bfd_sizeof_headers(abfd, reloc) \
33693 + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
33695 +#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
33696 + BFD_SEND (abfd, _bfd_find_nearest_line, \
33697 + (abfd, sec, syms, off, file, func, line))
33699 +#define bfd_find_line(abfd, syms, sym, file, line) \
33700 + BFD_SEND (abfd, _bfd_find_line, \
33701 + (abfd, syms, sym, file, line))
33703 +#define bfd_find_inliner_info(abfd, file, func, line) \
33704 + BFD_SEND (abfd, _bfd_find_inliner_info, \
33705 + (abfd, file, func, line))
33707 +#define bfd_debug_info_start(abfd) \
33708 + BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
33710 +#define bfd_debug_info_end(abfd) \
33711 + BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
33713 +#define bfd_debug_info_accumulate(abfd, section) \
33714 + BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
33716 +#define bfd_stat_arch_elt(abfd, stat) \
33717 + BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
33719 +#define bfd_update_armap_timestamp(abfd) \
33720 + BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
33722 +#define bfd_set_arch_mach(abfd, arch, mach)\
33723 + BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
33725 +#define bfd_relax_section(abfd, section, link_info, again) \
33726 + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
33728 +#define bfd_gc_sections(abfd, link_info) \
33729 + BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
33731 +#define bfd_merge_sections(abfd, link_info) \
33732 + BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
33734 +#define bfd_is_group_section(abfd, sec) \
33735 + BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec))
33737 +#define bfd_discard_group(abfd, sec) \
33738 + BFD_SEND (abfd, _bfd_discard_group, (abfd, sec))
33740 +#define bfd_link_hash_table_create(abfd) \
33741 + BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
33743 +#define bfd_link_hash_table_free(abfd, hash) \
33744 + BFD_SEND (abfd, _bfd_link_hash_table_free, (hash))
33746 +#define bfd_link_add_symbols(abfd, info) \
33747 + BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
33749 +#define bfd_link_just_syms(abfd, sec, info) \
33750 + BFD_SEND (abfd, _bfd_link_just_syms, (sec, info))
33752 +#define bfd_final_link(abfd, info) \
33753 + BFD_SEND (abfd, _bfd_final_link, (abfd, info))
33755 +#define bfd_free_cached_info(abfd) \
33756 + BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
33758 +#define bfd_get_dynamic_symtab_upper_bound(abfd) \
33759 + BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
33761 +#define bfd_print_private_bfd_data(abfd, file)\
33762 + BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
33764 +#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
33765 + BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
33767 +#define bfd_get_synthetic_symtab(abfd, count, syms, dyncount, dynsyms, ret) \
33768 + BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, count, syms, \
33769 + dyncount, dynsyms, ret))
33771 +#define bfd_get_dynamic_reloc_upper_bound(abfd) \
33772 + BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
33774 +#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
33775 + BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
33777 +extern bfd_byte *bfd_get_relocated_section_contents
33778 + (bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *,
33779 + bfd_boolean, asymbol **);
33781 +bfd_boolean bfd_alt_mach_code (bfd *abfd, int alternative);
33783 +struct bfd_preserve
33788 + const struct bfd_arch_info *arch_info;
33789 + struct bfd_section *sections;
33790 + struct bfd_section *section_last;
33791 + unsigned int section_count;
33792 + struct bfd_hash_table section_htab;
33795 +bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
33797 +void bfd_preserve_restore (bfd *, struct bfd_preserve *);
33799 +void bfd_preserve_finish (bfd *, struct bfd_preserve *);
33801 +/* Extracted from archive.c. */
33802 +symindex bfd_get_next_mapent
33803 + (bfd *abfd, symindex previous, carsym **sym);
33805 +bfd_boolean bfd_set_archive_head (bfd *output, bfd *new_head);
33807 +bfd *bfd_openr_next_archived_file (bfd *archive, bfd *previous);
33809 +/* Extracted from corefile.c. */
33810 +const char *bfd_core_file_failing_command (bfd *abfd);
33812 +int bfd_core_file_failing_signal (bfd *abfd);
33814 +bfd_boolean core_file_matches_executable_p
33815 + (bfd *core_bfd, bfd *exec_bfd);
33817 +/* Extracted from targets.c. */
33818 +#define BFD_SEND(bfd, message, arglist) \
33819 + ((*((bfd)->xvec->message)) arglist)
33821 +#ifdef DEBUG_BFD_SEND
33823 +#define BFD_SEND(bfd, message, arglist) \
33824 + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
33825 + ((*((bfd)->xvec->message)) arglist) : \
33826 + (bfd_assert (__FILE__,__LINE__), NULL))
33828 +#define BFD_SEND_FMT(bfd, message, arglist) \
33829 + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist)
33831 +#ifdef DEBUG_BFD_SEND
33832 +#undef BFD_SEND_FMT
33833 +#define BFD_SEND_FMT(bfd, message, arglist) \
33834 + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
33835 + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
33836 + (bfd_assert (__FILE__,__LINE__), NULL))
33841 + bfd_target_unknown_flavour,
33842 + bfd_target_aout_flavour,
33843 + bfd_target_coff_flavour,
33844 + bfd_target_ecoff_flavour,
33845 + bfd_target_xcoff_flavour,
33846 + bfd_target_elf_flavour,
33847 + bfd_target_ieee_flavour,
33848 + bfd_target_nlm_flavour,
33849 + bfd_target_oasys_flavour,
33850 + bfd_target_tekhex_flavour,
33851 + bfd_target_srec_flavour,
33852 + bfd_target_ihex_flavour,
33853 + bfd_target_som_flavour,
33854 + bfd_target_os9k_flavour,
33855 + bfd_target_versados_flavour,
33856 + bfd_target_msdos_flavour,
33857 + bfd_target_ovax_flavour,
33858 + bfd_target_evax_flavour,
33859 + bfd_target_mmo_flavour,
33860 + bfd_target_mach_o_flavour,
33861 + bfd_target_pef_flavour,
33862 + bfd_target_pef_xlib_flavour,
33863 + bfd_target_sym_flavour
33866 +enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
33868 +/* Forward declaration. */
33869 +typedef struct bfd_link_info _bfd_link_info;
33871 +typedef struct bfd_target
33873 + /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. */
33876 + /* The "flavour" of a back end is a general indication about
33877 + the contents of a file. */
33878 + enum bfd_flavour flavour;
33880 + /* The order of bytes within the data area of a file. */
33881 + enum bfd_endian byteorder;
33883 + /* The order of bytes within the header parts of a file. */
33884 + enum bfd_endian header_byteorder;
33886 + /* A mask of all the flags which an executable may have set -
33887 + from the set <<BFD_NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>. */
33888 + flagword object_flags;
33890 + /* A mask of all the flags which a section may have set - from
33891 + the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>. */
33892 + flagword section_flags;
33894 + /* The character normally found at the front of a symbol.
33895 + (if any), perhaps `_'. */
33896 + char symbol_leading_char;
33898 + /* The pad character for file names within an archive header. */
33899 + char ar_pad_char;
33901 + /* The maximum number of characters in an archive header. */
33902 + unsigned short ar_max_namelen;
33904 + /* Entries for byte swapping for data. These are different from the
33905 + other entry points, since they don't take a BFD as the first argument.
33906 + Certain other handlers could do the same. */
33907 + bfd_uint64_t (*bfd_getx64) (const void *);
33908 + bfd_int64_t (*bfd_getx_signed_64) (const void *);
33909 + void (*bfd_putx64) (bfd_uint64_t, void *);
33910 + bfd_vma (*bfd_getx32) (const void *);
33911 + bfd_signed_vma (*bfd_getx_signed_32) (const void *);
33912 + void (*bfd_putx32) (bfd_vma, void *);
33913 + bfd_vma (*bfd_getx16) (const void *);
33914 + bfd_signed_vma (*bfd_getx_signed_16) (const void *);
33915 + void (*bfd_putx16) (bfd_vma, void *);
33917 + /* Byte swapping for the headers. */
33918 + bfd_uint64_t (*bfd_h_getx64) (const void *);
33919 + bfd_int64_t (*bfd_h_getx_signed_64) (const void *);
33920 + void (*bfd_h_putx64) (bfd_uint64_t, void *);
33921 + bfd_vma (*bfd_h_getx32) (const void *);
33922 + bfd_signed_vma (*bfd_h_getx_signed_32) (const void *);
33923 + void (*bfd_h_putx32) (bfd_vma, void *);
33924 + bfd_vma (*bfd_h_getx16) (const void *);
33925 + bfd_signed_vma (*bfd_h_getx_signed_16) (const void *);
33926 + void (*bfd_h_putx16) (bfd_vma, void *);
33928 + /* Format dependent routines: these are vectors of entry points
33929 + within the target vector structure, one for each format to check. */
33931 + /* Check the format of a file being read. Return a <<bfd_target *>> or zero. */
33932 + const struct bfd_target *(*_bfd_check_format[bfd_type_end]) (bfd *);
33934 + /* Set the format of a file being written. */
33935 + bfd_boolean (*_bfd_set_format[bfd_type_end]) (bfd *);
33937 + /* Write cached information into a file being written, at <<bfd_close>>. */
33938 + bfd_boolean (*_bfd_write_contents[bfd_type_end]) (bfd *);
33941 + /* Generic entry points. */
33942 +#define BFD_JUMP_TABLE_GENERIC(NAME) \
33943 + NAME##_close_and_cleanup, \
33944 + NAME##_bfd_free_cached_info, \
33945 + NAME##_new_section_hook, \
33946 + NAME##_get_section_contents, \
33947 + NAME##_get_section_contents_in_window
33949 + /* Called when the BFD is being closed to do any necessary cleanup. */
33950 + bfd_boolean (*_close_and_cleanup) (bfd *);
33951 + /* Ask the BFD to free all cached information. */
33952 + bfd_boolean (*_bfd_free_cached_info) (bfd *);
33953 + /* Called when a new section is created. */
33954 + bfd_boolean (*_new_section_hook) (bfd *, sec_ptr);
33955 + /* Read the contents of a section. */
33956 + bfd_boolean (*_bfd_get_section_contents)
33957 + (bfd *, sec_ptr, void *, file_ptr, bfd_size_type);
33958 + bfd_boolean (*_bfd_get_section_contents_in_window)
33959 + (bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type);
33961 + /* Entry points to copy private data. */
33962 +#define BFD_JUMP_TABLE_COPY(NAME) \
33963 + NAME##_bfd_copy_private_bfd_data, \
33964 + NAME##_bfd_merge_private_bfd_data, \
33965 + NAME##_bfd_copy_private_section_data, \
33966 + NAME##_bfd_copy_private_symbol_data, \
33967 + NAME##_bfd_copy_private_header_data, \
33968 + NAME##_bfd_set_private_flags, \
33969 + NAME##_bfd_print_private_bfd_data
33971 + /* Called to copy BFD general private data from one object file
33973 + bfd_boolean (*_bfd_copy_private_bfd_data) (bfd *, bfd *);
33974 + /* Called to merge BFD general private data from one object file
33975 + to a common output file when linking. */
33976 + bfd_boolean (*_bfd_merge_private_bfd_data) (bfd *, bfd *);
33977 + /* Called to copy BFD private section data from one object file
33979 + bfd_boolean (*_bfd_copy_private_section_data)
33980 + (bfd *, sec_ptr, bfd *, sec_ptr);
33981 + /* Called to copy BFD private symbol data from one symbol
33983 + bfd_boolean (*_bfd_copy_private_symbol_data)
33984 + (bfd *, asymbol *, bfd *, asymbol *);
33985 + /* Called to copy BFD private header data from one object file
33987 + bfd_boolean (*_bfd_copy_private_header_data)
33989 + /* Called to set private backend flags. */
33990 + bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword);
33992 + /* Called to print private BFD data. */
33993 + bfd_boolean (*_bfd_print_private_bfd_data) (bfd *, void *);
33995 + /* Core file entry points. */
33996 +#define BFD_JUMP_TABLE_CORE(NAME) \
33997 + NAME##_core_file_failing_command, \
33998 + NAME##_core_file_failing_signal, \
33999 + NAME##_core_file_matches_executable_p
34001 + char * (*_core_file_failing_command) (bfd *);
34002 + int (*_core_file_failing_signal) (bfd *);
34003 + bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *);
34005 + /* Archive entry points. */
34006 +#define BFD_JUMP_TABLE_ARCHIVE(NAME) \
34007 + NAME##_slurp_armap, \
34008 + NAME##_slurp_extended_name_table, \
34009 + NAME##_construct_extended_name_table, \
34010 + NAME##_truncate_arname, \
34011 + NAME##_write_armap, \
34012 + NAME##_read_ar_hdr, \
34013 + NAME##_openr_next_archived_file, \
34014 + NAME##_get_elt_at_index, \
34015 + NAME##_generic_stat_arch_elt, \
34016 + NAME##_update_armap_timestamp
34018 + bfd_boolean (*_bfd_slurp_armap) (bfd *);
34019 + bfd_boolean (*_bfd_slurp_extended_name_table) (bfd *);
34020 + bfd_boolean (*_bfd_construct_extended_name_table)
34021 + (bfd *, char **, bfd_size_type *, const char **);
34022 + void (*_bfd_truncate_arname) (bfd *, const char *, char *);
34023 + bfd_boolean (*write_armap)
34024 + (bfd *, unsigned int, struct orl *, unsigned int, int);
34025 + void * (*_bfd_read_ar_hdr_fn) (bfd *);
34026 + bfd * (*openr_next_archived_file) (bfd *, bfd *);
34027 +#define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i))
34028 + bfd * (*_bfd_get_elt_at_index) (bfd *, symindex);
34029 + int (*_bfd_stat_arch_elt) (bfd *, struct stat *);
34030 + bfd_boolean (*_bfd_update_armap_timestamp) (bfd *);
34032 + /* Entry points used for symbols. */
34033 +#define BFD_JUMP_TABLE_SYMBOLS(NAME) \
34034 + NAME##_get_symtab_upper_bound, \
34035 + NAME##_canonicalize_symtab, \
34036 + NAME##_make_empty_symbol, \
34037 + NAME##_print_symbol, \
34038 + NAME##_get_symbol_info, \
34039 + NAME##_bfd_is_local_label_name, \
34040 + NAME##_bfd_is_target_special_symbol, \
34041 + NAME##_get_lineno, \
34042 + NAME##_find_nearest_line, \
34043 + _bfd_generic_find_line, \
34044 + NAME##_find_inliner_info, \
34045 + NAME##_bfd_make_debug_symbol, \
34046 + NAME##_read_minisymbols, \
34047 + NAME##_minisymbol_to_symbol
34049 + long (*_bfd_get_symtab_upper_bound) (bfd *);
34050 + long (*_bfd_canonicalize_symtab)
34051 + (bfd *, struct bfd_symbol **);
34052 + struct bfd_symbol *
34053 + (*_bfd_make_empty_symbol) (bfd *);
34054 + void (*_bfd_print_symbol)
34055 + (bfd *, void *, struct bfd_symbol *, bfd_print_symbol_type);
34056 +#define bfd_print_symbol(b,p,s,e) BFD_SEND (b, _bfd_print_symbol, (b,p,s,e))
34057 + void (*_bfd_get_symbol_info)
34058 + (bfd *, struct bfd_symbol *, symbol_info *);
34059 +#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
34060 + bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
34061 + bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
34062 + alent * (*_get_lineno) (bfd *, struct bfd_symbol *);
34063 + bfd_boolean (*_bfd_find_nearest_line)
34064 + (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma,
34065 + const char **, const char **, unsigned int *);
34066 + bfd_boolean (*_bfd_find_line)
34067 + (bfd *, struct bfd_symbol **, struct bfd_symbol *,
34068 + const char **, unsigned int *);
34069 + bfd_boolean (*_bfd_find_inliner_info)
34070 + (bfd *, const char **, const char **, unsigned int *);
34071 + /* Back-door to allow format-aware applications to create debug symbols
34072 + while using BFD for everything else. Currently used by the assembler
34073 + when creating COFF files. */
34074 + asymbol * (*_bfd_make_debug_symbol)
34075 + (bfd *, void *, unsigned long size);
34076 +#define bfd_read_minisymbols(b, d, m, s) \
34077 + BFD_SEND (b, _read_minisymbols, (b, d, m, s))
34078 + long (*_read_minisymbols)
34079 + (bfd *, bfd_boolean, void **, unsigned int *);
34080 +#define bfd_minisymbol_to_symbol(b, d, m, f) \
34081 + BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
34082 + asymbol * (*_minisymbol_to_symbol)
34083 + (bfd *, bfd_boolean, const void *, asymbol *);
34085 + /* Routines for relocs. */
34086 +#define BFD_JUMP_TABLE_RELOCS(NAME) \
34087 + NAME##_get_reloc_upper_bound, \
34088 + NAME##_canonicalize_reloc, \
34089 + NAME##_bfd_reloc_type_lookup
34091 + long (*_get_reloc_upper_bound) (bfd *, sec_ptr);
34092 + long (*_bfd_canonicalize_reloc)
34093 + (bfd *, sec_ptr, arelent **, struct bfd_symbol **);
34094 + /* See documentation on reloc types. */
34095 + reloc_howto_type *
34096 + (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
34098 + /* Routines used when writing an object file. */
34099 +#define BFD_JUMP_TABLE_WRITE(NAME) \
34100 + NAME##_set_arch_mach, \
34101 + NAME##_set_section_contents
34103 + bfd_boolean (*_bfd_set_arch_mach)
34104 + (bfd *, enum bfd_architecture, unsigned long);
34105 + bfd_boolean (*_bfd_set_section_contents)
34106 + (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
34108 + /* Routines used by the linker. */
34109 +#define BFD_JUMP_TABLE_LINK(NAME) \
34110 + NAME##_sizeof_headers, \
34111 + NAME##_bfd_get_relocated_section_contents, \
34112 + NAME##_bfd_relax_section, \
34113 + NAME##_bfd_link_hash_table_create, \
34114 + NAME##_bfd_link_hash_table_free, \
34115 + NAME##_bfd_link_add_symbols, \
34116 + NAME##_bfd_link_just_syms, \
34117 + NAME##_bfd_final_link, \
34118 + NAME##_bfd_link_split_section, \
34119 + NAME##_bfd_gc_sections, \
34120 + NAME##_bfd_merge_sections, \
34121 + NAME##_bfd_is_group_section, \
34122 + NAME##_bfd_discard_group, \
34123 + NAME##_section_already_linked \
34125 + int (*_bfd_sizeof_headers) (bfd *, bfd_boolean);
34126 + bfd_byte * (*_bfd_get_relocated_section_contents)
34127 + (bfd *, struct bfd_link_info *, struct bfd_link_order *,
34128 + bfd_byte *, bfd_boolean, struct bfd_symbol **);
34130 + bfd_boolean (*_bfd_relax_section)
34131 + (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *);
34133 + /* Create a hash table for the linker. Different backends store
34134 + different information in this table. */
34135 + struct bfd_link_hash_table *
34136 + (*_bfd_link_hash_table_create) (bfd *);
34138 + /* Release the memory associated with the linker hash table. */
34139 + void (*_bfd_link_hash_table_free) (struct bfd_link_hash_table *);
34141 + /* Add symbols from this object file into the hash table. */
34142 + bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *);
34144 + /* Indicate that we are only retrieving symbol values from this section. */
34145 + void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *);
34147 + /* Do a link based on the link_order structures attached to each
34148 + section of the BFD. */
34149 + bfd_boolean (*_bfd_final_link) (bfd *, struct bfd_link_info *);
34151 + /* Should this section be split up into smaller pieces during linking. */
34152 + bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *);
34154 + /* Remove sections that are not referenced from the output. */
34155 + bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
34157 + /* Attempt to merge SEC_MERGE sections. */
34158 + bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
34160 + /* Is this section a member of a group? */
34161 + bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *);
34163 + /* Discard members of a group. */
34164 + bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *);
34166 + /* Check if SEC has been already linked during a reloceatable or
34168 + void (*_section_already_linked) (bfd *, struct bfd_section *);
34170 + /* Routines to handle dynamic symbols and relocs. */
34171 +#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
34172 + NAME##_get_dynamic_symtab_upper_bound, \
34173 + NAME##_canonicalize_dynamic_symtab, \
34174 + NAME##_get_synthetic_symtab, \
34175 + NAME##_get_dynamic_reloc_upper_bound, \
34176 + NAME##_canonicalize_dynamic_reloc
34178 + /* Get the amount of memory required to hold the dynamic symbols. */
34179 + long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *);
34180 + /* Read in the dynamic symbols. */
34181 + long (*_bfd_canonicalize_dynamic_symtab)
34182 + (bfd *, struct bfd_symbol **);
34183 + /* Create synthetized symbols. */
34184 + long (*_bfd_get_synthetic_symtab)
34185 + (bfd *, long, struct bfd_symbol **, long, struct bfd_symbol **,
34186 + struct bfd_symbol **);
34187 + /* Get the amount of memory required to hold the dynamic relocs. */
34188 + long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *);
34189 + /* Read in the dynamic relocs. */
34190 + long (*_bfd_canonicalize_dynamic_reloc)
34191 + (bfd *, arelent **, struct bfd_symbol **);
34193 + /* Opposite endian version of this target. */
34194 + const struct bfd_target * alternative_target;
34196 + /* Data for use by back-end routines, which isn't
34197 + generic enough to belong in this structure. */
34198 + const void *backend_data;
34202 +bfd_boolean bfd_set_default_target (const char *name);
34204 +const bfd_target *bfd_find_target (const char *target_name, bfd *abfd);
34206 +const char ** bfd_target_list (void);
34208 +const bfd_target *bfd_search_for_target
34209 + (int (*search_func) (const bfd_target *, void *),
34212 +/* Extracted from format.c. */
34213 +bfd_boolean bfd_check_format (bfd *abfd, bfd_format format);
34215 +bfd_boolean bfd_check_format_matches
34216 + (bfd *abfd, bfd_format format, char ***matching);
34218 +bfd_boolean bfd_set_format (bfd *abfd, bfd_format format);
34220 +const char *bfd_format_string (bfd_format format);
34222 +/* Extracted from linker.c. */
34223 +bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec);
34225 +#define bfd_link_split_section(abfd, sec) \
34226 + BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))
34228 +void bfd_section_already_linked (bfd *abfd, asection *sec);
34230 +#define bfd_section_already_linked(abfd, sec) \
34231 + BFD_SEND (abfd, _section_already_linked, (abfd, sec))
34233 +/* Extracted from simple.c. */
34234 +bfd_byte *bfd_simple_get_relocated_section_contents
34235 + (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table);
34237 +#ifdef __cplusplus
34241 diff -Nurp linux-2.6.22-590/include/asm-x86_64/hw_irq.h linux-2.6.22-600/include/asm-x86_64/hw_irq.h
34242 --- linux-2.6.22-590/include/asm-x86_64/hw_irq.h 2007-07-09 01:32:17.000000000 +0200
34243 +++ linux-2.6.22-600/include/asm-x86_64/hw_irq.h 2008-04-09 18:16:24.000000000 +0200
34245 #define FIRST_EXTERNAL_VECTOR 0x20
34247 #define IA32_SYSCALL_VECTOR 0x80
34249 +#define KDBENTER_VECTOR 0x81
34251 /* Reserve the lowest usable priority level 0x20 - 0x2f for triggering
34252 * cleanup after irq migration.
34254 #define ERROR_APIC_VECTOR 0xfe
34255 #define RESCHEDULE_VECTOR 0xfd
34256 #define CALL_FUNCTION_VECTOR 0xfc
34257 -/* fb free - please don't readd KDB here because it's useless
34258 - (hint - think what a NMI bit does to a vector) */
34259 +#define KDB_VECTOR 0xfb
34260 #define THERMAL_APIC_VECTOR 0xfa
34261 #define THRESHOLD_APIC_VECTOR 0xf9
34263 diff -Nurp linux-2.6.22-590/include/asm-x86_64/kdb.h linux-2.6.22-600/include/asm-x86_64/kdb.h
34264 --- linux-2.6.22-590/include/asm-x86_64/kdb.h 1970-01-01 01:00:00.000000000 +0100
34265 +++ linux-2.6.22-600/include/asm-x86_64/kdb.h 2008-04-09 18:16:24.000000000 +0200
34267 +#ifndef _ASM_KDB_H
34268 +#define _ASM_KDB_H
34271 + * Kernel Debugger Architecture Dependent Global Headers
34273 + * This file is subject to the terms and conditions of the GNU General Public
34274 + * License. See the file "COPYING" in the main directory of this archive
34275 + * for more details.
34277 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
34281 + * KDB_ENTER() is a macro which causes entry into the kernel
34282 + * debugger from any point in the kernel code stream. If it
34283 + * is intended to be used from interrupt level, it must use
34284 + * a non-maskable entry method. The vector is KDB_VECTOR,
34285 + * defined in hw_irq.h
34287 +#define KDB_ENTER() do {if (kdb_on && !KDB_IS_RUNNING()) { asm("\tint $129\n"); }} while(0)
34290 + * Needed for exported symbols.
34292 +typedef unsigned long kdb_machreg_t;
34294 +#define kdb_machreg_fmt "0x%lx"
34295 +#define kdb_machreg_fmt0 "0x%016lx"
34296 +#define kdb_bfd_vma_fmt "0x%lx"
34297 +#define kdb_bfd_vma_fmt0 "0x%016lx"
34298 +#define kdb_elfw_addr_fmt "0x%x"
34299 +#define kdb_elfw_addr_fmt0 "0x%016x"
34302 + * Per cpu arch specific kdb state. Must be in range 0xff000000.
34304 +#define KDB_STATE_A_IF 0x01000000 /* Saved IF flag */
34307 + * Functions to safely read and write kernel areas. The {to,from}_xxx
34308 + * addresses are not necessarily valid, these functions must check for
34309 + * validity. If the arch already supports get and put routines with
34310 + * suitable validation and/or recovery on invalid addresses then use
34311 + * those routines, otherwise check it yourself.
34315 + * asm-i386 uaccess.h supplies __copy_to_user which relies on MMU to
34316 + * trap invalid addresses in the _xxx fields. Verify the other address
34317 + * of the pair is valid by accessing the first and last byte ourselves,
34318 + * then any access violations should only be caused by the _xxx
34322 +#include <asm/uaccess.h>
34325 +__kdba_putarea_size(unsigned long to_xxx, void *from, size_t size)
34327 + mm_segment_t oldfs = get_fs();
34330 + c = *((volatile char *)from);
34331 + c = *((volatile char *)from + size - 1);
34333 + if (to_xxx < PAGE_OFFSET) {
34334 + return kdb_putuserarea_size(to_xxx, from, size);
34337 + set_fs(KERNEL_DS);
34338 + r = __copy_to_user((void *)to_xxx, from, size);
34344 +__kdba_getarea_size(void *to, unsigned long from_xxx, size_t size)
34346 + mm_segment_t oldfs = get_fs();
34348 + *((volatile char *)to) = '\0';
34349 + *((volatile char *)to + size - 1) = '\0';
34351 + if (from_xxx < PAGE_OFFSET) {
34352 + return kdb_getuserarea_size(to, from_xxx, size);
34355 + set_fs(KERNEL_DS);
34356 + r = __copy_to_user(to, (void *)from_xxx, size);
34361 +/* For numa with replicated code/data, the platform must supply its own
34362 + * kdba_putarea_size and kdba_getarea_size routines. Without replication kdb
34363 + * uses the standard architecture routines.
34365 +#ifdef CONFIG_NUMA_REPLICATE
34366 +extern int kdba_putarea_size(unsigned long to_xxx, void *from, size_t size);
34367 +extern int kdba_getarea_size(void *to, unsigned long from_xxx, size_t size);
34369 +#define kdba_putarea_size __kdba_putarea_size
34370 +#define kdba_getarea_size __kdba_getarea_size
34374 +kdba_verify_rw(unsigned long addr, size_t size)
34376 + unsigned char data[size];
34377 + return(kdba_getarea_size(data, addr, size) || kdba_putarea_size(addr, data, size));
34380 +static inline unsigned long
34381 +kdba_funcptr_value(void *fp)
34383 + return (unsigned long)fp;
34386 +#endif /* !_ASM_KDB_H */
34387 diff -Nurp linux-2.6.22-590/include/asm-x86_64/kdbprivate.h linux-2.6.22-600/include/asm-x86_64/kdbprivate.h
34388 --- linux-2.6.22-590/include/asm-x86_64/kdbprivate.h 1970-01-01 01:00:00.000000000 +0100
34389 +++ linux-2.6.22-600/include/asm-x86_64/kdbprivate.h 2008-04-09 18:16:24.000000000 +0200
34391 +#ifndef _ASM_KDBPRIVATE_H
34392 +#define _ASM_KDBPRIVATE_H
34395 + * Kernel Debugger Architecture Dependent Private Headers
34397 + * This file is subject to the terms and conditions of the GNU General Public
34398 + * License. See the file "COPYING" in the main directory of this archive
34399 + * for more details.
34401 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
34404 +typedef unsigned char kdb_machinst_t;
34407 + * KDB_MAXBPT describes the total number of breakpoints
34408 + * supported by this architecure.
34410 +#define KDB_MAXBPT 16
34413 + * KDB_MAXHARDBPT describes the total number of hardware
34414 + * breakpoint registers that exist.
34416 +#define KDB_MAXHARDBPT 4
34418 +/* Maximum number of arguments to a function */
34419 +#define KDBA_MAXARGS 16
34422 + * Platform specific environment entries
34424 +#define KDB_PLATFORM_ENV "IDMODE=x86_64", "BYTESPERWORD=8", "IDCOUNT=16"
34427 + * Support for ia32 debug registers
34429 +typedef struct _kdbhard_bp {
34430 + kdb_machreg_t bph_reg; /* Register this breakpoint uses */
34432 + unsigned int bph_free:1; /* Register available for use */
34433 + unsigned int bph_data:1; /* Data Access breakpoint */
34435 + unsigned int bph_write:1; /* Write Data breakpoint */
34436 + unsigned int bph_mode:2; /* 0=inst, 1=write, 2=io, 3=read */
34437 + unsigned int bph_length:2; /* 0=1, 1=2, 2=BAD, 3=4 (bytes) */
34440 +extern kdbhard_bp_t kdb_hardbreaks[/* KDB_MAXHARDBPT */];
34442 +#define IA32_BREAKPOINT_INSTRUCTION 0xcc
34444 +#define DR6_BT 0x00008000
34445 +#define DR6_BS 0x00004000
34446 +#define DR6_BD 0x00002000
34448 +#define DR6_B3 0x00000008
34449 +#define DR6_B2 0x00000004
34450 +#define DR6_B1 0x00000002
34451 +#define DR6_B0 0x00000001
34452 +#define DR6_DR_MASK 0x0000000F
34454 +#define DR7_RW_VAL(dr, drnum) \
34455 + (((dr) >> (16 + (4 * (drnum)))) & 0x3)
34457 +#define DR7_RW_SET(dr, drnum, rw) \
34459 + (dr) &= ~(0x3 << (16 + (4 * (drnum)))); \
34460 + (dr) |= (((rw) & 0x3) << (16 + (4 * (drnum)))); \
34463 +#define DR7_RW0(dr) DR7_RW_VAL(dr, 0)
34464 +#define DR7_RW0SET(dr,rw) DR7_RW_SET(dr, 0, rw)
34465 +#define DR7_RW1(dr) DR7_RW_VAL(dr, 1)
34466 +#define DR7_RW1SET(dr,rw) DR7_RW_SET(dr, 1, rw)
34467 +#define DR7_RW2(dr) DR7_RW_VAL(dr, 2)
34468 +#define DR7_RW2SET(dr,rw) DR7_RW_SET(dr, 2, rw)
34469 +#define DR7_RW3(dr) DR7_RW_VAL(dr, 3)
34470 +#define DR7_RW3SET(dr,rw) DR7_RW_SET(dr, 3, rw)
34473 +#define DR7_LEN_VAL(dr, drnum) \
34474 + (((dr) >> (18 + (4 * (drnum)))) & 0x3)
34476 +#define DR7_LEN_SET(dr, drnum, rw) \
34478 + (dr) &= ~(0x3 << (18 + (4 * (drnum)))); \
34479 + (dr) |= (((rw) & 0x3) << (18 + (4 * (drnum)))); \
34481 +#define DR7_LEN0(dr) DR7_LEN_VAL(dr, 0)
34482 +#define DR7_LEN0SET(dr,len) DR7_LEN_SET(dr, 0, len)
34483 +#define DR7_LEN1(dr) DR7_LEN_VAL(dr, 1)
34484 +#define DR7_LEN1SET(dr,len) DR7_LEN_SET(dr, 1, len)
34485 +#define DR7_LEN2(dr) DR7_LEN_VAL(dr, 2)
34486 +#define DR7_LEN2SET(dr,len) DR7_LEN_SET(dr, 2, len)
34487 +#define DR7_LEN3(dr) DR7_LEN_VAL(dr, 3)
34488 +#define DR7_LEN3SET(dr,len) DR7_LEN_SET(dr, 3, len)
34490 +#define DR7_G0(dr) (((dr)>>1)&0x1)
34491 +#define DR7_G0SET(dr) ((dr) |= 0x2)
34492 +#define DR7_G0CLR(dr) ((dr) &= ~0x2)
34493 +#define DR7_G1(dr) (((dr)>>3)&0x1)
34494 +#define DR7_G1SET(dr) ((dr) |= 0x8)
34495 +#define DR7_G1CLR(dr) ((dr) &= ~0x8)
34496 +#define DR7_G2(dr) (((dr)>>5)&0x1)
34497 +#define DR7_G2SET(dr) ((dr) |= 0x20)
34498 +#define DR7_G2CLR(dr) ((dr) &= ~0x20)
34499 +#define DR7_G3(dr) (((dr)>>7)&0x1)
34500 +#define DR7_G3SET(dr) ((dr) |= 0x80)
34501 +#define DR7_G3CLR(dr) ((dr) &= ~0x80)
34503 +#define DR7_L0(dr) (((dr))&0x1)
34504 +#define DR7_L0SET(dr) ((dr) |= 0x1)
34505 +#define DR7_L0CLR(dr) ((dr) &= ~0x1)
34506 +#define DR7_L1(dr) (((dr)>>2)&0x1)
34507 +#define DR7_L1SET(dr) ((dr) |= 0x4)
34508 +#define DR7_L1CLR(dr) ((dr) &= ~0x4)
34509 +#define DR7_L2(dr) (((dr)>>4)&0x1)
34510 +#define DR7_L2SET(dr) ((dr) |= 0x10)
34511 +#define DR7_L2CLR(dr) ((dr) &= ~0x10)
34512 +#define DR7_L3(dr) (((dr)>>6)&0x1)
34513 +#define DR7_L3SET(dr) ((dr) |= 0x40)
34514 +#define DR7_L3CLR(dr) ((dr) &= ~0x40)
34516 +#define DR7_GD 0x00002000 /* General Detect Enable */
34517 +#define DR7_GE 0x00000200 /* Global exact */
34518 +#define DR7_LE 0x00000100 /* Local exact */
34520 +extern kdb_machreg_t kdba_getdr6(void);
34521 +extern void kdba_putdr6(kdb_machreg_t);
34523 +extern kdb_machreg_t kdba_getdr7(void);
34525 +extern kdb_machreg_t kdba_getdr(int);
34526 +extern void kdba_putdr(int, kdb_machreg_t);
34528 +extern kdb_machreg_t kdb_getcr(int);
34531 + * reg indicies for x86_64 setjmp/longjmp
34542 +typedef struct __kdb_jmp_buf {
34543 + unsigned long regs[8]; /* kdba_setjmp assumes fixed offsets here */
34546 +extern int asmlinkage kdba_setjmp(kdb_jmp_buf *);
34547 +extern void asmlinkage kdba_longjmp(kdb_jmp_buf *, int);
34548 +#define kdba_setjmp kdba_setjmp
34550 +extern kdb_jmp_buf *kdbjmpbuf;
34552 +/* Arch specific data saved for running processes */
34554 +struct kdba_running_process {
34555 + long rsp; /* KDB may be on a different stack */
34556 + long rip; /* rip when rsp was set */
34559 +register unsigned long current_stack_pointer asm("rsp") __attribute_used__;
34562 +void kdba_save_running(struct kdba_running_process *k, struct pt_regs *regs)
34564 + k->rsp = current_stack_pointer;
34565 + __asm__ __volatile__ ( " lea 0(%%rip),%%rax; movq %%rax,%0 ; " : "=r"(k->rip) : : "rax" );
34569 +void kdba_unsave_running(struct kdba_running_process *k, struct pt_regs *regs)
34573 +struct kdb_activation_record;
34574 +extern void kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
34575 + struct kdb_activation_record *ar);
34577 +extern void kdba_wait_for_cpus(void);
34579 +extern asmlinkage void kdb_interrupt(void);
34581 +#define KDB_INT_REGISTERS 16
34583 +#endif /* !_ASM_KDBPRIVATE_H */
34584 diff -Nurp linux-2.6.22-590/include/asm-x86_64/kdebug.h linux-2.6.22-600/include/asm-x86_64/kdebug.h
34585 --- linux-2.6.22-590/include/asm-x86_64/kdebug.h 2007-07-09 01:32:17.000000000 +0200
34586 +++ linux-2.6.22-600/include/asm-x86_64/kdebug.h 2008-04-09 18:16:24.000000000 +0200
34587 @@ -23,6 +23,8 @@ enum die_val {
34591 + DIE_KDEBUG_ENTER,
34592 + DIE_KDEBUG_LEAVE,
34595 extern void printk_address(unsigned long address);
34596 diff -Nurp linux-2.6.22-590/include/asm-x86_64/kmap_types.h linux-2.6.22-600/include/asm-x86_64/kmap_types.h
34597 --- linux-2.6.22-590/include/asm-x86_64/kmap_types.h 2007-07-09 01:32:17.000000000 +0200
34598 +++ linux-2.6.22-600/include/asm-x86_64/kmap_types.h 2008-04-09 18:16:24.000000000 +0200
34599 @@ -13,6 +13,7 @@ enum km_type {
34607 diff -Nurp linux-2.6.22-590/include/linux/console.h linux-2.6.22-600/include/linux/console.h
34608 --- linux-2.6.22-590/include/linux/console.h 2007-07-09 01:32:17.000000000 +0200
34609 +++ linux-2.6.22-600/include/linux/console.h 2008-04-09 18:14:28.000000000 +0200
34610 @@ -137,7 +137,12 @@ void vcs_remove_sysfs(struct tty_struct
34612 /* Some debug stub to catch some of the obvious races in the VT code */
34615 +#include <linux/kdb.h>
34616 +#define WARN_CONSOLE_UNLOCKED() WARN_ON(!is_console_locked() && !oops_in_progress && !atomic_read(&kdb_event))
34617 +#else /* !CONFIG_KDB */
34618 #define WARN_CONSOLE_UNLOCKED() WARN_ON(!is_console_locked() && !oops_in_progress)
34619 +#endif /* CONFIG_KDB */
34621 #define WARN_CONSOLE_UNLOCKED()
34623 diff -Nurp linux-2.6.22-590/include/linux/dis-asm.h linux-2.6.22-600/include/linux/dis-asm.h
34624 --- linux-2.6.22-590/include/linux/dis-asm.h 1970-01-01 01:00:00.000000000 +0100
34625 +++ linux-2.6.22-600/include/linux/dis-asm.h 2008-04-09 18:14:28.000000000 +0200
34627 +/* Interface between the opcode library and its callers.
34629 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
34630 + Free Software Foundation, Inc.
34632 + This program is free software; you can redistribute it and/or modify
34633 + it under the terms of the GNU General Public License as published by
34634 + the Free Software Foundation; either version 2, or (at your option)
34635 + any later version.
34637 + This program is distributed in the hope that it will be useful,
34638 + but WITHOUT ANY WARRANTY; without even the implied warranty of
34639 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34640 + GNU General Public License for more details.
34642 + You should have received a copy of the GNU General Public License
34643 + along with this program; if not, write to the Free Software
34644 + Foundation, Inc., 51 Franklin Street - Fifth Floor,
34645 + Boston, MA 02110-1301, USA.
34647 + Written by Cygnus Support, 1993.
34649 + The opcode library (libopcodes.a) provides instruction decoders for
34650 + a large variety of instruction sets, callable with an identical
34651 + interface, for making instruction-processing programs more independent
34652 + of the instruction set being processed. */
34654 +/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
34655 + * Any trailing whitespace was removed and #ifdef/ifndef __KERNEL__ added as
34657 + * Keith Owens <kaos@sgi.com> 15 May 2006
34663 +#ifdef __cplusplus
34668 +#include <asm/ansidecl.h>
34669 +#include <asm/bfd.h>
34670 +typedef void FILE;
34671 +#else /* __KERNEL__ */
34672 +#include <stdio.h>
34674 +#endif /* __KERNEL__ */
34676 +typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2;
34678 +enum dis_insn_type {
34679 + dis_noninsn, /* Not a valid instruction */
34680 + dis_nonbranch, /* Not a branch instruction */
34681 + dis_branch, /* Unconditional branch */
34682 + dis_condbranch, /* Conditional branch */
34683 + dis_jsr, /* Jump to subroutine */
34684 + dis_condjsr, /* Conditional jump to subroutine */
34685 + dis_dref, /* Data reference instruction */
34686 + dis_dref2 /* Two data references in instruction */
34689 +/* This struct is passed into the instruction decoding routine,
34690 + and is passed back out into each callback. The various fields are used
34691 + for conveying information from your main routine into your callbacks,
34692 + for passing information into the instruction decoders (such as the
34693 + addresses of the callback functions), or for passing information
34694 + back from the instruction decoders to their callers.
34696 + It must be initialized before it is first passed; this can be done
34697 + by hand, or using one of the initialization macros below. */
34699 +typedef struct disassemble_info {
34700 + fprintf_ftype fprintf_func;
34702 + void *application_data;
34704 + /* Target description. We could replace this with a pointer to the bfd,
34705 + but that would require one. There currently isn't any such requirement
34706 + so to avoid introducing one we record these explicitly. */
34707 + /* The bfd_flavour. This can be bfd_target_unknown_flavour. */
34708 + enum bfd_flavour flavour;
34709 + /* The bfd_arch value. */
34710 + enum bfd_architecture arch;
34711 + /* The bfd_mach value. */
34712 + unsigned long mach;
34713 + /* Endianness (for bi-endian cpus). Mono-endian cpus can ignore this. */
34714 + enum bfd_endian endian;
34715 + /* An arch/mach-specific bitmask of selected instruction subsets, mainly
34716 + for processors with run-time-switchable instruction sets. The default,
34717 + zero, means that there is no constraint. CGEN-based opcodes ports
34718 + may use ISA_foo masks. */
34719 + unsigned long insn_sets;
34721 + /* Some targets need information about the current section to accurately
34722 + display insns. If this is NULL, the target disassembler function
34723 + will have to make its best guess. */
34724 + asection *section;
34726 + /* An array of pointers to symbols either at the location being disassembled
34727 + or at the start of the function being disassembled. The array is sorted
34728 + so that the first symbol is intended to be the one used. The others are
34729 + present for any misc. purposes. This is not set reliably, but if it is
34730 + not NULL, it is correct. */
34731 + asymbol **symbols;
34732 + /* Number of symbols in array. */
34735 + /* For use by the disassembler.
34736 + The top 16 bits are reserved for public use (and are documented here).
34737 + The bottom 16 bits are for the internal use of the disassembler. */
34738 + unsigned long flags;
34739 +#define INSN_HAS_RELOC 0x80000000
34740 + void *private_data;
34742 + /* Function used to get bytes to disassemble. MEMADDR is the
34743 + address of the stuff to be disassembled, MYADDR is the address to
34744 + put the bytes in, and LENGTH is the number of bytes to read.
34745 + INFO is a pointer to this struct.
34746 + Returns an errno value or 0 for success. */
34747 + int (*read_memory_func)
34748 + (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length,
34749 + struct disassemble_info *info);
34751 + /* Function which should be called if we get an error that we can't
34752 + recover from. STATUS is the errno value from read_memory_func and
34753 + MEMADDR is the address that we were trying to read. INFO is a
34754 + pointer to this struct. */
34755 + void (*memory_error_func)
34756 + (int status, bfd_vma memaddr, struct disassemble_info *info);
34758 + /* Function called to print ADDR. */
34759 + void (*print_address_func)
34760 + (bfd_vma addr, struct disassemble_info *info);
34762 + /* Function called to determine if there is a symbol at the given ADDR.
34763 + If there is, the function returns 1, otherwise it returns 0.
34764 + This is used by ports which support an overlay manager where
34765 + the overlay number is held in the top part of an address. In
34766 + some circumstances we want to include the overlay number in the
34767 + address, (normally because there is a symbol associated with
34768 + that address), but sometimes we want to mask out the overlay bits. */
34769 + int (* symbol_at_address_func)
34770 + (bfd_vma addr, struct disassemble_info * info);
34772 + /* Function called to check if a SYMBOL is can be displayed to the user.
34773 + This is used by some ports that want to hide special symbols when
34774 + displaying debugging outout. */
34775 + bfd_boolean (* symbol_is_valid)
34776 + (asymbol *, struct disassemble_info * info);
34778 + /* These are for buffer_read_memory. */
34779 + bfd_byte *buffer;
34780 + bfd_vma buffer_vma;
34781 + unsigned int buffer_length;
34783 + /* This variable may be set by the instruction decoder. It suggests
34784 + the number of bytes objdump should display on a single line. If
34785 + the instruction decoder sets this, it should always set it to
34786 + the same value in order to get reasonable looking output. */
34787 + int bytes_per_line;
34789 + /* The next two variables control the way objdump displays the raw data. */
34790 + /* For example, if bytes_per_line is 8 and bytes_per_chunk is 4, the */
34791 + /* output will look like this:
34792 + 00: 00000000 00000000
34793 + with the chunks displayed according to "display_endian". */
34794 + int bytes_per_chunk;
34795 + enum bfd_endian display_endian;
34797 + /* Number of octets per incremented target address
34798 + Normally one, but some DSPs have byte sizes of 16 or 32 bits. */
34799 + unsigned int octets_per_byte;
34801 + /* The number of zeroes we want to see at the end of a section before we
34802 + start skipping them. */
34803 + unsigned int skip_zeroes;
34805 + /* The number of zeroes to skip at the end of a section. If the number
34806 + of zeroes at the end is between SKIP_ZEROES_AT_END and SKIP_ZEROES,
34807 + they will be disassembled. If there are fewer than
34808 + SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic
34809 + attempt to avoid disassembling zeroes inserted by section
34811 + unsigned int skip_zeroes_at_end;
34813 + /* Results from instruction decoders. Not all decoders yet support
34814 + this information. This info is set each time an instruction is
34815 + decoded, and is only valid for the last such instruction.
34817 + To determine whether this decoder supports this information, set
34818 + insn_info_valid to 0, decode an instruction, then check it. */
34820 + char insn_info_valid; /* Branch info has been set. */
34821 + char branch_delay_insns; /* How many sequential insn's will run before
34822 + a branch takes effect. (0 = normal) */
34823 + char data_size; /* Size of data reference in insn, in bytes */
34824 + enum dis_insn_type insn_type; /* Type of instruction */
34825 + bfd_vma target; /* Target address of branch or dref, if known;
34826 + zero if unknown. */
34827 + bfd_vma target2; /* Second target address for dref2 */
34829 + /* Command line options specific to the target disassembler. */
34830 + char * disassembler_options;
34832 +} disassemble_info;
34835 +/* Standard disassemblers. Disassemble one instruction at the given
34836 + target address. Return number of octets processed. */
34837 +typedef int (*disassembler_ftype) (bfd_vma, disassemble_info *);
34839 +extern int print_insn_big_mips (bfd_vma, disassemble_info *);
34840 +extern int print_insn_little_mips (bfd_vma, disassemble_info *);
34841 +extern int print_insn_i386 (bfd_vma, disassemble_info *);
34842 +extern int print_insn_i386_att (bfd_vma, disassemble_info *);
34843 +extern int print_insn_i386_intel (bfd_vma, disassemble_info *);
34844 +extern int print_insn_ia64 (bfd_vma, disassemble_info *);
34845 +extern int print_insn_i370 (bfd_vma, disassemble_info *);
34846 +extern int print_insn_m68hc11 (bfd_vma, disassemble_info *);
34847 +extern int print_insn_m68hc12 (bfd_vma, disassemble_info *);
34848 +extern int print_insn_m68k (bfd_vma, disassemble_info *);
34849 +extern int print_insn_z8001 (bfd_vma, disassemble_info *);
34850 +extern int print_insn_z8002 (bfd_vma, disassemble_info *);
34851 +extern int print_insn_h8300 (bfd_vma, disassemble_info *);
34852 +extern int print_insn_h8300h (bfd_vma, disassemble_info *);
34853 +extern int print_insn_h8300s (bfd_vma, disassemble_info *);
34854 +extern int print_insn_h8500 (bfd_vma, disassemble_info *);
34855 +extern int print_insn_alpha (bfd_vma, disassemble_info *);
34856 +extern int print_insn_big_arm (bfd_vma, disassemble_info *);
34857 +extern int print_insn_little_arm (bfd_vma, disassemble_info *);
34858 +extern int print_insn_sparc (bfd_vma, disassemble_info *);
34859 +extern int print_insn_big_a29k (bfd_vma, disassemble_info *);
34860 +extern int print_insn_little_a29k (bfd_vma, disassemble_info *);
34861 +extern int print_insn_avr (bfd_vma, disassemble_info *);
34862 +extern int print_insn_d10v (bfd_vma, disassemble_info *);
34863 +extern int print_insn_d30v (bfd_vma, disassemble_info *);
34864 +extern int print_insn_dlx (bfd_vma, disassemble_info *);
34865 +extern int print_insn_fr30 (bfd_vma, disassemble_info *);
34866 +extern int print_insn_hppa (bfd_vma, disassemble_info *);
34867 +extern int print_insn_i860 (bfd_vma, disassemble_info *);
34868 +extern int print_insn_i960 (bfd_vma, disassemble_info *);
34869 +extern int print_insn_ip2k (bfd_vma, disassemble_info *);
34870 +extern int print_insn_m32r (bfd_vma, disassemble_info *);
34871 +extern int print_insn_m88k (bfd_vma, disassemble_info *);
34872 +extern int print_insn_maxq_little (bfd_vma, disassemble_info *);
34873 +extern int print_insn_maxq_big (bfd_vma, disassemble_info *);
34874 +extern int print_insn_mcore (bfd_vma, disassemble_info *);
34875 +extern int print_insn_mmix (bfd_vma, disassemble_info *);
34876 +extern int print_insn_mn10200 (bfd_vma, disassemble_info *);
34877 +extern int print_insn_mn10300 (bfd_vma, disassemble_info *);
34878 +extern int print_insn_ms1 (bfd_vma, disassemble_info *);
34879 +extern int print_insn_msp430 (bfd_vma, disassemble_info *);
34880 +extern int print_insn_ns32k (bfd_vma, disassemble_info *);
34881 +extern int print_insn_crx (bfd_vma, disassemble_info *);
34882 +extern int print_insn_openrisc (bfd_vma, disassemble_info *);
34883 +extern int print_insn_big_or32 (bfd_vma, disassemble_info *);
34884 +extern int print_insn_little_or32 (bfd_vma, disassemble_info *);
34885 +extern int print_insn_pdp11 (bfd_vma, disassemble_info *);
34886 +extern int print_insn_pj (bfd_vma, disassemble_info *);
34887 +extern int print_insn_big_powerpc (bfd_vma, disassemble_info *);
34888 +extern int print_insn_little_powerpc (bfd_vma, disassemble_info *);
34889 +extern int print_insn_rs6000 (bfd_vma, disassemble_info *);
34890 +extern int print_insn_s390 (bfd_vma, disassemble_info *);
34891 +extern int print_insn_sh (bfd_vma, disassemble_info *);
34892 +extern int print_insn_tic30 (bfd_vma, disassemble_info *);
34893 +extern int print_insn_tic4x (bfd_vma, disassemble_info *);
34894 +extern int print_insn_tic54x (bfd_vma, disassemble_info *);
34895 +extern int print_insn_tic80 (bfd_vma, disassemble_info *);
34896 +extern int print_insn_v850 (bfd_vma, disassemble_info *);
34897 +extern int print_insn_vax (bfd_vma, disassemble_info *);
34898 +extern int print_insn_w65 (bfd_vma, disassemble_info *);
34899 +extern int print_insn_xstormy16 (bfd_vma, disassemble_info *);
34900 +extern int print_insn_xtensa (bfd_vma, disassemble_info *);
34901 +extern int print_insn_sh64 (bfd_vma, disassemble_info *);
34902 +extern int print_insn_sh64x_media (bfd_vma, disassemble_info *);
34903 +extern int print_insn_frv (bfd_vma, disassemble_info *);
34904 +extern int print_insn_iq2000 (bfd_vma, disassemble_info *);
34905 +extern int print_insn_m32c (bfd_vma, disassemble_info *);
34907 +extern disassembler_ftype arc_get_disassembler (void *);
34908 +extern disassembler_ftype cris_get_disassembler (bfd *);
34910 +extern void print_mips_disassembler_options (FILE *);
34911 +extern void print_ppc_disassembler_options (FILE *);
34912 +extern void print_arm_disassembler_options (FILE *);
34913 +extern void parse_arm_disassembler_option (char *);
34914 +extern int get_arm_regname_num_options (void);
34915 +extern int set_arm_regname_option (int);
34916 +extern int get_arm_regnames (int, const char **, const char **, const char *const **);
34917 +extern bfd_boolean arm_symbol_is_valid (asymbol *, struct disassemble_info *);
34919 +/* Fetch the disassembler for a given BFD, if that support is available. */
34920 +extern disassembler_ftype disassembler (bfd *);
34922 +/* Amend the disassemble_info structure as necessary for the target architecture.
34923 + Should only be called after initialising the info->arch field. */
34924 +extern void disassemble_init_for_target (struct disassemble_info * info);
34926 +/* Document any target specific options available from the disassembler. */
34927 +extern void disassembler_usage (FILE *);
34930 +/* This block of definitions is for particular callers who read instructions
34931 + into a buffer before calling the instruction decoder. */
34933 +/* Here is a function which callers may wish to use for read_memory_func.
34934 + It gets bytes from a buffer. */
34935 +extern int buffer_read_memory
34936 + (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *);
34938 +/* This function goes with buffer_read_memory.
34939 + It prints a message using info->fprintf_func and info->stream. */
34940 +extern void perror_memory (int, bfd_vma, struct disassemble_info *);
34943 +/* Just print the address in hex. This is included for completeness even
34944 + though both GDB and objdump provide their own (to print symbolic
34946 +extern void generic_print_address
34947 + (bfd_vma, struct disassemble_info *);
34949 +/* Always true. */
34950 +extern int generic_symbol_at_address
34951 + (bfd_vma, struct disassemble_info *);
34953 +/* Also always true. */
34954 +extern bfd_boolean generic_symbol_is_valid
34955 + (asymbol *, struct disassemble_info *);
34957 +/* Method to initialize a disassemble_info struct. This should be
34958 + called by all applications creating such a struct. */
34959 +extern void init_disassemble_info (struct disassemble_info *info, void *stream,
34960 + fprintf_ftype fprintf_func);
34962 +/* For compatibility with existing code. */
34963 +#define INIT_DISASSEMBLE_INFO(INFO, STREAM, FPRINTF_FUNC) \
34964 + init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC))
34965 +#define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \
34966 + init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC))
34969 +#ifdef __cplusplus
34973 +#endif /* ! defined (DIS_ASM_H) */
34974 diff -Nurp linux-2.6.22-590/include/linux/kdb.h linux-2.6.22-600/include/linux/kdb.h
34975 --- linux-2.6.22-590/include/linux/kdb.h 1970-01-01 01:00:00.000000000 +0100
34976 +++ linux-2.6.22-600/include/linux/kdb.h 2008-04-09 18:14:28.000000000 +0200
34982 + * Kernel Debugger Architecture Independent Global Headers
34984 + * This file is subject to the terms and conditions of the GNU General Public
34985 + * License. See the file "COPYING" in the main directory of this archive
34986 + * for more details.
34988 + * Copyright (c) 2000-2007 Silicon Graphics, Inc. All Rights Reserved.
34989 + * Copyright (C) 2000 Stephane Eranian <eranian@hpl.hp.com>
34992 +#include <linux/init.h>
34993 +#include <linux/sched.h>
34994 +#include <asm/atomic.h>
34997 +/* These are really private, but they must be defined before including
34998 + * asm-$(ARCH)/kdb.h, so make them public and put them here.
35000 +extern int kdb_getuserarea_size(void *, unsigned long, size_t);
35001 +extern int kdb_putuserarea_size(unsigned long, void *, size_t);
35003 +#include <asm/kdb.h>
35006 +#define KDB_MAJOR_VERSION 4
35007 +#define KDB_MINOR_VERSION 4
35008 +#define KDB_TEST_VERSION ""
35011 + * kdb_initial_cpu is initialized to -1, and is set to the cpu
35012 + * number whenever the kernel debugger is entered.
35014 +extern volatile int kdb_initial_cpu;
35015 +extern atomic_t kdb_event;
35016 +extern atomic_t kdb_8250;
35018 +#define KDB_IS_RUNNING() (kdb_initial_cpu != -1)
35019 +#define KDB_8250() (atomic_read(&kdb_8250) != 0)
35021 +#define KDB_IS_RUNNING() (0)
35022 +#define KDB_8250() (0)
35023 +#endif /* CONFIG_KDB */
35028 + * Defines whether kdb is on or not. Default value
35029 + * is set by CONFIG_KDB_OFF. Boot with kdb=on/off/on-nokey
35030 + * or echo "[012]" > /proc/sys/kernel/kdb to change it.
35032 +extern int kdb_on;
35034 +#if defined(CONFIG_SERIAL_8250_CONSOLE) || defined(CONFIG_SERIAL_SGI_L1_CONSOLE)
35036 + * kdb_serial.iobase is initialized to zero, and is set to the I/O
35037 + * address of the serial port when the console is setup in
35038 + * serial_console_setup.
35040 +extern struct kdb_serial {
35042 + unsigned long iobase;
35043 + unsigned long ioreg_shift;
35050 + * Contains a pointer to the last string supplied to the
35051 + * kernel 'die' panic function.
35053 +extern const char *kdb_diemsg;
35055 +#define KDB_FLAG_EARLYKDB (1 << 0) /* set from boot parameter kdb=early */
35056 +#define KDB_FLAG_CATASTROPHIC (1 << 1) /* A catastrophic event has occurred */
35057 +#define KDB_FLAG_CMD_INTERRUPT (1 << 2) /* Previous command was interrupted */
35058 +#define KDB_FLAG_NOIPI (1 << 3) /* Do not send IPIs */
35059 +#define KDB_FLAG_ONLY_DO_DUMP (1 << 4) /* Only do a dump, used when kdb is off */
35060 +#define KDB_FLAG_NO_CONSOLE (1 << 5) /* No console is available, kdb is disabled */
35061 +#define KDB_FLAG_NO_VT_CONSOLE (1 << 6) /* No VT console is available, do not use keyboard */
35062 +#define KDB_FLAG_NO_I8042 (1 << 7) /* No i8042 chip is available, do not use keyboard */
35063 +#define KDB_FLAG_RECOVERY (1 << 8) /* kdb is being entered for an error which has been recovered */
35065 +extern volatile int kdb_flags; /* Global flags, see kdb_state for per cpu state */
35067 +extern void kdb_save_flags(void);
35068 +extern void kdb_restore_flags(void);
35070 +#define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag)
35071 +#define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag))
35072 +#define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag))
35075 + * External entry point for the kernel debugger. The pt_regs
35076 + * at the time of entry are supplied along with the reason for
35077 + * entry to the kernel debugger.
35081 + KDB_REASON_ENTER=1, /* KDB_ENTER() trap/fault - regs valid */
35082 + KDB_REASON_ENTER_SLAVE, /* KDB_ENTER_SLAVE() trap/fault - regs valid */
35083 + KDB_REASON_BREAK, /* Breakpoint inst. - regs valid */
35084 + KDB_REASON_DEBUG, /* Debug Fault - regs valid */
35085 + KDB_REASON_OOPS, /* Kernel Oops - regs valid */
35086 + KDB_REASON_SWITCH, /* CPU switch - regs valid*/
35087 + KDB_REASON_KEYBOARD, /* Keyboard entry - regs valid */
35088 + KDB_REASON_NMI, /* Non-maskable interrupt; regs valid */
35089 + KDB_REASON_RECURSE, /* Recursive entry to kdb; regs probably valid */
35090 + KDB_REASON_CPU_UP, /* Add one cpu to kdb; regs invalid */
35091 + KDB_REASON_SILENT, /* Silent entry/exit to kdb; regs invalid - internal only */
35095 +extern fastcall int kdb(kdb_reason_t, int, struct pt_regs *);
35097 +#define kdb(reason,error_code,frame) (0)
35100 +/* Mainly used by kdb code, but this function is sometimes used
35101 + * by hacked debug code so make it generally available, not private.
35103 +extern void kdb_printf(const char *,...)
35104 + __attribute__ ((format (printf, 1, 2)));
35105 +typedef void (*kdb_printf_t)(const char *, ...)
35106 + __attribute__ ((format (printf, 1, 2)));
35107 +extern void kdb_init(void);
35109 +#if defined(CONFIG_SMP)
35111 + * Kernel debugger non-maskable IPI handler.
35113 +extern int kdb_ipi(struct pt_regs *, void (*ack_interrupt)(void));
35114 +extern void smp_kdb_stop(void);
35115 +#else /* CONFIG_SMP */
35116 +#define smp_kdb_stop()
35117 +#endif /* CONFIG_SMP */
35119 +#ifdef CONFIG_KDB_USB
35120 +#include <linux/usb.h>
35122 +struct kdb_usb_exchange {
35123 + void *uhci; /* pointer to the UHCI structure */
35124 + struct urb *urb; /* pointer to the URB */
35125 + unsigned char *buffer; /* pointer to buffer */
35126 + void (*poll_func)(void *, struct urb *); /* pointer to the polling function */
35127 + void (*reset_timer)(void); /* pointer to the reset timer function */
35129 +extern struct kdb_usb_exchange kdb_usb_infos; /* KDB common structure */
35130 +#endif /* CONFIG_KDB_USB */
35133 +int kdb_process_cpu(const struct task_struct *p)
35135 + unsigned int cpu = task_thread_info(p)->cpu;
35136 + if (cpu > NR_CPUS)
35141 +extern const char kdb_serial_str[];
35143 +#endif /* !_KDB_H */
35144 diff -Nurp linux-2.6.22-590/include/linux/kdbprivate.h linux-2.6.22-600/include/linux/kdbprivate.h
35145 --- linux-2.6.22-590/include/linux/kdbprivate.h 1970-01-01 01:00:00.000000000 +0100
35146 +++ linux-2.6.22-600/include/linux/kdbprivate.h 2008-04-09 18:14:28.000000000 +0200
35148 +#ifndef _KDBPRIVATE_H
35149 +#define _KDBPRIVATE_H
35152 + * Kernel Debugger Architecture Independent Private Headers
35154 + * This file is subject to the terms and conditions of the GNU General Public
35155 + * License. See the file "COPYING" in the main directory of this archive
35156 + * for more details.
35158 + * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
35162 +#include <linux/dis-asm.h>
35163 +#include <asm/kdbprivate.h>
35164 +#include <asm/bfd.h>
35167 + * Kernel Debugger Error codes. Must not overlap with command codes.
35170 +#define KDB_NOTFOUND (-1)
35171 +#define KDB_ARGCOUNT (-2)
35172 +#define KDB_BADWIDTH (-3)
35173 +#define KDB_BADRADIX (-4)
35174 +#define KDB_NOTENV (-5)
35175 +#define KDB_NOENVVALUE (-6)
35176 +#define KDB_NOTIMP (-7)
35177 +#define KDB_ENVFULL (-8)
35178 +#define KDB_ENVBUFFULL (-9 )
35179 +#define KDB_TOOMANYBPT (-10)
35180 +#define KDB_TOOMANYDBREGS (-11)
35181 +#define KDB_DUPBPT (-12)
35182 +#define KDB_BPTNOTFOUND (-13)
35183 +#define KDB_BADMODE (-14)
35184 +#define KDB_BADINT (-15)
35185 +#define KDB_INVADDRFMT (-16)
35186 +#define KDB_BADREG (-17)
35187 +#define KDB_BADCPUNUM (-18)
35188 +#define KDB_BADLENGTH (-19)
35189 +#define KDB_NOBP (-20)
35190 +#define KDB_BADADDR (-21)
35193 + * Kernel Debugger Command codes. Must not overlap with error codes.
35195 +#define KDB_CMD_GO (-1001)
35196 +#define KDB_CMD_CPU (-1002)
35197 +#define KDB_CMD_SS (-1003)
35198 +#define KDB_CMD_SSB (-1004)
35201 + * Internal debug flags
35203 +/* KDB_DEBUG_FLAG_BT 0x0001 Was Stack traceback debug */
35204 +#define KDB_DEBUG_FLAG_BP 0x0002 /* Breakpoint subsystem debug */
35205 +#define KDB_DEBUG_FLAG_BB_SUMM 0x0004 /* Basic block analysis, summary only */
35206 +#define KDB_DEBUG_FLAG_AR 0x0008 /* Activation record, generic */
35207 +#define KDB_DEBUG_FLAG_ARA 0x0010 /* Activation record, arch specific */
35208 +#define KDB_DEBUG_FLAG_BB 0x0020 /* All basic block analysis */
35209 +#define KDB_DEBUG_FLAG_STATE 0x0040 /* State flags */
35210 +#define KDB_DEBUG_FLAG_MASK 0xffff /* All debug flags */
35211 +#define KDB_DEBUG_FLAG_SHIFT 16 /* Shift factor for dbflags */
35213 +#define KDB_DEBUG(flag) (kdb_flags & (KDB_DEBUG_FLAG_##flag << KDB_DEBUG_FLAG_SHIFT))
35214 +#define KDB_DEBUG_STATE(text,value) if (KDB_DEBUG(STATE)) kdb_print_state(text, value)
35217 + KDB_REPEAT_NONE = 0, /* Do not repeat this command */
35218 + KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */
35219 + KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */
35222 +typedef int (*kdb_func_t)(int, const char **);
35225 + * Symbol table format returned by kallsyms.
35228 +typedef struct __ksymtab {
35229 + unsigned long value; /* Address of symbol */
35230 + const char *mod_name; /* Module containing symbol or "kernel" */
35231 + unsigned long mod_start;
35232 + unsigned long mod_end;
35233 + const char *sec_name; /* Section containing symbol */
35234 + unsigned long sec_start;
35235 + unsigned long sec_end;
35236 + const char *sym_name; /* Full symbol name, including any version */
35237 + unsigned long sym_start;
35238 + unsigned long sym_end;
35240 +extern int kallsyms_symbol_next(char *prefix_name, int flag);
35241 +extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
35244 + * Exported Symbols for kernel loadable modules to use.
35246 +extern int kdb_register(char *, kdb_func_t, char *, char *, short);
35247 +extern int kdb_register_repeat(char *, kdb_func_t, char *, char *, short, kdb_repeat_t);
35248 +extern int kdb_unregister(char *);
35250 +extern int kdb_getarea_size(void *, unsigned long, size_t);
35251 +extern int kdb_putarea_size(unsigned long, void *, size_t);
35253 +/* Like get_user and put_user, kdb_getarea and kdb_putarea take variable
35254 + * names, not pointers. The underlying *_size functions take pointers.
35256 +#define kdb_getarea(x,addr) kdb_getarea_size(&(x), addr, sizeof((x)))
35257 +#define kdb_putarea(addr,x) kdb_putarea_size(addr, &(x), sizeof((x)))
35259 +extern int kdb_getphysword(unsigned long *word,
35260 + unsigned long addr, size_t size);
35261 +extern int kdb_getword(unsigned long *, unsigned long, size_t);
35262 +extern int kdb_putword(unsigned long, unsigned long, size_t);
35264 +extern int kdbgetularg(const char *, unsigned long *);
35265 +extern char *kdbgetenv(const char *);
35266 +extern int kdbgetintenv(const char *, int *);
35267 +extern int kdbgetaddrarg(int, const char**, int*, unsigned long *,
35268 + long *, char **);
35269 +extern int kdbgetsymval(const char *, kdb_symtab_t *);
35270 +extern int kdbnearsym(unsigned long, kdb_symtab_t *);
35271 +extern void kdbnearsym_cleanup(void);
35272 +extern char *kdb_read(char *buffer, size_t bufsize);
35273 +extern char *kdb_strdup(const char *str, gfp_t type);
35274 +extern void kdb_symbol_print(kdb_machreg_t, const kdb_symtab_t *, unsigned int);
35277 + * Do we have a set of registers?
35280 +#define KDB_NULL_REGS(regs) \
35281 + (regs == (struct pt_regs *)NULL ? kdb_printf("%s: null regs - should never happen\n", __FUNCTION__), 1 : 0)
35284 + * Routine for debugging the debugger state.
35287 +extern void kdb_print_state(const char *, int);
35290 + * Per cpu kdb state. A cpu can be under kdb control but outside kdb,
35291 + * for example when doing single step.
35293 +volatile extern int kdb_state[ /*NR_CPUS*/ ];
35294 +#define KDB_STATE_KDB 0x00000001 /* Cpu is inside kdb */
35295 +#define KDB_STATE_LEAVING 0x00000002 /* Cpu is leaving kdb */
35296 +#define KDB_STATE_CMD 0x00000004 /* Running a kdb command */
35297 +#define KDB_STATE_KDB_CONTROL 0x00000008 /* This cpu is under kdb control */
35298 +#define KDB_STATE_HOLD_CPU 0x00000010 /* Hold this cpu inside kdb */
35299 +#define KDB_STATE_DOING_SS 0x00000020 /* Doing ss command */
35300 +#define KDB_STATE_DOING_SSB 0x00000040 /* Doing ssb command, DOING_SS is also set */
35301 +#define KDB_STATE_SSBPT 0x00000080 /* Install breakpoint after one ss, independent of DOING_SS */
35302 +#define KDB_STATE_REENTRY 0x00000100 /* Valid re-entry into kdb */
35303 +#define KDB_STATE_SUPPRESS 0x00000200 /* Suppress error messages */
35304 +#define KDB_STATE_LONGJMP 0x00000400 /* longjmp() data is available */
35305 +#define KDB_STATE_GO_SWITCH 0x00000800 /* go is switching back to initial cpu */
35306 +#define KDB_STATE_PRINTF_LOCK 0x00001000 /* Holds kdb_printf lock */
35307 +#define KDB_STATE_WAIT_IPI 0x00002000 /* Waiting for kdb_ipi() NMI */
35308 +#define KDB_STATE_RECURSE 0x00004000 /* Recursive entry to kdb */
35309 +#define KDB_STATE_IP_ADJUSTED 0x00008000 /* Restart IP has been adjusted */
35310 +#define KDB_STATE_GO1 0x00010000 /* go only releases one cpu */
35311 +#define KDB_STATE_KEYBOARD 0x00020000 /* kdb entered via keyboard on this cpu */
35312 +#define KDB_STATE_ARCH 0xff000000 /* Reserved for arch specific use */
35314 +#define KDB_STATE_CPU(flag,cpu) (kdb_state[cpu] & KDB_STATE_##flag)
35315 +#define KDB_STATE_SET_CPU(flag,cpu) ((void)(kdb_state[cpu] |= KDB_STATE_##flag))
35316 +#define KDB_STATE_CLEAR_CPU(flag,cpu) ((void)(kdb_state[cpu] &= ~KDB_STATE_##flag))
35318 +#define KDB_STATE(flag) KDB_STATE_CPU(flag,smp_processor_id())
35319 +#define KDB_STATE_SET(flag) KDB_STATE_SET_CPU(flag,smp_processor_id())
35320 +#define KDB_STATE_CLEAR(flag) KDB_STATE_CLEAR_CPU(flag,smp_processor_id())
35325 + * Contains the current line number on the screen. Used
35326 + * to handle the built-in pager (LINES env variable)
35328 +extern volatile int kdb_nextline;
35331 + * Breakpoint state
35333 + * Each active and inactive breakpoint is represented by
35334 + * an instance of the following data structure.
35337 +typedef struct _kdb_bp {
35338 + bfd_vma bp_addr; /* Address breakpoint is present at */
35339 + kdb_machinst_t bp_inst; /* Replaced instruction */
35341 + unsigned int bp_free:1; /* This entry is available */
35343 + unsigned int bp_enabled:1; /* Breakpoint is active in register */
35344 + unsigned int bp_global:1; /* Global to all processors */
35346 + unsigned int bp_hardtype:1; /* Uses hardware register */
35347 + unsigned int bp_forcehw:1; /* Force hardware register */
35348 + unsigned int bp_installed:1; /* Breakpoint is installed */
35349 + unsigned int bp_delay:1; /* Do delayed bp handling */
35350 + unsigned int bp_delayed:1; /* Delayed breakpoint */
35352 + int bp_cpu; /* Cpu # (if bp_global == 0) */
35353 + kdbhard_bp_t bp_template; /* Hardware breakpoint template */
35354 + kdbhard_bp_t *bp_hard; /* Hardware breakpoint structure */
35355 + int bp_adjust; /* Adjustment to PC for real instruction */
35359 + * Breakpoint handling subsystem global variables
35361 +extern kdb_bp_t kdb_breakpoints[/* KDB_MAXBPT */];
35364 + * Breakpoint architecture dependent functions. Must be provided
35365 + * in some form for all architectures.
35367 +extern void kdba_initbp(void);
35368 +extern void kdba_printbp(kdb_bp_t *);
35369 +extern kdbhard_bp_t *kdba_allocbp(kdbhard_bp_t *, int *);
35370 +extern void kdba_freebp(kdbhard_bp_t *);
35371 +extern int kdba_parsebp(int, const char**, int *, kdb_bp_t*);
35372 +extern char *kdba_bptype(kdbhard_bp_t *);
35373 +extern void kdba_setsinglestep(struct pt_regs *);
35374 +extern void kdba_clearsinglestep(struct pt_regs *);
35377 + * Adjust instruction pointer architecture dependent function. Must be
35378 + * provided in some form for all architectures.
35380 +extern void kdba_adjust_ip(kdb_reason_t, int, struct pt_regs *);
35383 + * KDB-only global function prototypes.
35385 +extern void kdb_id1(unsigned long);
35386 +extern void kdb_id_init(void);
35389 + * Initialization functions.
35391 +extern void kdba_init(void);
35392 +extern void kdb_io_init(void);
35395 + * Architecture specific function to read a string.
35397 +typedef int (*get_char_func)(void);
35398 +extern get_char_func poll_funcs[];
35400 +#ifndef CONFIG_IA64
35402 + * Data for a single activation record on stack.
35405 +struct kdb_stack_info {
35406 + kdb_machreg_t physical_start;
35407 + kdb_machreg_t physical_end;
35408 + kdb_machreg_t logical_start;
35409 + kdb_machreg_t logical_end;
35410 + kdb_machreg_t next;
35414 +typedef struct { DECLARE_BITMAP(bits, KDBA_MAXARGS); } valid_t;
35416 +struct kdb_activation_record {
35417 + struct kdb_stack_info stack; /* information about current stack */
35418 + int args; /* number of arguments detected */
35419 + kdb_machreg_t arg[KDBA_MAXARGS]; /* -> arguments */
35420 + valid_t valid; /* is argument n valid? */
35425 + * Architecture specific Stack Traceback functions.
35428 +struct task_struct;
35430 +extern int kdba_bt_address(kdb_machreg_t, int);
35431 +extern int kdba_bt_process(const struct task_struct *, int);
35434 + * KDB Command Table
35437 +typedef struct _kdbtab {
35438 + char *cmd_name; /* Command name */
35439 + kdb_func_t cmd_func; /* Function to execute command */
35440 + char *cmd_usage; /* Usage String for this command */
35441 + char *cmd_help; /* Help message for this command */
35442 + short cmd_flags; /* Parsing flags */
35443 + short cmd_minlen; /* Minimum legal # command chars required */
35444 + kdb_repeat_t cmd_repeat; /* Does command auto repeat on enter? */
35448 + * External command function declarations
35451 +extern int kdb_id(int, const char **);
35452 +extern int kdb_bt(int, const char **);
35455 + * External utility function declarations
35457 +extern char* kdb_getstr(char *, size_t, char *);
35460 + * Register contents manipulation
35462 +extern int kdba_getregcontents(const char *, struct pt_regs *, kdb_machreg_t *);
35463 +extern int kdba_setregcontents(const char *, struct pt_regs *, kdb_machreg_t);
35464 +extern int kdba_dumpregs(struct pt_regs *, const char *, const char *);
35465 +extern int kdba_setpc(struct pt_regs *, kdb_machreg_t);
35466 +extern kdb_machreg_t kdba_getpc(struct pt_regs *);
35469 + * Debug register handling.
35471 +extern void kdba_installdbreg(kdb_bp_t*);
35472 +extern void kdba_removedbreg(kdb_bp_t*);
35475 + * Breakpoint handling - External interfaces
35477 +extern void kdb_initbptab(void);
35478 +extern void kdb_bp_install_global(struct pt_regs *);
35479 +extern void kdb_bp_install_local(struct pt_regs *);
35480 +extern void kdb_bp_remove_global(void);
35481 +extern void kdb_bp_remove_local(void);
35484 + * Breakpoint handling - Internal to kdb_bp.c/kdba_bp.c
35486 +extern int kdba_installbp(struct pt_regs *regs, kdb_bp_t *);
35487 +extern int kdba_removebp(kdb_bp_t *);
35491 + KDB_DB_BPT, /* Breakpoint */
35492 + KDB_DB_SS, /* Single-step trap */
35493 + KDB_DB_SSB, /* Single step to branch */
35494 + KDB_DB_SSBPT, /* Single step over breakpoint */
35495 + KDB_DB_NOBPT /* Spurious breakpoint */
35498 +extern kdb_dbtrap_t kdba_db_trap(struct pt_regs *, int); /* DEBUG trap/fault handler */
35499 +extern kdb_dbtrap_t kdba_bp_trap(struct pt_regs *, int); /* Breakpoint trap/fault hdlr */
35502 + * Interrupt Handling
35504 +typedef unsigned long kdb_intstate_t;
35506 +extern void kdba_disableint(kdb_intstate_t *);
35507 +extern void kdba_restoreint(kdb_intstate_t *);
35510 + * SMP and process stack manipulation routines.
35512 +extern int kdba_ipi(struct pt_regs *, void (*)(void));
35513 +extern int kdba_main_loop(kdb_reason_t, kdb_reason_t, int, kdb_dbtrap_t, struct pt_regs *);
35514 +extern int kdb_main_loop(kdb_reason_t, kdb_reason_t, int, kdb_dbtrap_t, struct pt_regs *);
35517 + * General Disassembler interfaces
35519 +extern int kdb_dis_fprintf(PTR, const char *, ...) __attribute__ ((format (printf, 2, 3)));
35520 +extern int kdb_dis_fprintf_dummy(PTR, const char *, ...) __attribute__ ((format (printf, 2, 3)));
35521 +extern disassemble_info kdb_di;
35524 + * Architecture Dependent Disassembler interfaces
35526 +extern int kdba_id_printinsn(kdb_machreg_t, disassemble_info *);
35527 +extern int kdba_id_parsemode(const char *, disassemble_info*);
35528 +extern void kdba_id_init(disassemble_info *);
35529 +extern void kdba_check_pc(kdb_machreg_t *);
35532 + * Miscellaneous functions and data areas
35534 +extern char *kdb_cmds[];
35535 +extern void kdb_syslog_data(char *syslog_data[]);
35536 +extern unsigned long kdb_task_state_string(const char *);
35537 +extern char kdb_task_state_char (const struct task_struct *);
35538 +extern unsigned long kdb_task_state(const struct task_struct *p, unsigned long mask);
35539 +extern void kdb_ps_suppressed(void);
35540 +extern void kdb_ps1(const struct task_struct *p);
35541 +extern int kdb_parse(const char *cmdstr);
35542 +extern void kdb_print_nameval(const char *name, unsigned long val);
35543 +extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info, int seqno);
35544 +#ifdef CONFIG_SWAP
35545 +extern void kdb_si_swapinfo(struct sysinfo *);
35547 +#include <linux/swap.h>
35548 +#define kdb_si_swapinfo(x) si_swapinfo(x)
35550 +extern void kdb_meminfo_read_proc(void);
35551 +#ifdef CONFIG_HUGETLB_PAGE
35552 +extern void kdb_hugetlb_report_meminfo(void);
35553 +#endif /* CONFIG_HUGETLB_PAGE */
35554 +extern const char *kdb_walk_kallsyms(loff_t *pos);
35557 + * Architecture Dependant Local Processor setup & cleanup interfaces
35559 +extern void kdba_local_arch_setup(void);
35560 +extern void kdba_local_arch_cleanup(void);
35563 + * Defines for kdb_symbol_print.
35565 +#define KDB_SP_SPACEB 0x0001 /* Space before string */
35566 +#define KDB_SP_SPACEA 0x0002 /* Space after string */
35567 +#define KDB_SP_PAREN 0x0004 /* Parenthesis around string */
35568 +#define KDB_SP_VALUE 0x0008 /* Print the value of the address */
35569 +#define KDB_SP_SYMSIZE 0x0010 /* Print the size of the symbol */
35570 +#define KDB_SP_NEWLINE 0x0020 /* Newline after string */
35571 +#define KDB_SP_DEFAULT (KDB_SP_VALUE|KDB_SP_PAREN)
35573 +/* Save data about running processes */
35575 +struct kdb_running_process {
35576 + struct task_struct *p;
35577 + struct pt_regs *regs;
35578 + int seqno; /* kdb sequence number */
35579 + int irq_depth; /* irq count */
35580 + struct kdba_running_process arch; /* arch dependent save data */
35583 +extern struct kdb_running_process kdb_running_process[/* NR_CPUS */];
35585 +extern void kdb_save_running(struct pt_regs *);
35586 +extern void kdb_unsave_running(struct pt_regs *);
35587 +extern struct task_struct *kdb_curr_task(int);
35589 +/* Incremented each time the main kdb loop is entered on the initial cpu,
35590 + * it gives some indication of how old the saved data is.
35592 +extern int kdb_seqno;
35594 +#define kdb_task_has_cpu(p) (task_curr(p))
35595 +extern void kdb_runqueue(unsigned long cpu, kdb_printf_t xxx_printf);
35597 +/* Simplify coexistence with NPTL */
35598 +#define kdb_do_each_thread(g, p) do_each_thread(g, p)
35599 +#define kdb_while_each_thread(g, p) while_each_thread(g, p)
35601 +#define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
35603 +extern void *debug_kmalloc(size_t size, gfp_t flags);
35604 +extern void debug_kfree(void *);
35605 +extern void debug_kusage(void);
35607 +extern void kdba_set_current_task(const struct task_struct *);
35608 +extern const struct task_struct *kdb_current_task;
35609 +extern struct pt_regs *kdb_current_regs;
35611 +/* Functions to safely read and write kernel areas. The {to,from}_xxx
35612 + * addresses are not necessarily valid, these functions must check for
35613 + * validity. If the arch already supports get and put routines with suitable
35614 + * validation and/or recovery on invalid addresses then use those routines,
35615 + * otherwise check it yourself.
35618 +extern int kdba_putarea_size(unsigned long to_xxx, void *from, size_t size);
35619 +extern int kdba_getarea_size(void *to, unsigned long from_xxx, size_t size);
35620 +extern int kdba_verify_rw(unsigned long addr, size_t size);
35622 +#ifndef KDB_RUNNING_PROCESS_ORIGINAL
35623 +#define KDB_RUNNING_PROCESS_ORIGINAL kdb_running_process
35626 +extern int kdb_wait_for_cpus_secs;
35627 +extern void kdba_cpu_up(void);
35628 +extern char kdb_prompt_str[];
35630 +#define KDB_WORD_SIZE ((int)sizeof(kdb_machreg_t))
35632 +#endif /* !_KDBPRIVATE_H */
35633 diff -Nurp linux-2.6.22-590/include/linux/sysctl.h linux-2.6.22-600/include/linux/sysctl.h
35634 --- linux-2.6.22-590/include/linux/sysctl.h 2008-04-09 18:10:57.000000000 +0200
35635 +++ linux-2.6.22-600/include/linux/sysctl.h 2008-04-09 18:14:28.000000000 +0200
35636 @@ -166,6 +166,7 @@ enum
35637 KERN_MAX_LOCK_DEPTH=74,
35638 KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
35639 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
35640 + KERN_KDB=77, /* int: kdb on/off */
35644 diff -Nurp linux-2.6.22-590/init/main.c linux-2.6.22-600/init/main.c
35645 --- linux-2.6.22-590/init/main.c 2008-04-09 18:10:53.000000000 +0200
35646 +++ linux-2.6.22-600/init/main.c 2008-04-09 18:14:28.000000000 +0200
35648 #include <asm/smp.h>
35652 +#include <linux/kdb.h>
35653 +#endif /* CONFIG_KDB */
35656 * This is one of the first .c files built. Error out early if we have compiler
35658 @@ -188,6 +192,26 @@ static const char *panic_later, *panic_p
35660 extern struct obs_kernel_param __setup_start[], __setup_end[];
35663 +static int __init kdb_setup(char *str)
35665 + if (strcmp(str, "on") == 0) {
35667 + } else if (strcmp(str, "on-nokey") == 0) {
35669 + } else if (strcmp(str, "off") == 0) {
35671 + } else if (strcmp(str, "early") == 0) {
35673 + kdb_flags |= KDB_FLAG_EARLYKDB;
35675 + printk("kdb flag %s not recognised\n", str);
35679 +__setup("kdb=", kdb_setup);
35680 +#endif /* CONFIG_KDB */
35682 static int __init obsolete_checksetup(char *line)
35684 struct obs_kernel_param *p;
35685 @@ -609,6 +633,14 @@ asmlinkage void __init start_kernel(void
35686 pgtable_cache_init();
35692 + if (KDB_FLAG(EARLYKDB)) {
35695 +#endif /* CONFIG_KDB */
35699 efi_enter_virtual_mode();
35700 diff -Nurp linux-2.6.22-590/kdb/ChangeLog linux-2.6.22-600/kdb/ChangeLog
35701 --- linux-2.6.22-590/kdb/ChangeLog 1970-01-01 01:00:00.000000000 +0100
35702 +++ linux-2.6.22-600/kdb/ChangeLog 2008-04-09 18:14:28.000000000 +0200
35704 +2007-07-26 Keith Owens <kaos@sgi.com>
35706 + * New x86 backtrace code.
35707 + * kdb v4.4-2.6.22-common-4.
35709 +2007-07-17 Keith Owens <kaos@sgi.com>
35711 + * Make kdb_printf_lock an irq lock to keep lockdep happy.
35712 + * kdb v4.4-2.6.22-common-3.
35714 +2007-07-13 Keith Owens <kaos@sgi.com>
35716 + * Increase the size of the debug_alloc pool.
35717 + * Add the caller that obtained each entry in the debug_alloc pool.
35718 + * Poison entries in the debug_alloc pool.
35719 + * Track current and maximum usage in debug_alloc pool.
35720 + * Print the debug_alloc entries that are still in use when kdb exits
35722 + * Increase the default value of BTARGS to 9.
35723 + * kdb v4.4-2.6.22-common-2.
35725 +2007-07-09 Keith Owens <kaos@sgi.com>
35727 + * kdb v4.4-2.6.22-common-1.
35729 +2007-07-02 Keith Owens <kaos@sgi.com>
35731 + * kdb v4.4-2.6.22-rc7-common-1.
35733 +2007-06-20 Keith Owens <kaos@sgi.com>
35735 + * kdb v4.4-2.6.22-rc5-common-1.
35737 +2007-06-15 Keith Owens <kaos@sgi.com>
35739 + * Do not include asm/kdb.h unless CONFIG_KDB is on. Dave Jiang.
35740 + * kdb v4.4-2.6.22-rc4-common-2.
35742 +2007-06-08 Keith Owens <kaos@sgi.com>
35744 + * kdb v4.4-2.6.22-rc4-common-1.
35746 +2007-05-28 Keith Owens <kaos@sgi.com>
35748 + * kdb v4.4-2.6.22-rc3-common-1.
35750 +2007-05-22 Keith Owens <kaos@sgi.com>
35752 + * kdb v4.4-2.6.22-rc2-common-1.
35754 +2007-05-22 Keith Owens <kaos@sgi.com>
35756 + * kdb v4.4-2.6.22-rc1-common-1.
35758 +2007-05-17 Keith Owens <kaos@sgi.com>
35760 + * Add rdmsr and wrmsr commands for i386 and x86_64. Original patch by
35761 + Bernardo Innocenti for i386, reworked by Keith Owens to make it safe
35762 + on all cpu models and to handle both i386 and x86_64.
35763 + * kdb v4.4-2.6.21-common-3.
35765 +2007-05-15 Keith Owens <kaos@sgi.com>
35767 + * Correct alignment of debug_alloc_header.
35768 + * kdb v4.4-2.6.21-common-2.
35770 +2007-04-29 Keith Owens <kaos@sgi.com>
35772 + * kdb v4.4-2.6.21-common-1.
35774 +2007-04-16 Keith Owens <kaos@sgi.com>
35776 + * Remove dead symbol declarations.
35777 + * kdb v4.4-2.6.21-rc7-common-2.
35779 +2007-04-16 Keith Owens <kaos@sgi.com>
35781 + * kdb v4.4-2.6.21-rc7-common-1.
35783 +2007-04-10 Keith Owens <kaos@sgi.com>
35785 + * kdb v4.4-2.6.21-rc6-common-1.
35787 +2007-04-02 Keith Owens <kaos@sgi.com>
35789 + * kdb v4.4-2.6.21-rc5-common-1.
35791 +2007-03-19 Keith Owens <kaos@sgi.com>
35793 + * kdb v4.4-2.6.21-rc4-common-1.
35795 +2007-03-14 Keith Owens <kaos@sgi.com>
35797 + * kdb v4.4-2.6.21-rc3-common-1.
35799 +2007-03-14 Keith Owens <kaos@sgi.com>
35801 + * kdb v4.4-2.6.21-rc2-common-1.
35803 +2007-03-01 Keith Owens <kaos@sgi.com>
35805 + * kdb v4.4-2.6.21-rc1-common-1.
35807 +2007-03-01 Keith Owens <kaos@sgi.com>
35809 + * Remove sparse warnings.
35810 + * kdb v4.4-2.6.20-common-6.
35812 +2007-02-27 Keith Owens <kaos@sgi.com>
35814 + * set_irq_regs() on entry to kdb() if they are not already set.
35815 + * kdb v4.4-2.6.20-common-5.
35817 +2007-02-22 Keith Owens <kaos@sgi.com>
35819 + * Initialise struct disassemble_info in kdb_id1().
35820 + * kdb v4.4-2.6.20-common-4.
35822 +2007-02-16 Keith Owens <kaos@sgi.com>
35824 + * Clean up debug_alloc_pool code.
35825 + * kdb v4.4-2.6.20-common-3.
35827 +2007-02-16 Keith Owens <kaos@sgi.com>
35829 + * Initialise variable bits of struct disassemble_info each time.
35830 + * kdb v4.4-2.6.20-common-2.
35832 +2007-02-06 Keith Owens <kaos@sgi.com>
35834 + * kdb v4.4-2.6.20-common-1.
35836 +2007-02-01 Keith Owens <kaos@sgi.com>
35838 + * kdb v4.4-2.6.20-rc7-common-1.
35840 +2007-01-08 Keith Owens <kaos@sgi.com>
35842 + * kdb v4.4-2.6.20-rc4-common-1.
35844 +2007-01-02 Keith Owens <kaos@sgi.com>
35846 + * kdb v4.4-2.6.20-rc3-common-1.
35848 +2006-12-21 Keith Owens <kaos@sgi.com>
35850 + * Initialize the debug_kmalloc pool on the first call, so it can be
35851 + used at any time.
35852 + * kdb v4.4-2.6.20-rc1-common-2.
35854 +2006-12-20 Keith Owens <kaos@sgi.com>
35856 + * kdb v4.4-2.6.20-rc1-common-1.
35858 +2006-11-30 Keith Owens <kaos@sgi.com>
35860 + * kdb v4.4-2.6.19-common-1.
35862 +2006-11-30 Keith Owens <kaos@sgi.com>
35864 + * Do not access registers if kdb_current_regs is NULL.
35865 + * kdb v4.4-2.6.19-rc6-common-3.
35867 +2006-11-27 Keith Owens <kaos@sgi.com>
35869 + * Only use VT keyboard if the command line allows it and ACPI indicates
35870 + that there is an i8042.
35871 + * Optimize kdb_read() to reduce the risk of dropping input characters.
35872 + * Print cpumasks as lists instead of hex, also cope with long lists.
35873 + * kdb v4.4-2.6.19-rc6-common-2.
35875 +2006-11-20 Keith Owens <kaos@sgi.com>
35877 + * kdb v4.4-2.6.19-rc6-common-1.
35879 +2006-11-09 Keith Owens <kaos@sgi.com>
35881 + * Change kdb() to fastcall.
35882 + * Correct loop in kdb_help(). Georg Nikodym.
35883 + * Only use VT console if the command line allows it.
35884 + * kdb v4.4-2.6.19-rc5-common-2.
35886 +2006-11-08 Keith Owens <kaos@sgi.com>
35888 + * kdb v4.4-2.6.19-rc5-common-1.
35890 +2006-11-01 Keith Owens <kaos@sgi.com>
35892 + * kdb v4.4-2.6.19-rc4-common-1.
35894 +2006-10-24 Keith Owens <kaos@sgi.com>
35896 + * kdb v4.4-2.6.19-rc3-common-1.
35898 +2006-10-24 Keith Owens <kaos@sgi.com>
35900 + * Remove redundant regs and envp parameters.
35901 + * kdb v4.4-2.6.19-rc2-common-2.
35903 +2006-10-18 Keith Owens <kaos@sgi.com>
35905 + * kdb v4.4-2.6.19-rc2-common-1.
35907 +2006-10-11 Keith Owens <kaos@sgi.com>
35909 + * Move kdbm_x86.c from the i386 to the common KDB patch.
35910 + * Expand kdbm_x86.c to work on x86_64 as well as i386.
35911 + * kdb v4.4-2.6.19-rc1-common-2.
35913 +2006-10-09 Keith Owens <kaos@sgi.com>
35915 + * kdb v4.4-2.6.19-rc1-common-1.
35917 +2006-10-06 Keith Owens <kaos@sgi.com>
35919 + * Remove #include <linux/config.h>
35920 + * kdb v4.4-2.6.18-common-2.
35922 +2006-09-20 Keith Owens <kaos@sgi.com>
35924 + * kdb v4.4-2.6.18-common-1.
35926 +2006-09-15 Keith Owens <kaos@sgi.com>
35928 + * kdb v4.4-2.6.18-rc7-common-1.
35930 +2006-08-29 Keith Owens <kaos@sgi.com>
35932 + * Rewrite all backtrace code.
35933 + * kdb v4.4-2.6.18-rc5-common-2.
35935 +2006-08-28 Keith Owens <kaos@sgi.com>
35937 + * kdb v4.4-2.6.18-rc5-common-1.
35939 +2006-08-08 Keith Owens <kaos@sgi.com>
35941 + * kdb v4.4-2.6.18-rc4-common-1.
35943 +2006-08-04 Keith Owens <kaos@sgi.com>
35945 + * kdb v4.4-2.6.18-rc3-common-1.
35947 +2006-07-18 Keith Owens <kaos@sgi.com>
35949 + * 8250.c locking has been fixed so there is no need to break spinlocks
35950 + for keyboard entry.
35951 + * kdb v4.4-2.6.18-rc2-common-2.
35953 +2006-07-18 Keith Owens <kaos@sgi.com>
35955 + * kdb v4.4-2.6.18-rc2-common-1.
35957 +2006-07-12 Keith Owens <kaos@sgi.com>
35959 + * Remove dead KDB_REASON codes.
35960 + * The main kdb() function is now always entered with interrupts
35961 + disabled, so there is no need to disable bottom halves.
35962 + * sparse cleanups.
35963 + * kdb v4.4-2.6.18-rc1-common-2.
35965 +2006-07-07 Keith Owens <kaos@sgi.com>
35967 + * kdb v4.4-2.6.18-rc1-common-1.
35969 +2006-07-04 Keith Owens <kaos@sgi.com>
35971 + * Add KDB_REASON_CPU_UP and callbacks for cpus coming online.
35972 + * Relegate KDB_REASON_SILENT to KDB internal use only.
35973 + * Backout the v4.4-2.6.15-common-3 change that made KDB_REASON_SILENT
35974 + wait for cpus, the Dell Xeon problem has been fixed.
35975 + * notify_die() is not called for KDB_REASON_SILENT nor
35976 + KDB_REASON_CPU_UP, these events do not stay in KDB.
35977 + * Export kdb_current_task for kdbm_x86. SuSE patch
35978 + kdb-missing-export.diff
35979 + * Scale kdb_wait_for_cpus_secs by the number of online cpus.
35980 + * Delete kdb_enablehwfault, architectures now do their own setup.
35981 + * Delete kdba_enable_mce, architectures now do their own setup.
35982 + * Delete kdba_enable_lbr, kdba_disable_lbr, kdba_print_lbr,
35983 + page_fault_mca. Only ever implemented on x86, difficult to maintain
35984 + and rarely used in the field.
35985 + * Replace #ifdef KDB_HAVE_LONGJMP with #ifdef kdba_setjmp.
35986 + * kdb v4.4-2.6.17-common-2.
35988 +2006-06-19 Keith Owens <kaos@sgi.com>
35990 + * kdb v4.4-2.6.17-common-1.
35992 +2006-05-31 Keith Owens <kaos@sgi.com>
35994 + * Break spinlocks for keyboard entry. Hopefully a temporary hack while
35995 + I track down why keyboard entry to KDB is hanging.
35996 + * kdb v4.4-2.6.17-rc5-common-2.
35998 +2006-05-25 Keith Owens <kaos@sgi.com>
36000 + * kdb v4.4-2.6.17-rc5-common-1.
36002 +2006-05-15 Keith Owens <kaos@sgi.com>
36004 + * Refresh bfd related files from binutils 2.16.91.0.2.
36005 + * kdb v4.4-2.6.17-rc4-common-2.
36007 +2006-05-12 Keith Owens <kaos@sgi.com>
36009 + * kdb v4.4-2.6.17-rc4-common-1.
36011 +2006-04-28 Keith Owens <kaos@sgi.com>
36013 + * kdb v4.4-2.6.17-rc3-common-1.
36015 +2006-04-22 Keith Owens <kaos@sgi.com>
36017 + * kdb v4.4-2.6.17-rc2-common-1.
36019 +2006-04-11 Keith Owens <kaos@sgi.com>
36021 + * kdb v4.4-2.6.17-rc1-common-1.
36023 +2006-04-05 Keith Owens <kaos@sgi.com>
36025 + * More fixes for the timing race with KDB_ENTER_SLAVE.
36026 + * kdb v4.4-2.6.16-common-5.
36028 +2006-03-30 Keith Owens <kaos@sgi.com>
36030 + * Some code was testing KDB_IS_RUNNING() twice, which left it open to
36031 + races. Cache the result instead.
36032 + * kdb v4.4-2.6.16-common-4.
36034 +2006-03-30 Keith Owens <kaos@sgi.com>
36036 + * Change CONFIG_LKCD to CONFIG_LKCD_DUMP.
36037 + * kdb v4.4-2.6.16-common-3.
36039 +2006-03-22 Keith Owens <kaos@sgi.com>
36041 + * Add some more xpc flags. Dean Nelson, SGI.
36042 + * Replace open coded counter references with atomic_read().
36043 + * Pass early_uart_console to early_uart_setup(). Francois
36044 + Wellenreiter, Bull.
36045 + * Replace open code with for_each_online_cpu().
36046 + * If cpus do not come into kdb after a few seconds then let
36047 + architectures send a more forceful interrupt.
36048 + * Close a timing race with KDB_ENTER_SLAVE.
36049 + * kdb v4.4-2.6.16-common-2.
36051 +2006-03-21 Keith Owens <kaos@sgi.com>
36053 + * kdb v4.4-2.6.16-common-1.
36055 +2006-03-14 Nathan Scott <nathans@sgi.com>
36057 + * kdb v4.4-2.6.16-rc6-common-1.
36059 +2006-02-28 Nathan Scott <nathans@sgi.com>
36061 + * kdb v4.4-2.6.16-rc5-common-1.
36063 +2006-02-20 Nathan Scott <nathans@sgi.com>
36065 + * kdb v4.4-2.6.16-rc4-common-1.
36067 +2006-02-06 Keith Owens <kaos@sgi.com>
36069 + * Change CONFIG_CRASH_DUMP to CONFIG_LKCD.
36070 + * Remove obsolete kdb_notifier_list.
36071 + * kdb v4.4-2.6.16-rc2-common-2.
36073 +2006-02-06 Keith Owens <kaos@sgi.com>
36075 + * Add xpcusers command. Dean Nelson, SGI.
36076 + * kdb v4.4-2.6.16-rc2-common-1.
36078 +2006-02-02 Keith Owens <kaos@sgi.com>
36080 + * Check if we have a console before using it for KDB.
36081 + * kdb v4.4-2.6.16-rc1-common-3.
36083 +2006-02-01 Keith Owens <kaos@sgi.com>
36085 + * Add option 'R' to the pid command to reset to the original task.
36086 + * Include 'pid R' in archkdb* commands to reset up the original failing
36087 + task. Users may have switched to other cpus and/or tasks before
36089 + * Compile fix for kdbm_pg.c on i386.
36090 + * kdb v4.4-2.6.16-rc1-common-2.
36092 +2006-01-18 Keith Owens <kaos@sgi.com>
36094 + * kdb v4.4-2.6.16-rc1-common-1.
36096 +2006-01-11 Keith Owens <kaos@sgi.com>
36098 + * Plug a timing race between KDB_ENTER_SLAVE and KDB_ENTER, and allow
36099 + the cpu command to switch to a slave cpu.
36100 + * KDB_REASON_SILENT now waits for other cpus, to avoid spurious NMI
36101 + events that were seen on some Xeon systems.
36102 + * kdb v4.4-2.6.15-common-3.
36104 +2006-01-08 Keith Owens <kaos@sgi.com>
36106 + * kdb mainline invokes DIE_KDEBUG_ENTER and DIE_KDEBUG_LEAVE via
36108 + * Move xpc debug support from xpc to mainline kdb.
36109 + * kdbm_cm.c: check if file_lock_operations or lock_manager_operations
36110 + are set before dereferencing them. Felix Blyakher, SGI.
36111 + * kdb v4.4-2.6.15-common-2.
36113 +2006-01-04 Keith Owens <kaos@sgi.com>
36115 + * Print all buffers on a page in inode pages and update formatting to be
36116 + legible, too. David Chinner, SGI.
36117 + * Update page flags in kdbm_pg.
36118 + * Remove inline from *.c files.
36119 + * kdb v4.4-2.6.15-common-1.
36121 +2005-12-25 Keith Owens <kaos@sgi.com>
36123 + * kdb v4.4-2.6.15-rc7-common-1.
36125 +2005-12-20 Keith Owens <kaos@sgi.com>
36127 + * kdb v4.4-2.6.15-rc6-common-1.
36129 +2005-12-10 Keith Owens <kaos@sgi.com>
36131 + * Update mapping of flags to strings in kdbm_pg.c and kdbm_vm.c.
36132 + * kdb v4.4-2.6.15-rc5-common-3.
36134 +2005-12-06 Keith Owens <kaos@sgi.com>
36136 + * Add RECOVERY flag to global KDB flags.
36137 + * Add kdb_{save,restore}_flags.
36138 + * kdb v4.4-2.6.15-rc5-common-2.
36140 +2005-12-05 Keith Owens <kaos@sgi.com>
36142 + * kdb v4.4-2.6.15-rc5-common-1.
36144 +2005-12-02 Keith Owens <kaos@sgi.com>
36146 + * kdbm_vm.c: offsets of page macros should be unsigned long. Reported
36147 + by Dean Nelson, SGI.
36148 + * kdb v4.4-2.6.15-rc4-common-1.
36150 +2005-11-30 Keith Owens <kaos@sgi.com>
36152 + * New follow_page() API.
36153 + * kdb v4.4-2.6.15-rc3-common-1.
36155 +2005-11-21 Keith Owens <kaos@sgi.com>
36157 + * kdb v4.4-2.6.15-rc2-common-1.
36159 +2005-11-15 Keith Owens <kaos@sgi.com>
36161 + * kdb v4.4-2.6.15-rc1-common-1.
36163 +2005-11-15 Keith Owens <kaos@sgi.com>
36165 + * Allow kdb_printf() to be used outside kdb, in preemptible context.
36166 + * Build with CONFIG_SWAP=n. Reported by Leo Yuriev.
36167 + * kdb v4.4-2.6.14-common-2.
36169 +2005-10-28 Keith Owens <kaos@sgi.com>
36171 + * kdb v4.4-2.6.14-common-1.
36173 +2005-10-21 Keith Owens <kaos@sgi.com>
36175 + * kdb v4.4-2.6.14-rc5-common-1.
36177 +2005-10-11 Keith Owens <kaos@sgi.com>
36179 + * Handle removal of USB keyboard. Aaron Young, SGI.
36180 + * kdb v4.4-2.6.14-rc4-common-1.
36182 +2005-10-05 Keith Owens <kaos@sgi.com>
36184 + * Extend kdb_notifier_list() codes to include dumping.
36185 + * Use emergency_restart() for reboot, it can be called from interrupt
36186 + context, unlike machine_restart().
36187 + * kdb v4.4-2.6.14-rc3-common-1.
36189 +2005-09-21 Keith Owens <kaos@sgi.com>
36191 + * Support kdb_current_task in register display and modify commands.
36192 + * Document what changes kdb's notion of the current task.
36193 + * Update rd documentation for IA64.
36194 + * Move some definictions to kdbprivate.h and remove some unused symbol
36196 + * kdb v4.4-2.6.14-rc2-common-1.
36198 +2005-09-20 Keith Owens <kaos@sgi.com>
36200 + * Document IA64 handlers command.
36201 + * Add more fields to the task command.
36202 + * Cope with MCA/INIT handlers in the ps command.
36203 + * Namespace cleanup, delete unused exports, make some functions static.
36204 + * Add a kdb_notifier_list callback when kdb is about to reboot the
36206 + * kdb v4.4-2.6.14-rc1-common-1.
36208 +2005-08-29 Keith Owens <kaos@sgi.com>
36210 + * kdb v4.4-2.6.13-common-1.
36212 +2005-08-24 Keith Owens <kaos@sgi.com>
36214 + * kdb v4.4-2.6.13-rc7-common-1.
36216 +2005-08-08 Keith Owens <kaos@sgi.com>
36218 + * kdb v4.4-2.6.13-rc6-common-1.
36220 +2005-08-02 Keith Owens <kaos@sgi.com>
36222 + * Print more fields from filp, dentry.
36223 + * Add kdb=on-nokey to suppress kdb entry from the keyboard.
36224 + * kdb v4.4-2.6.13-rc5-common-1.
36226 +2005-07-30 Keith Owens <kaos@sgi.com>
36228 + * kdb v4.4-2.6.13-rc4-common-1.
36230 +2005-07-26 Keith Owens <kaos@sgi.com>
36232 + * Fix compile problem with CONFIG_USB_KBD.
36233 + * kdb v4.4-2.6.13-rc3-common-3.
36235 +2005-07-22 Keith Owens <kaos@sgi.com>
36237 + * The asmlinkage kdb() patch was lost during packaging. Reinstate it.
36238 + * kdb v4.4-2.6.13-rc3-common-2.
36240 +2005-07-19 Keith Owens <kaos@sgi.com>
36242 + * Add support for USB keyboard (OHCI only). Aaron Young, SGI.
36243 + * kdb v4.4-2.6.13-rc3-common-1.
36245 +2005-07-08 Keith Owens <kaos@sgi.com>
36247 + * kdb v4.4-2.6.13-rc2-common-1.
36249 +2005-07-01 Keith Owens <kaos@sgi.com>
36251 + * Make kdb() asmlinkage to avoid problems with CONFIG_REGPARM.
36252 + * Change some uses of smp_processor_id() to be preempt safe.
36253 + * Use DEFINE_SPINLOCK().
36254 + * kdb v4.4-2.6.13-rc1-common-1.
36256 +2005-06-18 Keith Owens <kaos@sgi.com>
36258 + * kdb v4.4-2.6.12-common-1.
36260 +2005-06-08 Keith Owens <kaos@sgi.com>
36262 + * Correct early exit from bd *.
36263 + * kdb v4.4-2.6.12-rc6-common-1.
36265 +2005-05-25 Keith Owens <kaos@sgi.com>
36267 + * Delete Documentation/kdb/dump.txt. lkcd now has reasonable
36268 + integration with kdb.
36269 + * kdb v4.4-2.6.12-rc5-common-1.
36271 +2005-05-08 Keith Owens <kaos@sgi.com>
36273 + * kdb v4.4-2.6.12-rc4-common-1.
36275 +2005-04-21 Keith Owens <kaos@sgi.com>
36277 + * Add rpte command (find the pte for a physical page).
36278 + * kdb v4.4-2.6.12-rc3-common-1.
36280 +2005-04-06 Keith Owens <kaos@sgi.com>
36282 + * Add rq and rqa commands. John Hawkes, SGI.
36283 + * kdb v4.4-2.6.12-rc2-common-1.
36285 +2005-03-29 Keith Owens <kaos@sgi.com>
36287 + * Use register_sysctl_table() instead of patching kernel/sysctl.c.
36288 + * Non-ASCII characters are not printable.
36289 + * kdb v4.4-2.6.12-rc1-common-1.
36291 +2005-03-15 Keith Owens <kaos@sgi.com>
36293 + * More coexistence patches for lkcd. Jason Uhlenkott, SGI.
36294 + * kdb v4.4-2.6.11-common-3.
36296 +2005-03-08 Keith Owens <kaos@sgi.com>
36298 + * Coexistence patches for lkcd. Jason Uhlenkott, SGI.
36299 + * kdb v4.4-2.6.11-common-2.
36301 +2005-03-03 Keith Owens <kaos@sgi.com>
36303 + * Add kdb to drivers/serial/8250_early.c. Francois Wellenreiter, Bull.
36304 + * kdb v4.4-2.6.11-common-1.
36306 +2005-02-14 Keith Owens <kaos@sgi.com>
36308 + * kdb v4.4-2.6.11-rc4-common-1.
36310 +2005-02-08 Keith Owens <kaos@sgi.com>
36312 + * kdb v4.4-2.6.11-rc3-bk4-common-1.
36314 +2005-02-03 Keith Owens <kaos@sgi.com>
36316 + * Print more superblock fields. Nathan Scott, SGI.
36317 + * Remove kallsyms correction for modules, Linus took it.
36318 + * kdb v4.4-2.6.11-rc3-common-1.
36320 +2005-01-27 Keith Owens <kaos@sgi.com>
36322 + * Add bio command. Nathan Scott, SGI.
36323 + * kdb v4.4-2.6.11-rc2-common-1.
36325 +2005-01-20 Keith Owens <kaos@sgi.com>
36327 + * Include kallsyms correction for modules until Linus takes it.
36328 + * kdb v4.4-2.6.11-rc1-bk7-common-1.
36330 +2005-01-12 Keith Owens <kaos@sgi.com>
36332 + * kallsyms now supports all symbols properly, remove kdb patch.
36333 + * Add last ditch allocator for debugging.
36334 + * Update kdb_meminfo_read_proc() for vmalloc changes.
36335 + * Update kdbm_vm.c for 4 level page tables.
36336 + * kdb v4.4-2.6.11-rc1-common-1.
36338 +2004-12-25 Keith Owens <kaos@sgi.com>
36340 + * Add kobject command.
36341 + * Ignore low addresses and large offsets in kdbnearsym().
36342 + * Console updates for sn2 simulator.
36343 + * kdb v4.4-2.6.10-common-1.
36345 +2004-12-07 Keith Owens <kaos@sgi.com>
36347 + * kdb v4.4-2.6.10-rc3-common-1.
36349 +2004-11-23 Keith Owens <kaos@sgi.com>
36351 + * Remove warning message from kdb_get_one_user_page(), it was too noisy.
36352 + * kdb v4.4-2.6.10-rc2-common-1.
36354 +2004-11-02 Keith Owens <kaos@sgi.com>
36356 + * Build with kdb patch applied but CONFIG_KDB=n.
36357 + * kdb v4.4-2.6.10-rc1-common-2.
36359 +2004-10-29 Keith Owens <kaos@sgi.com>
36361 + * Handle new compression scheme for kallsyms.
36362 + * Handle move of DEAD and ZOMBIE for task->state to task->exit_state.
36363 + * Tweak the concept of a valid kernel address to get all symbols,
36364 + including the symbols in the ia64 gate page.
36365 + * kdb v4.4-2.6.10-rc1-common-1.
36367 +2004-10-21 Keith Owens <kaos@sgi.com>
36369 + * Handle variable size for the kernel log buffer.
36370 + * kdb v4.4-2.6.9-common-2.
36372 +2004-10-19 Keith Owens <kaos@sgi.com>
36374 + * kdb v4.4-2.6.9-common-1.
36376 +2004-10-12 Keith Owens <kaos@sgi.com>
36378 + * kdb v4.4-2.6.9-rc4-common-1.
36380 +2004-10-01 Keith Owens <kaos@sgi.com>
36382 + * kdb v4.4-2.6.9-rc3-common-1.
36384 +2004-09-30 Keith Owens <kaos@sgi.com>
36386 + * Add stackdepth command to Documentation/kdb/kdb.mm. stackdepth is
36387 + only supported on i386 and ia64 at the moment.
36388 + * Skip kdbm_pg memmap build on x86_64. Scott Lurndal, 3leafnetworks.
36389 + * Export kdb_serial_str for modular I/O. Bryan Cardillo, UPenn.
36390 + * Reinstate tab completion for symbols.
36391 + * kdb v4.4-2.6.9-rc2-common-2.
36393 +2004-09-14 Keith Owens <kaos@sgi.com>
36395 + * Add task states C (traCed) and E (dEad).
36396 + * kdb v4.4-2.6.9-rc2-common-1.
36398 +2004-08-27 Keith Owens <kaos@sgi.com>
36400 + * kdb v4.4-2.6.9-rc1-common-1.
36402 +2004-08-14 Keith Owens <kaos@sgi.com>
36404 + * kdb v4.4-2.6.8-common-1.
36406 +2004-08-12 Keith Owens <kaos@sgi.com>
36408 + * kdb v4.4-2.6.8-rc4-common-1.
36410 +2004-08-05 Keith Owens <kaos@sgi.com>
36412 + * Mark kdb_initcall as __attribute_used__ for newer gcc.
36413 + * kdb v4.4-2.6.8-rc3-common-2.
36415 +2004-08-04 Keith Owens <kaos@sgi.com>
36417 + * Add mdp (memory display physical) comnmand.
36418 + Ananth N Mavinakayanahalli, IBM.
36419 + * kdb v4.4-2.6.8-rc3-common-1.
36421 +2004-07-18 Keith Owens <kaos@sgi.com>
36423 + * Patch for new sn_console. Erik Jacobson. SGI.
36424 + * kdb v4.4-2.6.8-rc2-common-1.
36426 +2004-07-12 Keith Owens <kaos@sgi.com>
36428 + * Convert kdbm_task to standard cpumask_t.
36429 + * Document '*' (all breakpoints) option on bd/be/bc commands.
36430 + * kdb v4.4-2.6.8-rc1-common-1.
36432 +2004-06-30 Keith Owens <kaos@sgi.com>
36434 + * Common changes to help the x86-64 port.
36435 + * kdb v4.4-2.6.7-common-3.
36437 +2004-06-20 Keith Owens <kaos@sgi.com>
36439 + * Move kdb includes in mm/swapfile.c to reduce conflicts with other
36441 + * kdb v4.4-2.6.7-common-2.
36443 +2004-06-16 Keith Owens <kaos@sgi.com>
36445 + * kdb v4.4-2.6.7-common-1.
36447 +2004-06-09 Keith Owens <kaos@sgi.com>
36449 + * kdb v4.4-2.6.7-rc3-common-1.
36451 +2004-06-09 Keith Owens <kaos@sgi.com>
36453 + * Namespace clean up. Mark code/variables as static when it is only
36454 + used in one file, delete dead code/variables.
36455 + * Saved interrupt state requires long, not int.
36456 + * kdb v4.4-2.6.7-rc2-common-3.
36458 +2004-06-08 Keith Owens <kaos@sgi.com>
36460 + * Whitespace clean up, no code changes.
36461 + * kdb v4.4-2.6.7-rc2-common-2.
36463 +2004-06-07 Keith Owens <kaos@sgi.com>
36465 + * kdb v4.4-2.6.7-rc2-common-1.
36467 +2004-06-06 Keith Owens <kaos@sgi.com>
36469 + * Avoid recursion problems in kdb_init().
36470 + * Add standard archkdb commands.
36471 + * Add per_cpu command.
36472 + * Move kdb_{get,put}userarea_size definitions to linux/kdb.h.
36473 + * kdb v4.4-2.6.6-common-2.
36475 +2004-05-23 Keith Owens <kaos@sgi.com>
36477 + * Shrink the output from the cpu command.
36478 + * Add cpu state 'I', the cpu is idle.
36479 + * Add cpu state '+', some kdb data is available but the cpu is not
36481 + * Do not print tasks in state I or M by default in ps and bta commands.
36482 + * Add states I (idle task) and M (sleeping system daemon) to ps and
36484 + * Delete unused variables.
36485 + * Move private kdb fields from kdb.h to kdbprivate.h.
36486 + * Print 'for keyboard entry' for the special cases when KDB_ENTER() is
36487 + used to get registers.
36488 + * Move bfd.h and ansidecl.h from arch/$(ARCH)/kdb to include/asm-$(ARCH)
36489 + and remove -I arch/$(ARCH)/kdb.
36490 + * dmesg command now prints from either the start or end of dmesg, or at
36491 + an arbitrary point in the middle of the kernel log buffer.
36492 + * Sensible string dump for multi byte md commands.
36493 + * 'page' command handles ia64 correctly.
36494 + * Show some activity when waiting for cpus to enter kdb.
36495 + * Change the KDB entry code to <esc>KDB.
36496 + * Allow comment commands, starting with '#'.
36497 + * Commands defined using defcmd from kdb_cmds are not printed as they
36498 + are entered, use defcmd with no parameters to print all the defined
36500 + * Add summary command.
36501 + * Update copyright notices.
36502 + * Zero suppression on md command.
36503 + * Make set NOSECT=1 the default.
36504 + * PPC64 uses OF-stdout instead of console. Ananth N Mavinakayanahalli.
36505 + * kdb v4.4-2.6.6-common-1.
36507 +2004-05-10 Keith Owens <kaos@sgi.com>
36509 + * kdb v4.3-2.6.6-common-1.
36511 +2004-05-06 Keith Owens <kaos@sgi.com>
36513 + * kdb v4.3-2.6.6-rc3-common-1.
36515 +2004-05-06 Keith Owens <kaos@sgi.com>
36517 + * kdb v4.3-2.6.6-rc2-common-1.
36519 +2004-04-30 Keith Owens <kaos@sgi.com>
36521 + * Rewrite inode_pages command for new radix code in struct page.
36522 + * kdb v4.3-2.6.6-rc1-common-1.
36524 +2004-04-11 Keith Owens <kaos@sgi.com>
36526 + * Unlock sn_sal_lock before entering kdb from sn_serial.
36527 + * kdb v4.3-2.6.5-common-2.
36529 +2004-04-05 Keith Owens <kaos@sgi.com>
36531 + * kdb v4.3-2.6.5-common-1.
36533 +2004-03-22 Keith Owens <kaos@sgi.com>
36535 + * kdb v4.3-2.6.5-rc2-common-1.
36537 +2004-03-12 Keith Owens <kaos@sgi.com>
36539 + * More work to avoid spurious messages from WARN_CONSOLE_UNLOCKED().
36540 + * bh command bug fixes. Nathan Scott.
36541 + * kdb v4.3-2.6.4-common-1.
36543 +2004-03-06 Keith Owens <kaos@sgi.com>
36545 + * Set KDB_IS_RUNNING() during kdb_init to avoid spurious messages from
36546 + WARN_CONSOLE_UNLOCKED().
36547 + * Correct loss of symbol names in kdbnearsym.
36548 + * kdb v4.3-2.6.4-rc2-common-1.
36550 +2004-02-29 Keith Owens <kaos@sgi.com>
36552 + * kdb v4.3-2.6.4-rc1-common-1.
36554 +2004-02-21 Keith Owens <kaos@sgi.com>
36556 + * Correct build of kdb_cmds when using a separate object directory and
36557 + make it quiet. j-nomura (NEC), Keith Owens.
36558 + * kdb v4.3-2.6.3-common-2.
36560 +2004-02-18 Keith Owens <kaos@sgi.com>
36562 + * kdb v4.3-2.6.3-common-1.
36564 +2004-02-17 Keith Owens <kaos@sgi.com>
36566 + * Remove WAR for incorrect console registration patch.
36567 + * kdb v4.3-2.6.3-rc4-common-1.
36569 +2004-02-17 Keith Owens <kaos@sgi.com>
36571 + * Convert longjmp buffers from static to dynamic allocation, for large
36573 + * Tweak kdbm_task for SMP/UP.
36574 + * Reconcile with kdb-v4.3 2.4.25-rc1-common-1.
36575 + * Simplify coexistence with NPTL patches.
36576 + * Support kill command on new scheduler.
36577 + * Do not refetch data when printing a value as characters.
36578 + * Document the pid command.
36579 + * Work around 2.6 kallsyms 'feature'.
36580 + * Upgrade to 2.6.3-rc3.
36581 + * WAR for incorrect console registration patch.
36582 + * kdb v4.3-2.6.3-rc3-common-1.
36584 +2003-12-03 Keith Owens <kaos@sgi.com>
36586 + * Reconcile 2.6-test versions from Xavier Bru (Bull), Greg Banks (SGI),
36587 + Jim Houston (Concurrent Computer Corp).
36588 + * Reconcile with kdb v4.3-2.4.23-common-2.
36589 + * Clean up CONFIG_KDB changes to {scripts,kernel}/kallsyms.c.
36590 + * Correct handling of kdb command line arguments.
36591 + * Make hooks into module code less intrusive.
36592 + * Delete kdb_active_task, not required with O(1) scheduler.
36593 + * Port kdbm_task.c from 2.4.
36594 + * Disable debug check in exit.c::next_thread() when kdb is running.
36595 + * Remove "only bh_disable when interrupts are set". BH must be disabled
36596 + in kdb to prevent deadlock on breakpoints in interrupt handlers.
36597 + * Add kdb to drivers/char/sn_serial.c.
36598 + * kdb v4.3-2.6.0-test11-common-1.
36600 +2003-11-11 Xavier Bru <xavier.bru@bull.net>
36601 + * Merge to 2.6.0-test9
36602 +2003-10-17 Xavier Bru <xavier.bru@bull.net>
36603 + * fix NUll ptr in kdb_ps at early prompt.
36604 +2003-10-14 Xavier Bru <xavier.bru@bull.net>
36605 + * fix NUll ptr in kdb_ps when cpu not present.
36606 +2003-10-06 Xavier Bru <xavier.bru@bull.net>
36607 + * Merge to 2.6.0-test5
36608 + * fix compile error with CONFIG_MODULES not set.
36610 +2003-09-08 Xavier Bru <xavier.bru@bull.net>
36611 + * Merge to 2.6.0-test4
36613 +2003-07-10 Xavier Bru <xavier.bru@bull.net>
36615 + * Merge kdb v4.3 to 2.5.72 ia64
36616 + * don't call local_bh_enable() with interrupts masked.
36618 +2003-04-07 Xavier Bru <xavier.bru@bull.net>
36620 + * Merge kdb v4.1 to 2.5.64 ia64
36621 + * new kernel parameters support
36622 + * new module format
36623 + * new kallsyms support
36625 +2003-12-02 Keith Owens <kaos@sgi.com>
36627 + * Use correct page alignment in kdb_get_one_user_page().
36628 + Prasanna S Panchamukhi, IBM.
36629 + * Split pte command into pte -m and pte -p. Dean Roe, SGI.
36630 + * kdb v4.3-2.4.23-common-2.
36632 +2003-12-01 Keith Owens <kaos@sgi.com>
36634 + * kdb v4.3-2.4.23-common-1.
36636 +2003-11-11 Keith Owens <kaos@sgi.com>
36638 + * Make KDB for USB keyboards build. Peter T. Breuer.
36639 + * Do not use USB keyboard if it has not been probed.
36640 + * kdb v4.3-2.4.23-rc1-common-1.
36642 +2003-10-10 Keith Owens <kaos@sgi.com>
36644 + * Sync with XFS 2.4.22 tree.
36645 + * kdb v4.3-2.4.22-common-2.
36647 +2003-08-29 Keith Owens <kaos@sgi.com>
36649 + * kdb v4.3-2.4.22-common-1.
36651 +2003-07-27 Keith Owens <kaos@sgi.com>
36653 + * kdb v4.3-2.4.22-pre8-common-8.
36655 +2003-07-20 Keith Owens <kaos@sgi.com>
36657 + * Make kdb_serial_str a common constant, the same for all consoles.
36658 + * Support SGI L1 console.
36659 + * kdb v4.3-2.4.21-common-8.
36661 +2003-07-14 Keith Owens <kaos@sgi.com>
36663 + * Correct ll command.
36664 + * kdb v4.3-2.4.21-common-7.
36666 +2003-07-08 Keith Owens <kaos@sgi.com>
36668 + * Export more kdb symbols. Vamsi Krishna S., IBM.
36669 + * kdb v4.3-2.4.21-common-6.
36671 +2003-07-07 Keith Owens <kaos@sgi.com>
36673 + * Tweak 'waiting for cpus' message.
36674 + * kdb v4.3-2.4.21-common-5.
36676 +2003-07-07 Keith Owens <kaos@sgi.com>
36678 + * 2.4.21-ia64-030702 patches common code that affects kdb. Workaround
36680 + * kdb v4.3-2.4.21-common-4.
36682 +2003-06-24 Keith Owens <kaos@sgi.com>
36684 + * Add task and sigset commands. Mark Goodwin, SGI.
36685 + * kdb v4.3-2.4.21-common-3.
36687 +2003-06-23 Keith Owens <kaos@sgi.com>
36689 + * Sync with XFS 2.4.21 tree.
36690 + * kdb v4.3-2.4.21-common-2.
36692 +2003-06-20 Keith Owens <kaos@sgi.com>
36694 + * kdb v4.3-2.4.21-common-1.
36696 +2003-06-20 Keith Owens <kaos@sgi.com>
36698 + * More details on vm command, add vmp and pte commands.
36699 + Dean Nelson, Dean Roe, SGI.
36700 + * YAO1SCF (Yet Another O(1) Scheduler Coexistence Fix).
36701 + * Changes to common code to build on sparc. Tom Duffy.
36702 + * Move Tom Duffy's changes to drivers/sbus from the sparc64
36703 + patch to the common patch to keep all the serial changes
36705 + * Changes to common code to build on Xscale. Eddie Dong, Intel.
36706 + * Remove CROSS_COMPILE_INC.
36707 + * Remove obsolete boot parameter 'kdb', long since replaced by
36709 + * Remove obsolete kdb_eframe_t casts.
36710 + * Add CONFIG_KDB_CONTINUE_CATASTROPHIC.
36711 + * Wait a short interval for cpus to join kdb before proceeding.
36712 + * Automatically enable sysrq for sr command.
36713 + * Correct double free of kdb_printf lock, spotted by Richard Sanders.
36714 + * Add optional cpu parameter to btc command.
36715 + * kdb v4.3-2.4.20-common-1.
36717 +2003-05-02 Keith Owens <kaos@sgi.com>
36719 + * Some architectures have problems with the initial empty kallsyms
36720 + section so revert to three kallsyms passes.
36721 + * Flush buffered input at startup and at 'more' prompt.
36722 + * Only print 'more' prompt when longjmp data is available.
36723 + * Print more data for buffers and inodes.
36724 + * Disable kill command when O(1) scheduler is installed, the code
36725 + needs to be redone for O(1).
36726 + * The kernel has an undocumented assumption that enable_bh() is
36727 + always called with interrupts enabled, make it so.
36728 + * Print trailing punctuation even for symbols that are not in kernel.
36729 + * Add read/write access to user pages. Vamsi Krishna S., IBM
36730 + * Rename cpu_is_online to cpu_online, as in 2.5.
36731 + * O(1) scheduler removes init_task so kdb maintains its own list of
36733 + * Delete btp 0 <cpuid> option, it needed init_tasks.
36734 + * Clean up USB keyboard support. Steven Dake.
36735 + * Sync with XFS 2.4.20 tree.
36736 + * kdb v4.2-2.4.20-common-1.
36738 +2003-04-04 Keith Owens <kaos@sgi.com>
36740 + * Remove one kallsyms pass.
36741 + * Automatic detection of O(1) scheduler.
36742 + * Rename cpu_online to cpu_is_online.
36743 + * Workarounds for scheduler bugs.
36744 + * Tweak algorithm for detecting if cpu process data is available.
36745 + * Add 'kill' command. Sonic Zhang, Keith Owens.
36746 + * kdb v4.1-2.4.20-common-1.
36748 +2003-03-16 Keith Owens <kaos@sgi.com>
36750 + * Each cpu saves its state as it enters kdb or before it enters code
36751 + which cannot call kdb.
36752 + * Allow btp on process 0 for a specified cpu.
36753 + * Add btt command, backtrace given a struct task address.
36754 + * btc command no longer switches cpus, instead it uses the saved data.
36755 + * bta shows the idle task on each cpu as well as real tasks, the idle
36756 + task could be handling an interrupt.
36757 + * ps command shows the idle task on each cpu.
36758 + * ps checks that the saved data for a cpu matches the process running on
36759 + that cpu and warns about stale saved data or no saved data at all.
36760 + * Remove special cases for i386 backtrace from common code and simplify
36762 + * Clean up kdb interaction with CONFIG_SERIAL_CONSOLE.
36763 + * Do not automatically repeat commands after the user typed 'q'.
36764 + * O(1) scheduler patch changes the process cpu field but does not set
36765 + any indicator that O(1) is being used. Adjust kdb_process_cpu() by
36766 + hand after applying O(1).
36767 + * Add kdb_print_nameval() to common code.
36768 + * Convert tests of cpu_online_map to cpu_online() macro.
36769 + * module.h needs errno.h when compiling with CONFIG_MODULES=n.
36770 + * Correct duplicate breakpoint handling.
36771 + * Do not try to send IPI during a catastrophic error, send_ipi can hang
36772 + and take kdb with it.
36773 + * kdb memmap command is i386 only, restrict it.
36774 + * Add large block device (LBD) support from XFS tree. Eric Sandeen.
36775 + * kdb v4.0-2.4.20-common-1.
36777 +2003-02-03 Keith Owens <kaos@sgi.com>
36779 + * Register kdb commands early.
36780 + * Decode oops via kallsyms if it is available.
36781 + * Update copyright notices to 2003.
36782 + * Add defcmd/endefcmd to allow users to package their own macros.
36783 + * kdb commands that fail are ignored when prefixed with '-'.
36784 + * Add selection options to bta command.
36785 + * Add btc command (switch to each cpu and backtrace).
36786 + * Do real time detection of dead cpus.
36787 + * Clear ip adjusted flag when leaving kdb.
36788 + * Clean up ps command.
36789 + * Print ps output for each task when backtracing.
36790 + * Bump to version v3.0 to reduce confusion between kdb and kernel
36792 + * Add kdba_local_arch_setup/kdba_local_arch_cleanup to correct
36793 + keyboard freeze. Ashish Kalra.
36794 + * Refuse multiple breakpoints at the same address.
36795 + * Add fl (file_lock) command, from XFS development tree.
36796 + * Correct inode_pages, from XFS development tree.
36797 + * Add command history and editing. Sonic Zhang.
36798 + * Extend command history and editing to handle vt100 escape sequences.
36799 + * Allow tab completion at start of line.
36800 + * Touch nmi watchdog on long running bta and btc commands.
36801 + * Clean up ps output and standardize with bta codes.
36802 + * Correctly handle escaped characters in commands.
36803 + * Update man pages for btc and command history/editing.
36804 + * kdb v3.0-2.4.20-common-1.
36806 +2002-11-29 Keith Owens <kaos@sgi.com>
36808 + * Upgrade to 2.4.20.
36809 + * Correct Documentation/kdb/kdb_sr.man.
36810 + * Remove leading zeroes from pids, they are decimal, not octal.
36811 + * kdb v2.5-2.4.20-common-1.
36813 +2002-11-14 Keith Owens <kaos@sgi.com>
36815 + * Upgrade to 2.4.20-rc1.
36816 + * kdb v2.5-2.4.20-rc1-common-1.
36818 +2002-11-14 Keith Owens <kaos@sgi.com>
36820 + * Fix processing with O(1) scheduler.
36821 + * 'go' switches back to initial cpu first.
36822 + * 'go <address>' only allowed on initial cpu.
36823 + * 'go' installs the global breakpoints from the initial cpu before
36824 + releasing the other cpus.
36825 + * If 'go' has to single step over a breakpoint then it single steps just
36826 + the initial cpu, installs the global breakpoints then releases the
36828 + * General clean up of handling for breakpoints and single stepping over
36829 + software breakpoints.
36830 + * Add kdb_notifier_block so other code can tell when kdb is in control.
36831 + * kdb v2.5-2.4.19-common-1.
36833 +2002-11-02 Keith Owens <kaos@sgi.com>
36835 + * Correct build without CONFIG_KDB.
36836 + * kdb v2.4-2.4.19-common-3.
36838 +2002-11-01 Keith Owens <kaos@sgi.com>
36840 + * Minimize differences from 2.5.44.
36841 + * kdb v2.4-2.4.19-common-2.
36843 +2002-10-31 Keith Owens <kaos@sgi.com>
36845 + * Add defcmd/endefcmd feature.
36846 + * Remove kdb_eframe_t.
36847 + * Clear bp data before using.
36848 + * Sanity check if we have pt_regs.
36849 + * Force LINES > 1.
36850 + * Remove special case for KDB_REASON_PANIC, use KDB_ENTER() instead.
36851 + * Remove kdba_getcurrentframe().
36852 + * Coexist with O(1) scheduler.
36853 + * Add lines option to dmesg, speed up dmesg.
36854 + * kdb v2.4-2.4.19-common-1.
36856 +2002-10-17 Keith Owens <kaos@sgi.com>
36858 + * Add selection critera to ps and bta commands.
36859 + * kdb v2.3-2.4.19-common-4.
36861 +2002-10-07 Keith Owens <kaos@sgi.com>
36863 + * New man page, Documentation/kdb/kdb_sr.man.
36865 +2002-10-04 Keith Owens <kaos@sgi.com>
36867 + * Minimize differences between patches for 2.4 and 2.5 kernels.
36868 + * Add Configure.help for CONFIG_KDB_USB.
36869 + * Reduce stack usage.
36870 + * kdb v2.3-2.4.19-common-3.
36872 +2002-08-10 Keith Owens <kaos@sgi.com>
36874 + * Replace kdb_port with kdb_serial to support memory mapped I/O.
36876 + * kdb v2.3-2.4.19-common-2.
36878 +2002-08-07 Keith Owens <kaos@sgi.com>
36880 + * Upgrade to 2.4.19.
36881 + * Remove individual SGI copyrights, the general SGI copyright applies.
36882 + * Handle md0. Reported by Hugh Dickins, different fix by Keith Owens.
36883 + * Use page_address() in kdbm_pg.c. Hugh Dickins.
36884 + * Remove debugging printk from kdbm_pg.c. Hugh Dickins.
36885 + * Move breakpoint address verification into arch dependent code.
36886 + * Dynamically resize kdb command table as required.
36887 + * Common code to support USB keyboard. Sebastien Lelarge.
36888 + * kdb v2.3-2.4.19-common-1.
36890 +2002-07-09 Keith Owens <kaos@sgi.com>
36892 + * Upgrade to 2.4.19-rc1.
36893 + * Add dmesg command.
36894 + * Clean up copyrights, Eric Sandeen.
36895 + * kdb v2.2-2.4.19-rc1-common-1.
36897 +2002-06-14 Keith Owens <kaos@sgi.com>
36899 + * Upgrade to 2.4.19-pre10.
36901 + * kdb v2.1-2.4.19-pre10-common-1.
36903 +2002-04-09 Keith Owens <kaos@sgi.com>
36905 + * Upgrade to 2.4.19-pre6.
36906 + * kdb v2.1-2.4.19-pre6-common-1.
36908 +2002-03-18 Keith Owens <kaos@sgi.com>
36910 + * Syntax check mdWcN commands.
36912 +2002-03-01 Keith Owens <kaos@sgi.com>
36914 + * Sync with XFS 2.4.18.
36915 + * kdb v2.1-2.4.18-common-2.
36917 +2002-02-26 Keith Owens <kaos@sgi.com>
36919 + * Upgrade to 2.4.18.
36920 + * Add Paul Dorwin (IBM) magicpoint slides on using kdb as
36921 + Documentation/kdb/slides.
36922 + * kdb v2.1-2.4.18-common-1.
36924 +2002-01-23 Keith Owens <kaos@sgi.com>
36926 + * Sync with XFS pagebuf changes.
36927 + * kdb v2.1-2.4.17-common-2.
36929 +2002-01-18 Keith Owens <kaos@sgi.com>
36931 + * Ignore single stepping during panic.
36932 + * Remove kdba_getword, kdba_putword. Replace with kdb_getword,
36933 + kdb_putword that rely on copy_xx_user. The new functions return
36934 + an error code, like copy_xx_user.
36935 + * New functions kdb_getarea, kdb_putarea for copying areas of data
36936 + such as structures. These functions also return an error code.
36937 + * Change all common code to use the new functions.
36938 + * bp command checks that it can read and write the word at the
36939 + breakpoint before accepting the address.
36940 + * Break points are now set FIFO and cleared LIFO so overlapping
36941 + entries give sensible results.
36942 + * Verify address before disassembling code.
36943 + * Common changes for sparc64. Ethan Solomita, Tom Duffy.
36944 + * Remove ss <count>, never supported.
36945 + * Remove kallsyms entries from arch vmlinux.lds files.
36946 + * Specify which commands auto repeat.
36947 + * kdb v2.1-2.4.17-common-1.
36949 +2002-01-07 Keith Owens <kaos@sgi.com>
36951 + * Remove console semaphore code, not good in interrupt.
36952 + * Remove fragment of ia64 patch that had crept into kdb.
36953 + * Release as kdb v2.0-2.4.17-common-3.
36955 +2002-01-04 Keith Owens <kaos@sgi.com>
36957 + * Sync xfs <-> kdb common code.
36959 +2001-12-22 Keith Owens <kaos@sgi.com>
36961 + * Upgrade to 2.4.17.
36962 + * Clean up ifdef CONFIG_KDB.
36963 + * Add ifdef CONFIG_KDB around include kdb.h.
36964 + * Delete dummy kdb.h files for unsupported architectures.
36965 + * Delete arch i386 and ia64 specific files. This changelog now
36966 + applies to kdb common code only.
36967 + * Release as kdb v2.0-2.4.17-common-1.
36969 +2001-12-03 Keith Owens <kaos@sgi.com>
36971 + * Upgrade to 2.4.16.
36972 + * Add include/asm-um/kdb.h stub to allow XFS to be tested under UML.
36973 + * Check if an interrupt frame on i386 came from user space.
36974 + * Out of scope bug fix in kdb_id.c. Ethan Solomita.
36975 + * Changes to common code to support sparc64. Ethan Solomita.
36976 + * Change GFP_KERNEL to GFP_ATOMIC in disasm. Ethan Solomita.
36978 +2001-11-16 Keith Owens <kaos@sgi.com>
36980 + * Upgrade to 2.4.15-pre5.
36981 + * Wrap () around #define expressions with unary operators.
36983 +2001-11-13 Keith Owens <kaos@sgi.com>
36985 + * Upgrade to 2.4.15-pre4.
36986 + * kbdm_pg.c patch from Hugh Dickins.
36988 +2001-11-07 Keith Owens <kaos@sgi.com>
36990 + * Upgrade to 2.4.14-ia64-011105.
36991 + * Change name of l1 serial I/O routine, add ia64 init command. SGI.
36992 + * Sync kdbm_pg with XFS.
36994 +2001-11-06 Keith Owens <kaos@sgi.com>
36996 + * Upgrade to kernel 2.4.14.
36998 +2001-11-02 Keith Owens <kaos@sgi.com>
37000 + * Sync kdbm_pg.c with XFS.
37002 +2001-10-24 Keith Owens <kaos@sgi.com>
37004 + * Upgrade to kernel 2.4.13.
37006 +2001-10-14 Keith Owens <kaos@melbourne.sgi.com>
37008 + * More use of TMPPREFIX in top level Makefile to speed up NFS compiles.
37010 + * Correct repeat calculations in md/mds commands.
37012 +2001-10-10 Keith Owens <kaos@melbourne.sgi.com>
37014 + * Copy bfd.h and ansidecl.h to arch/$(ARCH)/kdb, remove dependecies on
37015 + user space includes.
37017 + * Update kdb v1.9 to kernel 2.4.11.
37019 +2001-10-01 Keith Owens <kaos@melbourne.sgi.com>
37021 + * Update kdb v1.9 to kernel 2.4.11-pre1 and 2.4.10-ac1.
37023 + * Correct loop in kdb_parse, reported by Tachino Nobuhiro.
37025 +2001-09-25 Keith Owens <kaos@melbourne.sgi.com>
37027 + * Update kdb v1.8 to kernel 2.4.10.
37029 + * kdbm_pg patch from Hugh Dickens.
37031 + * DProbes patch from Bharata B Rao.
37033 + * mdWcn and mmW patch from Vamsi Krishna S.
37035 + * i386 disasm layout patch from Jean-Marc Saffroy.
37037 + * Work around for 64 bit binutils, Simon Munton.
37039 + * kdb.mm doc correction by Chris Pascoe.
37041 + * Enter repeats the last command, IA64 disasm only prints one
37042 + instruction. Don Dugger.
37044 + * Allow kdb/modules to be linked into vmlinux.
37046 + * Remove obsolete code from kdb/modules/kdbm_{pg,vm}.c.
37048 + * Warn when commands are entered at more prompt.
37050 + * Add MODULE_AUTHOR, DESCRIPTION, LICENSE.
37052 + * Release as kdb v1.9.
37054 +2001-02-27 Keith Owens <kaos@melbourne.sgi.com>
37056 + * Update kdb v1.8 to kernel 2.4.2, sync kdb/modules with XFS.
37058 + * Hook into panic() call.
37060 +2000-12-18 Keith Owens <kaos@melbourne.sgi.com>
37062 + * Update kdb v1.7 to kernel 2.4.0-test13-pre3, sync kdb/modules with
37065 +2000-11-18 Keith Owens <kaos@melbourne.sgi.com>
37067 + * Update to kernel 2.4.0-test11-pre7, including forward port of
37068 + bug fixes from WIP 2.4.0-test9 tree.
37070 + * Update to Cygnus CVS trees for disassembly code.
37072 + * Bump to kdb v1.6.
37074 +2000-10-19 Keith Owens <kaos@melbourne.sgi.com>
37076 + * Update to kernel 2.4.0-test10-pre4.
37078 +2000-10-15 Keith Owens <kaos@melbourne.sgi.com>
37080 + * kdb/kdbmain.c (kdb_parse): Correctly handle blank input.
37082 + * kdb/kdbmain.c (kdb_local, kdb): Reason SILENT can have NULL regs.
37084 +2000-10-13 Keith Owens <kaos@melbourne.sgi.com>
37086 + * kdb/kdbmain.c: Reduce CMD_LEN to avoid overflowing kdb_printf buffer.
37088 +2000-10-11 Keith Owens <kaos@melbourne.sgi.com>
37090 + * kdb/kdbmain.c (kdb): Test for userspace breakpoints before driving
37091 + other cpus into kdb. Speeds up gdb and avoids SMP race.
37093 + * arch/i386/kdb/kdba_io.c (get_serial_char, get_kbd_char): Ignore
37094 + unprintable characters.
37096 + * arch/i386/kdb/kdba_io.c (kdba_read): Better handling of buffer size.
37098 +2000-10-04 Keith Owens <kaos@melbourne.sgi.com>
37100 + * arch/i386/kdb/kdba_bt.c (kdba_bt_process): Verify that esp is inside
37101 + task_struct. Original patch by Mike Galbraith.
37103 + * kdb/kdb_io.c (kdb_getstr): Reset output line counter, remove
37104 + unnecessary prompts.
37106 + * arch/i386/kdb/kdbasupport.c (kdb_getregcontents): Change " cs" to
37107 + "xcs", ditto ss, ds, es. gdb2kdb does not like leading spaces.
37109 + * include/asm-xxx/kdb.h: Add dummy kdb.h for all architectures except
37110 + ix86. This allows #include <linux/kdb.h> to appear in arch independent
37111 + code without causing compile errors.
37113 + * kdb/modules/kdbm_pg: Sync with XFS.
37115 +2000-10-03 Keith Owens <kaos@melbourne.sgi.com>
37117 + * kdb/kdb_io.c (kdb_read): Ignore NMI while waiting for input.
37119 + * kdb/kdb_io.c, kdb/Makefile: Export kdb_read.
37121 +2000-10-02 Keith Owens <kaos@melbourne.sgi.com>
37123 + * arch/i386/kernel/smpboot.c (do_boot_cpu): Set nmi_watchdog_source to 2
37124 + to avoid premature NMI oops during cpu bring up. We have to assume that
37125 + a box with more than 1 cpu has a working IO-APIC.
37127 + * Documentation/kdb/{kdb.mm,kdb_md.man}: Add mdr command.
37129 + * kdb/kdbmain.c (kdb_md): Add mdr command.
37131 + * Release as kdb v1.5 against 2.4.0-test9-pre8.
37133 + * arch/i386/kdb/kdba_io.c, arch/i386/kdb/kdbasupport.c, kdb/kdbmain.c,
37134 + kdb/kdb_io.c, kdb/kdb_id.c: Remove zero initializers for static
37137 +2000-09-28 Keith Owens <kaos@melbourne.sgi.com>
37139 + * various: Add nmi_watchdog_source, 1 local APIC, 2 IO-APIC.
37140 + Test nmi_watchdog_source instead of nr_ioapics so UP works on SMP hardware.
37142 + * arch/i386/kernel/io_apic.c: Rename setup_nmi to setup_nmi_io for clarity.
37144 + * kdb/kdbmain.c (kdb_parse): Only set NO_WATCHDOG if it was already set.
37146 + * kdb/kdbmain.c (kdb): Clear NO_WATCHDOG on all exit paths.
37148 + * include/linux/kdb.h: Add KDB_REASON_SILENT.
37150 + * kdb/kdbmain.c (kdb_local): Treat reason SILENT as immediate 'go'.
37152 + * kdb/kdbmain.c (kdb_init): Invoke kdb with reason SILENT to instantiate
37153 + any breakpoints on boot cpu.
37155 + * arch/i386/kernel/smpboot.c (smp_callin): Invoke kdb with reason SILENT
37156 + to instantiate any global breakpoints on this cpu.
37158 + * kdb/kdb_cmds: Remove comment that said initial commands only worked on
37161 +2000-09-27 Keith Owens <kaos@melbourne.sgi.com>
37163 + * arch/i386/kernel/msr.c: Move {rd,wr}msr_eio to include/asm-i386/apic.h.
37165 + * include/asm-i386/apic.h: Define NMI interfaces.
37167 + * kernel/sysctl.c (kern_table):
37168 + * kernel/sysctl.c (do_proc_set_nmi_watchdog):
37169 + Add /proc/sys/kernel/nmi_watchdog.
37171 + * arch/i386/kernel/apic.c: New routines set_nmi_counter_local,
37172 + setup_apic_nmi_watchdog.
37174 + * arch/i386/kernel/traps.c: New routine set_nmi_watchdog(). Call apic
37175 + routines to set/clear local apic timer.
37177 +2000-09-26 Keith Owens <kaos@melbourne.sgi.com>
37179 + * include/linux/sysctl.h (enum): Add NMI_WATCHDOG.
37181 + * arch/i386/kernel/traps.c (nmi_watchdog_tick): Check nmi_watchdog is
37184 + * arch/i386/config.in: Add CONFIG_UP_NMI_WATCHDOG.
37186 + * Documentation/Configure.help: Add CONFIG_UP_NMI_WATCHDOG.
37188 + * Documentation/nmi_watchdog.txt: Update for UP NMI watchdog.
37190 +2000-09-25 Keith Owens <kaos@melbourne.sgi.com>
37192 + * arch/i386/kernel/apic.c (init_apic_mappings):
37193 + * arch/i386/kernel/io_apic.c (IO_APIC_init_uniprocessor):
37194 + Merge Keir Fraser's local APIC for uniprocessors patch.
37196 +2000-09-24 Keith Owens <kaos@melbourne.sgi.com>
37198 + * Various: Declare initialization routines as __init.
37200 + * Makefile: Define and export AWK.
37202 + * kdb/Makefile: Generate gen-kdb_cmds.c from kdb/kdb_cmds.
37204 + * kdb/kdbmain.c (kdb_init): Call new routine kdb_cmds_init to execute
37205 + whatever the user put in kdb/kdb_cmds.
37207 + * arch/i386/kdb/kdba_bt.c (kdba_bt_stack): New parameter to
37208 + indicate if esp in regs is known to be valid or not.
37210 + * kdb/kdb_bp.c, arch/i386/kdb/kdba_bp.c: More trace prints for
37211 + breakpoint handling.
37213 + * arch/i386/kdb/kdba_bp.c (kdba_installbp): Finally found and fixed the
37214 + annoying breakpoint bug where breakpoints where not always installed
37217 + * Documentation/kdb: Update man pages kdb.mm, kdb_env.man, kdb_ss.man.
37219 + * Released as kdb-v1.5-beta1-2.4.0-test8.
37221 + * Sync to 2.4.0-test9-pre6 and release as kdb-v1.5-beta1-2.4.0-test9-pre6.
37223 +2000-09-23 Keith Owens <kaos@melbourne.sgi.com>
37225 + * arch/i386/kdb/kdbasupport.c (kdba_getregcontents): New pseudo
37226 + registers cesp and ceflags to help with debugging the debugger.
37228 + * kdb/kdbmain.c (kdb_local, kdb): Add KDB_REASON_RECURSE. Add
37229 + environment variable RECURSE. Add code to cope with some types of
37232 + * kdb/kdbmain.c (kdb), arch/i386/kdba/kdba_bp.c: Add
37233 + kdba_clearsinglestep.
37235 +2000-09-22 Keith Owens <kaos@melbourne.sgi.com>
37237 + * drivers/video/vgacon.c (write_vga): No cli() if kdb is running, avoid
37238 + console deadlock.
37240 + * arch/i386/kernel/irq.c (get_irqlock): Warn if kdb is running, may hang.
37242 + * include/linux/kdb.h: Define KDB_IS_RUNNING as (0) if no CONFIG_KDB.
37244 + * arch/i386/kdb/kdba_bt.c (kdba_bt_stack): Do not attempt a backtrace if
37245 + the code segment is not in the kernel.
37247 + * kdb/modules: Change modules from MX_OBJS to M_OBJS. Remove EXPORT_NOSYMBOLS.
37249 +2000-09-21 Keith Owens <kaos@melbourne.sgi.com>
37251 + * arch/i386/kernel/i386_ksyms.c: Move EXPORT_SYMBOLS for kdb to kdb/kdbmain.c.
37253 + * kdb/Makefile: Change kdb/kdbmain.o from O_OBJS to OX_OBJS.
37255 + * arch/i386/kernel/smp.c: Remove some #ifdef CONFIG_KDB. Remove kdbprivate.h.
37257 + * include/linux/kdb.h: Add kdb_print_state. Add KDB_STATE_WAIT_IPI.
37259 + * kdb/kdbmain.c (kdb): Only mark cpu as leaving if it is in KDB state. Maintain
37260 + WAIT_IPI state so a cpu is only driven through NMI once.
37262 + * arch/i386/kernel/smp.c (smp_kdb_stop): All state fiddling moved to kdb().
37264 +2000-09-20 Keith Owens <kaos@melbourne.sgi.com>
37266 + * include/linux/kdb.h: #define kdb() as (0) if kdb is not configured.
37268 + * arch/i386/kernel/traps.c: Remove some #ifdef CONFIG_KDB.
37270 + * include/linux/kdbprivate.h: Move per cpu state to kdb.h.
37272 + * include/linux/kdb.h: Add KDB_STATE_NO_WATCHDOG, KDB_STATE_PRINTF_LOCK.
37273 + Rename KDB_DEBUG_xxx to KDB_DEBUG_FLAG_xxx. Clean up debug flag
37276 + * arch/i386/kernel/traps.c (nmi_watchdog_tick): Check no watchdog.
37278 + * kdb/kdbmain.c (kdb): Set no watchdog in normal kdb code.
37280 + * kdb/kdbmain.c (kdb_parse): Allow watchdog in commands.
37282 + * kdb/kdb_io.c (kdb_printf): No watchdog during printing. Clean up lock handling.
37284 + * kdb/kdbmain.c (kdb_set): Clean up debug flag handling.
37286 +2000-09-19 Juan J. Quintela <quintela@fi.udc.es>
37288 + * kdb/arch/i386/kdb/kdba_io.c: Allow kdb to compile without CONFIG_VT and/or
37291 +2000-09-19 Keith Owens <kaos@melbourne.sgi.com>
37293 + * include/linux/kdb.h: Define KDB_DEBUG_STATE().
37295 + * kdb/kdbmain.c (kdb): Add kdb_print_state(), calls to KDB_DEBUG_STATE().
37297 +2000-09-16 Keith Owens <kaos@melbourne.sgi.com>
37299 + * Move to finer grained control over individual processors in kdb with
37300 + per cpu kdb state. Needed to allow ss[b] to only release one processor,
37301 + previously ss[b] released all processors. Also need to recover from
37302 + errors inside kdb commands, e.g. oops in kdbm_pg code.
37305 + Move global flags KDB_FLAG_SSB, KDB_FLAG_SUPRESS, KDB_FLAG_FAULT,
37306 + KDB_FLAG_SS, KDB_FLAG_SSBPT, kdb_active, to per cpu state and macros
37308 + Replace kdb_flags & KDB_FLAG_xxx with KDB_FLAG(xxx).
37309 + Replace kdb_flags & KDB_DEBUG_xxx with KDB_DEBUG(xxx).
37310 + Replace specific tests with wrapper KDB_IS_RUNNING().
37312 + * various: Remove #ifdef CONFIG_SMP from kdb code wherever
37313 + possible. Simplifies the code and makes it much more readable.
37315 + * arch/i386/kdb/kdbasupport.c (kdb_setjmp): Record if we have reliable
37316 + longjmp data instead of assuming it is always set.
37318 + * various: Replace smp_kdb_wait with per cpu state, HOLD_CPU.
37320 + * init/main.c : Replace #ifdef KDB_DEBUG with KDB_DEBUG(CALLBACK).
37322 + * include/linux/kdbprivate.h: Separate command return codes from error
37323 + codes. Add more detailed command codes.
37325 + * arch/i386/kernel/traps.c (die): Change spin_lock_irq to
37326 + spin_lock_irqsave. Why did I do this?
37328 + * kdb/kdbmain.c (kdb_parse): Set per cpu flag CMD before executing kdb
37329 + command. More detailed return codes for commands that affect
37332 + * kdb/kdbmain.c (kdb_previous_event): New, check if any processors are
37333 + still executing the previous kdb event. Removes a race window where a
37334 + second event could enter kdb before the first had completely ended.
37336 + * kdb/kdbmain.c (kdb): Document all the concurrency conditions and how
37337 + kdb handles them. ss[b] now releases only the current cpu. Do not set
37338 + breakpoints when releasing for ss[b]. Recover from errors in kdb
37339 + commands. Check that we have reliable longjmp data before using it.
37341 + * various: Update return code documentation.
37343 + * kdb/kdb_bp.c (kdb_ss): Separate ss and ssb return codes.
37345 + * kdb/kdbsupport.c (kdb_ipi): Finer grained algorithm for deciding
37346 + whether to call send a stop signal to a cpu.
37348 + * arch/i386/kdb/kdba_bp.c (kdba_db_trap): Separate ss and ssb return
37349 + codes. Reinstall delayed software breakpoints per cpu instead of
37350 + globally. Changed algorithm for handling ss[b].
37352 + * arch/i386/kdb/kdba_bp.c (kdba_bp_trap): Match software breakpoints per
37353 + cpu instead of globally.
37355 + * include/linux/kdb.h: Bump version to kdb v1.5.
37357 +2000-09-16 Keith Owens <kaos@melbourne.sgi.com>
37359 + * kernel/sysctl.c (kern_table): add /proc/sys/kernel/kdb.
37361 + * init/main.c (parse_options): add boot flags kdb=on, kdb=off,
37364 + * include/linux/sysctl.h (enum): add KERN_KDB.
37366 + * drivers/char/serial.c (receive_chars): check kdb_on.
37368 + * drivers/char/keyboard.c (handle_scancode): check kdb_on.
37370 + * arch/i386/kernel/traps.c (nmi_watchdog_tick): check kdb_on.
37372 + * arch/i386/config.in: add CONFIG_KDB_OFF.
37374 + * Documentation/Configure.help: add CONFIG_KDB_OFF.
37376 + * kdb/kdbmain.c: add kdb_initial_cpu, kdb_on.
37378 + * kdb/kdbmain.c (kdb): check kdb_on, set kdb_initial_cpu.
37380 + * kdb/kdbmain.c (kdb_init): add Keith Owens to kdb banner.
37382 + * kdb/kdb_io.c (kdb_printf): serialize kdb_printf output.
37384 + * kdb/kdb_bt.c (kdb_bt): check environment variable BTAPROMPT.
37386 + * kdb/kdbsupport.c (kdb_ipi): ignore NMI for kdb_initial_cpu.
37388 + * kdb/modules/kdbm_pg.c (kdbm_page): merge updates from 2.4.0-test5-xfs.
37390 + * kdb/kdb_bt.man: add btp, bta, BTAPROMPT.
37392 + * kdb/kdb.mm: add CONFIG_KDB_OFF, boot flags, btp, bta.
37394 + * include/linux/kdbprivate.h: add kdb_initial_cpu.
37396 + * include/linux/kdb.h: add kdb_on, bump version to kdb v1.4.
37397 diff -Nurp linux-2.6.22-590/kdb/kdba_bt_x86.c linux-2.6.22-600/kdb/kdba_bt_x86.c
37398 --- linux-2.6.22-590/kdb/kdba_bt_x86.c 1970-01-01 01:00:00.000000000 +0100
37399 +++ linux-2.6.22-600/kdb/kdba_bt_x86.c 2008-04-09 18:14:28.000000000 +0200
37402 + * This file is subject to the terms and conditions of the GNU General Public
37403 + * License. See the file "COPYING" in the main directory of this archive
37404 + * for more details.
37406 + * Copyright (c) 2006, 2007 Silicon Graphics, Inc. All Rights Reserved.
37408 + * Common code for doing accurate backtraces on i386 and x86_64, including
37409 + * printing the values of arguments.
37412 +#include <linux/init.h>
37413 +#include <linux/kallsyms.h>
37414 +#include <linux/kdb.h>
37415 +#include <linux/kdbprivate.h>
37416 +#include <linux/ctype.h>
37417 +#include <linux/string.h>
37418 +#include <linux/stringify.h>
37419 +#include <linux/kernel.h>
37420 +#include <linux/sched.h>
37421 +#include <linux/nmi.h>
37422 +#include <asm/asm-offsets.h>
37423 +#include <asm/system.h>
37425 +#define KDB_DEBUG_BB(fmt, ...) \
37426 + {if (KDB_DEBUG(BB)) kdb_printf(fmt, ## __VA_ARGS__);}
37427 +#define KDB_DEBUG_BB_OFFSET_PRINTF(offset, prefix, suffix) \
37428 + kdb_printf(prefix "%c0x%x" suffix, \
37429 + offset >= 0 ? '+' : '-', \
37430 + offset >= 0 ? offset : -offset)
37431 +#define KDB_DEBUG_BB_OFFSET(offset, prefix, suffix) \
37432 + {if (KDB_DEBUG(BB)) KDB_DEBUG_BB_OFFSET_PRINTF(offset, prefix, suffix);}
37434 +#define BB_CHECK(expr, val, ret) \
37436 + if (unlikely(expr)) { \
37437 + kdb_printf("%s, line %d: BB_CHECK(" #expr ") failed " \
37439 + __FUNCTION__, __LINE__, (long)val); \
37445 +/* Use BBRG_Rxx for both i386 and x86_64. RAX through R15 must be at the end,
37446 + * starting with RAX. Some of these codes do not reflect actual registers,
37447 + * such codes are special cases when parsing the record of register changes.
37448 + * When updating BBRG_ entries, update bbrg_name as well.
37453 + BBRG_UNDEFINED = 0, /* Register contents are undefined */
37454 + BBRG_OSP, /* original stack pointer on entry to function */
37473 +const static char *bbrg_name[] = {
37474 + [BBRG_UNDEFINED] = "undefined",
37475 + [BBRG_OSP] = "osp",
37476 + [BBRG_RAX] = "rax",
37477 + [BBRG_RBX] = "rbx",
37478 + [BBRG_RCX] = "rcx",
37479 + [BBRG_RDX] = "rdx",
37480 + [BBRG_RDI] = "rdi",
37481 + [BBRG_RSI] = "rsi",
37482 + [BBRG_RBP] = "rbp",
37483 + [BBRG_RSP] = "rsp",
37484 + [BBRG_R8] = "r8",
37485 + [BBRG_R9] = "r9",
37486 + [BBRG_R10] = "r10",
37487 + [BBRG_R11] = "r11",
37488 + [BBRG_R12] = "r12",
37489 + [BBRG_R13] = "r13",
37490 + [BBRG_R14] = "r14",
37491 + [BBRG_R15] = "r15",
37494 +/* Map a register name to its register code. This includes the sub-register
37495 + * addressable fields, e.g. parts of rax can be addressed as ax, al, ah, eax.
37496 + * The list is sorted so it can be binary chopped, sort command is:
37497 + * LANG=C sort -t '"' -k2
37500 +struct bb_reg_code_map {
37501 + enum bb_reg_code reg;
37502 + const char *name;
37505 +const static struct bb_reg_code_map
37506 +bb_reg_code_map[] = {
37507 + { BBRG_RAX, "ah" },
37508 + { BBRG_RAX, "al" },
37509 + { BBRG_RAX, "ax" },
37510 + { BBRG_RBX, "bh" },
37511 + { BBRG_RBX, "bl" },
37512 + { BBRG_RBP, "bp" },
37513 + { BBRG_RBP, "bpl" },
37514 + { BBRG_RBX, "bx" },
37515 + { BBRG_RCX, "ch" },
37516 + { BBRG_RCX, "cl" },
37517 + { BBRG_RCX, "cx" },
37518 + { BBRG_RDX, "dh" },
37519 + { BBRG_RDI, "di" },
37520 + { BBRG_RDI, "dil" },
37521 + { BBRG_RDX, "dl" },
37522 + { BBRG_RDX, "dx" },
37523 + { BBRG_RAX, "eax" },
37524 + { BBRG_RBP, "ebp" },
37525 + { BBRG_RBX, "ebx" },
37526 + { BBRG_RCX, "ecx" },
37527 + { BBRG_RDI, "edi" },
37528 + { BBRG_RDX, "edx" },
37529 + { BBRG_RSI, "esi" },
37530 + { BBRG_RSP, "esp" },
37531 + { BBRG_R10, "r10" },
37532 + { BBRG_R10, "r10d" },
37533 + { BBRG_R10, "r10l" },
37534 + { BBRG_R10, "r10w" },
37535 + { BBRG_R11, "r11" },
37536 + { BBRG_R11, "r11d" },
37537 + { BBRG_R11, "r11l" },
37538 + { BBRG_R11, "r11w" },
37539 + { BBRG_R12, "r12" },
37540 + { BBRG_R12, "r12d" },
37541 + { BBRG_R12, "r12l" },
37542 + { BBRG_R12, "r12w" },
37543 + { BBRG_R13, "r13" },
37544 + { BBRG_R13, "r13d" },
37545 + { BBRG_R13, "r13l" },
37546 + { BBRG_R13, "r13w" },
37547 + { BBRG_R14, "r14" },
37548 + { BBRG_R14, "r14d" },
37549 + { BBRG_R14, "r14l" },
37550 + { BBRG_R14, "r14w" },
37551 + { BBRG_R15, "r15" },
37552 + { BBRG_R15, "r15d" },
37553 + { BBRG_R15, "r15l" },
37554 + { BBRG_R15, "r15w" },
37555 + { BBRG_R8, "r8" },
37556 + { BBRG_R8, "r8d" },
37557 + { BBRG_R8, "r8l" },
37558 + { BBRG_R8, "r8w" },
37559 + { BBRG_R9, "r9" },
37560 + { BBRG_R9, "r9d" },
37561 + { BBRG_R9, "r9l" },
37562 + { BBRG_R9, "r9w" },
37563 + { BBRG_RAX, "rax" },
37564 + { BBRG_RBP, "rbp" },
37565 + { BBRG_RBX, "rbx" },
37566 + { BBRG_RCX, "rcx" },
37567 + { BBRG_RDI, "rdi" },
37568 + { BBRG_RDX, "rdx" },
37569 + { BBRG_RSI, "rsi" },
37570 + { BBRG_RSP, "rsp" },
37571 + { BBRG_RSI, "si" },
37572 + { BBRG_RSI, "sil" },
37573 + { BBRG_RSP, "sp" },
37574 + { BBRG_RSP, "spl" },
37577 +/* Record register contents in terms of the values that were passed to this
37578 + * function, IOW track which registers contain an input value. A register's
37579 + * contents can be undefined, it can contain an input register value or it can
37580 + * contain an offset from the original stack pointer.
37582 + * This structure is used to represent the current contents of the integer
37583 + * registers, it is held in an array that is indexed by BBRG_xxx. The element
37584 + * for BBRG_xxx indicates what input value is currently in BBRG_xxx. When
37585 + * 'value' is BBRG_OSP then register BBRG_xxx contains a stack pointer,
37586 + * pointing at 'offset' from the original stack pointer on entry to the
37587 + * function. When 'value' is not BBRG_OSP then element BBRG_xxx contains the
37588 + * original contents of an input register and offset is ignored.
37590 + * An input register 'value' can be stored in more than one register and/or in
37591 + * more than one memory location.
37594 +struct bb_reg_contains
37596 + enum bb_reg_code value: 8;
37600 +/* Note: the offsets in struct bb_mem_contains in this code are _NOT_ offsets
37601 + * from OSP, they are offsets from current RSP. It fits better with the way
37602 + * that struct pt_regs is built, some code pushes extra data before pt_regs so
37603 + * working with OSP relative offsets gets messy. struct bb_mem_contains
37604 + * entries must be in descending order of RSP offset.
37607 +typedef struct { DECLARE_BITMAP(bits, BBRG_R15+1); } bbrgmask_t;
37608 +#define BB_SKIP(reg) (1 << (BBRG_ ## reg))
37609 +struct bb_mem_contains {
37610 + short offset_address;
37611 + enum bb_reg_code value: 8;
37614 +/* Transfer of control to a label outside the current function. If the
37615 + * transfer is to a known common restore path that expects known registers
37616 + * and/or a known memory state (e.g. struct pt_regs) then do a sanity check on
37617 + * the state at this point.
37620 +struct bb_name_state {
37621 + const char *name; /* target function */
37622 + bfd_vma address; /* Address of target function */
37623 + const char *fname; /* optional from function name */
37624 + const struct bb_mem_contains *mem; /* expected memory state */
37625 + const struct bb_reg_contains *regs; /* expected register state */
37626 + const unsigned short mem_size; /* ARRAY_SIZE(mem) */
37627 + const unsigned short regs_size; /* ARRAY_SIZE(regs) */
37628 + const short osp_offset; /* RSP in regs == OSP+osp_offset */
37629 + const bbrgmask_t skip_mem; /* Some slots in mem may be undefined */
37630 + const bbrgmask_t skip_regs; /* Some slots in regs may be undefined */
37633 +/* NS (NAME_STATE) macros define the register and memory state when we transfer
37634 + * control to or start decoding a special case name. Use NS when the target
37635 + * label always has the same state. Use NS_FROM and specify the source label
37636 + * if the target state is slightly different depending on where it is branched
37637 + * from. This gives better state checking, by isolating the special cases.
37639 + * Note: for the same target label, NS_FROM entries must be followed by a
37640 + * single NS entry.
37643 +#define NS_FROM(iname, ifname, imem, iregs, iskip_mem, iskip_regs, iosp_offset) \
37646 + .fname = ifname, \
37649 + .mem_size = ARRAY_SIZE(imem), \
37650 + .regs_size = ARRAY_SIZE(iregs), \
37651 + .skip_mem.bits[0] = iskip_mem, \
37652 + .skip_regs.bits[0] = iskip_regs, \
37653 + .osp_offset = iosp_offset, \
37657 +/* Shorter forms for the common cases */
37658 +#define NS(iname, imem, iregs, iskip_mem, iskip_regs, iosp_offset) \
37659 + NS_FROM(iname, NULL, imem, iregs, iskip_mem, iskip_regs, iosp_offset)
37660 +#define NS_MEM(iname, imem, iskip_mem) \
37661 + NS_FROM(iname, NULL, imem, no_regs, iskip_mem, 0, 0)
37662 +#define NS_MEM_FROM(iname, ifname, imem, iskip_mem) \
37663 + NS_FROM(iname, ifname, imem, no_regs, iskip_mem, 0, 0)
37664 +#define NS_REG(iname, iregs, iskip_regs) \
37665 + NS_FROM(iname, NULL, no_memory, iregs, 0, iskip_regs, 0)
37666 +#define NS_REG_FROM(iname, ifname, iregs, iskip_regs) \
37667 + NS_FROM(iname, ifname, no_memory, iregs, 0, iskip_regs, 0)
37670 +bb_reg_code_set_value(enum bb_reg_code dst, enum bb_reg_code src);
37672 +static const char *bb_mod_name, *bb_func_name;
37674 +/*============================================================================*/
37676 +/* Most of the basic block code and data is common to x86_64 and i386. This */
37677 +/* large ifdef contains almost all of the differences between the two */
37678 +/* architectures. */
37680 +/* Make sure you update the correct section of this ifdef. */
37682 +/*============================================================================*/
37684 +#ifdef CONFIG_X86_64
37686 +/* Registers that can be used to pass parameters, in the order that parameters
37690 +const static enum bb_reg_code
37691 +bb_param_reg[] = {
37700 +const static enum bb_reg_code
37701 +bb_preserved_reg[] = {
37711 +static const struct bb_mem_contains full_pt_regs[] = {
37712 + { 0x70, BBRG_RDI },
37713 + { 0x68, BBRG_RSI },
37714 + { 0x60, BBRG_RDX },
37715 + { 0x58, BBRG_RCX },
37716 + { 0x50, BBRG_RAX },
37717 + { 0x48, BBRG_R8 },
37718 + { 0x40, BBRG_R9 },
37719 + { 0x38, BBRG_R10 },
37720 + { 0x30, BBRG_R11 },
37721 + { 0x28, BBRG_RBX },
37722 + { 0x20, BBRG_RBP },
37723 + { 0x18, BBRG_R12 },
37724 + { 0x10, BBRG_R13 },
37725 + { 0x08, BBRG_R14 },
37726 + { 0x00, BBRG_R15 },
37728 +static const struct bb_mem_contains partial_pt_regs[] = {
37729 + { 0x40, BBRG_RDI },
37730 + { 0x38, BBRG_RSI },
37731 + { 0x30, BBRG_RDX },
37732 + { 0x28, BBRG_RCX },
37733 + { 0x20, BBRG_RAX },
37734 + { 0x18, BBRG_R8 },
37735 + { 0x10, BBRG_R9 },
37736 + { 0x08, BBRG_R10 },
37737 + { 0x00, BBRG_R11 },
37739 +static const struct bb_mem_contains partial_pt_regs_plus_1[] = {
37740 + { 0x48, BBRG_RDI },
37741 + { 0x40, BBRG_RSI },
37742 + { 0x38, BBRG_RDX },
37743 + { 0x30, BBRG_RCX },
37744 + { 0x28, BBRG_RAX },
37745 + { 0x20, BBRG_R8 },
37746 + { 0x18, BBRG_R9 },
37747 + { 0x10, BBRG_R10 },
37748 + { 0x08, BBRG_R11 },
37750 +static const struct bb_mem_contains partial_pt_regs_plus_2[] = {
37751 + { 0x50, BBRG_RDI },
37752 + { 0x48, BBRG_RSI },
37753 + { 0x40, BBRG_RDX },
37754 + { 0x38, BBRG_RCX },
37755 + { 0x30, BBRG_RAX },
37756 + { 0x28, BBRG_R8 },
37757 + { 0x20, BBRG_R9 },
37758 + { 0x18, BBRG_R10 },
37759 + { 0x10, BBRG_R11 },
37761 +static const struct bb_mem_contains no_memory[] = {
37763 +/* Hardware has already pushed an error_code on the stack. Use undefined just
37764 + * to set the initial stack offset.
37766 +static const struct bb_mem_contains error_code[] = {
37767 + { 0x0, BBRG_UNDEFINED },
37769 +/* error_code plus original rax */
37770 +static const struct bb_mem_contains error_code_rax[] = {
37771 + { 0x8, BBRG_UNDEFINED },
37772 + { 0x0, BBRG_RAX },
37775 +static const struct bb_reg_contains all_regs[] = {
37776 + [BBRG_RAX] = { BBRG_RAX, 0 },
37777 + [BBRG_RBX] = { BBRG_RBX, 0 },
37778 + [BBRG_RCX] = { BBRG_RCX, 0 },
37779 + [BBRG_RDX] = { BBRG_RDX, 0 },
37780 + [BBRG_RDI] = { BBRG_RDI, 0 },
37781 + [BBRG_RSI] = { BBRG_RSI, 0 },
37782 + [BBRG_RBP] = { BBRG_RBP, 0 },
37783 + [BBRG_RSP] = { BBRG_OSP, 0 },
37784 + [BBRG_R8 ] = { BBRG_R8, 0 },
37785 + [BBRG_R9 ] = { BBRG_R9, 0 },
37786 + [BBRG_R10] = { BBRG_R10, 0 },
37787 + [BBRG_R11] = { BBRG_R11, 0 },
37788 + [BBRG_R12] = { BBRG_R12, 0 },
37789 + [BBRG_R13] = { BBRG_R13, 0 },
37790 + [BBRG_R14] = { BBRG_R14, 0 },
37791 + [BBRG_R15] = { BBRG_R15, 0 },
37793 +static const struct bb_reg_contains no_regs[] = {
37796 +static struct bb_name_state bb_special_cases[] = {
37798 + /* First the cases that pass data only in memory. We do not check any
37799 + * register state for these cases.
37802 + /* Simple cases, no exceptions */
37803 + NS_MEM("ia32_ptregs_common", partial_pt_regs_plus_1, 0),
37804 + NS_MEM("ia32_sysret", partial_pt_regs, 0),
37805 + NS_MEM("int_careful", partial_pt_regs, 0),
37806 + NS_MEM("int_restore_rest", full_pt_regs, 0),
37807 + NS_MEM("int_signal", full_pt_regs, 0),
37808 + NS_MEM("int_very_careful", partial_pt_regs, 0),
37809 + NS_MEM("int_with_check", partial_pt_regs, 0),
37810 +#ifdef CONFIG_TRACE_IRQFLAGS
37811 + NS_MEM("paranoid_exit0", full_pt_regs, 0),
37812 +#endif /* CONFIG_TRACE_IRQFLAGS */
37813 + NS_MEM("paranoid_exit1", full_pt_regs, 0),
37814 + NS_MEM("ptregscall_common", partial_pt_regs_plus_1, 0),
37815 + NS_MEM("restore_norax", partial_pt_regs, 0),
37816 + NS_MEM("restore", partial_pt_regs, 0),
37817 + NS_MEM("ret_from_intr", partial_pt_regs_plus_2, 0),
37818 + NS_MEM("stub32_clone", partial_pt_regs_plus_1, 0),
37819 + NS_MEM("stub32_execve", partial_pt_regs_plus_1, 0),
37820 + NS_MEM("stub32_fork", partial_pt_regs_plus_1, 0),
37821 + NS_MEM("stub32_iopl", partial_pt_regs_plus_1, 0),
37822 + NS_MEM("stub32_rt_sigreturn", partial_pt_regs_plus_1, 0),
37823 + NS_MEM("stub32_rt_sigsuspend", partial_pt_regs_plus_1, 0),
37824 + NS_MEM("stub32_sigaltstack", partial_pt_regs_plus_1, 0),
37825 + NS_MEM("stub32_sigreturn", partial_pt_regs_plus_1, 0),
37826 + NS_MEM("stub32_sigsuspend", partial_pt_regs_plus_1, 0),
37827 + NS_MEM("stub32_vfork", partial_pt_regs_plus_1, 0),
37828 + NS_MEM("stub_clone", partial_pt_regs_plus_1, 0),
37829 + NS_MEM("stub_execve", partial_pt_regs_plus_1, 0),
37830 + NS_MEM("stub_fork", partial_pt_regs_plus_1, 0),
37831 + NS_MEM("stub_iopl", partial_pt_regs_plus_1, 0),
37832 + NS_MEM("stub_rt_sigreturn", partial_pt_regs_plus_1, 0),
37833 + NS_MEM("stub_rt_sigsuspend", partial_pt_regs_plus_1, 0),
37834 + NS_MEM("stub_sigaltstack", partial_pt_regs_plus_1, 0),
37835 + NS_MEM("stub_vfork", partial_pt_regs_plus_1, 0),
37837 + NS_MEM_FROM("ia32_badsys", "ia32_sysenter_target",
37839 + /* ia32_sysenter_target uses CLEAR_RREGS to clear R8-R11 on
37840 + * some paths. It also stomps on RAX.
37842 + BB_SKIP(R8) | BB_SKIP(R9) | BB_SKIP(R10) | BB_SKIP(R11) |
37844 + NS_MEM_FROM("ia32_badsys", "ia32_cstar_target",
37846 + /* ia32_cstar_target uses CLEAR_RREGS to clear R8-R11 on some
37847 + * paths. It also stomps on RAX. Even more confusing, instead
37848 + * of storing RCX it stores RBP. WTF?
37850 + BB_SKIP(R8) | BB_SKIP(R9) | BB_SKIP(R10) | BB_SKIP(R11) |
37851 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37852 + NS_MEM("ia32_badsys", partial_pt_regs, 0),
37854 + /* Various bits of code branch to int_ret_from_sys_call, with slightly
37855 + * different missing values in pt_regs.
37857 + NS_MEM_FROM("int_ret_from_sys_call", "ret_from_fork",
37860 + NS_MEM_FROM("int_ret_from_sys_call", "stub_execve",
37862 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37863 + NS_MEM_FROM("int_ret_from_sys_call", "stub_rt_sigreturn",
37865 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37866 + NS_MEM_FROM("int_ret_from_sys_call", "kernel_execve",
37869 + NS_MEM_FROM("int_ret_from_sys_call", "ia32_syscall",
37871 + /* ia32_syscall only saves RDI through RCX. */
37872 + BB_SKIP(R8) | BB_SKIP(R9) | BB_SKIP(R10) | BB_SKIP(R11) |
37874 + NS_MEM_FROM("int_ret_from_sys_call", "ia32_sysenter_target",
37876 + /* ia32_sysenter_target uses CLEAR_RREGS to clear R8-R11 on
37877 + * some paths. It also stomps on RAX.
37879 + BB_SKIP(R8) | BB_SKIP(R9) | BB_SKIP(R10) | BB_SKIP(R11) |
37881 + NS_MEM_FROM("int_ret_from_sys_call", "ia32_cstar_target",
37883 + /* ia32_cstar_target uses CLEAR_RREGS to clear R8-R11 on some
37884 + * paths. It also stomps on RAX. Even more confusing, instead
37885 + * of storing RCX it stores RBP. WTF?
37887 + BB_SKIP(R8) | BB_SKIP(R9) | BB_SKIP(R10) | BB_SKIP(R11) |
37888 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37889 + NS_MEM("int_ret_from_sys_call", partial_pt_regs, 0),
37891 + NS_MEM("retint_kernel", partial_pt_regs, BB_SKIP(RAX)),
37893 + NS_MEM("retint_careful", partial_pt_regs, BB_SKIP(RAX)),
37895 + /* Horrible hack: For a brand new x86_64 task, switch_to() branches to
37896 + * ret_from_fork with a totally different stack state from all the
37897 + * other tasks that come out of switch_to(). This non-standard state
37898 + * cannot be represented so just ignore the branch from switch_to() to
37899 + * ret_from_fork. Due to inlining and linker labels, switch_to() can
37900 + * appear as several different function labels, including schedule,
37901 + * context_switch and __sched_text_start.
37903 + NS_MEM_FROM("ret_from_fork", "schedule", no_memory, 0),
37904 + NS_MEM_FROM("ret_from_fork", "__sched_text_start", no_memory, 0),
37905 + NS_MEM_FROM("ret_from_fork", "context_switch", no_memory, 0),
37906 + NS_MEM("ret_from_fork", full_pt_regs, 0),
37909 + NS_MEM_FROM("ret_from_sys_call", "ret_from_fork",
37912 + NS_MEM("ret_from_sys_call", partial_pt_regs, 0),
37914 + NS_MEM("retint_restore_args",
37916 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37918 + NS_MEM("retint_swapgs",
37920 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37922 + /* Now the cases that pass data in registers. We do not check any
37923 + * memory state for these cases.
37926 + NS_REG("bad_put_user",
37928 + BB_SKIP(RAX) | BB_SKIP(RCX) | BB_SKIP(R8)),
37930 + NS_REG("bad_get_user",
37932 + BB_SKIP(RAX) | BB_SKIP(RCX) | BB_SKIP(R8)),
37934 + NS_REG("bad_to_user",
37936 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37938 + NS_REG("ia32_ptregs_common",
37942 + NS_REG("copy_user_generic_unrolled",
37944 + BB_SKIP(RAX) | BB_SKIP(RCX)),
37946 + NS_REG("copy_user_generic_string",
37950 + NS_REG("iret_label",
37954 + /* Finally the cases that pass data in both registers and memory.
37957 + NS("invalid_TSS", error_code, all_regs, 0, 0, 0),
37958 + NS("segment_not_present", error_code, all_regs, 0, 0, 0),
37959 + NS("alignment_check", error_code, all_regs, 0, 0, 0),
37960 + NS("page_fault", error_code, all_regs, 0, 0, 0),
37961 + NS("general_protection", error_code, all_regs, 0, 0, 0),
37962 + NS("error_entry", error_code_rax, all_regs, 0, BB_SKIP(RAX), -0x10),
37963 + NS("common_interrupt", error_code, all_regs, 0, 0, -0x8),
37966 +static const char *bb_spurious[] = {
37969 + /* ret_from_fork */
37972 + /* system_call */
37973 + "ret_from_sys_call",
37975 + "sysret_careful",
37979 + "int_ret_from_sys_call",
37980 + "int_with_check",
37982 + "int_very_careful",
37984 + "int_restore_rest",
37985 + /* common_interrupt */
37988 + "retint_with_reschedule",
37991 + "retint_restore_args",
37995 + "retint_careful",
37998 + /* .macro paranoidexit */
37999 +#ifdef CONFIG_TRACE_IRQFLAGS
38000 + "paranoid_exit0",
38001 + "paranoid_userspace0",
38002 + "paranoid_restore0",
38003 + "paranoid_swapgs0",
38004 + "paranoid_schedule0",
38005 +#endif /* CONFIG_TRACE_IRQFLAGS */
38006 + "paranoid_exit1",
38007 + "paranoid_swapgs1",
38008 + "paranoid_restore1",
38009 + "paranoid_userspace1",
38010 + "paranoid_schedule1",
38011 + /* error_entry */
38015 + "error_kernelspace",
38016 + /* load_gs_index */
38019 + /* ia32_sysenter_target */
38020 + "sysenter_do_call",
38021 + "sysenter_tracesys",
38022 + /* ia32_cstar_target */
38024 + "cstar_tracesys",
38026 + /* ia32_syscall */
38027 + "ia32_do_syscall",
38033 +#define HARDWARE_PUSHED (5 * KDB_WORD_SIZE)
38035 +static const char *bb_hardware_handlers[] = {
38037 + "common_interrupt",
38049 +bb_start_block0(void)
38051 + bb_reg_code_set_value(BBRG_RAX, BBRG_RAX);
38052 + bb_reg_code_set_value(BBRG_RBX, BBRG_RBX);
38053 + bb_reg_code_set_value(BBRG_RCX, BBRG_RCX);
38054 + bb_reg_code_set_value(BBRG_RDX, BBRG_RDX);
38055 + bb_reg_code_set_value(BBRG_RDI, BBRG_RDI);
38056 + bb_reg_code_set_value(BBRG_RSI, BBRG_RSI);
38057 + bb_reg_code_set_value(BBRG_RBP, BBRG_RBP);
38058 + bb_reg_code_set_value(BBRG_RSP, BBRG_OSP);
38059 + bb_reg_code_set_value(BBRG_R8, BBRG_R8);
38060 + bb_reg_code_set_value(BBRG_R9, BBRG_R9);
38061 + bb_reg_code_set_value(BBRG_R10, BBRG_R10);
38062 + bb_reg_code_set_value(BBRG_R11, BBRG_R11);
38063 + bb_reg_code_set_value(BBRG_R12, BBRG_R12);
38064 + bb_reg_code_set_value(BBRG_R13, BBRG_R13);
38065 + bb_reg_code_set_value(BBRG_R14, BBRG_R14);
38066 + bb_reg_code_set_value(BBRG_R15, BBRG_R15);
38069 +/* x86_64 does not have a special case for __switch_to */
38072 +bb_fixup_switch_to(char *p)
38077 +bb_asmlinkage_arch(void)
38079 + return strncmp(bb_func_name, "__down", 6) == 0 ||
38080 + strncmp(bb_func_name, "__up", 4) == 0 ||
38081 + strncmp(bb_func_name, "stub_", 5) == 0 ||
38082 + strcmp(bb_func_name, "ret_from_fork") == 0 ||
38083 + strcmp(bb_func_name, "ptregscall_common") == 0;
38086 +#else /* !CONFIG_X86_64 */
38088 +/* Registers that can be used to pass parameters, in the order that parameters
38092 +const static enum bb_reg_code
38093 +bb_param_reg[] = {
38099 +const static enum bb_reg_code
38100 +bb_preserved_reg[] = {
38108 +static const struct bb_mem_contains full_pt_regs[] = {
38109 + { 0x18, BBRG_RAX },
38110 + { 0x14, BBRG_RBP },
38111 + { 0x10, BBRG_RDI },
38112 + { 0x0c, BBRG_RSI },
38113 + { 0x08, BBRG_RDX },
38114 + { 0x04, BBRG_RCX },
38115 + { 0x00, BBRG_RBX },
38117 +static const struct bb_mem_contains no_memory[] = {
38119 +/* Hardware has already pushed an error_code on the stack. Use undefined just
38120 + * to set the initial stack offset.
38122 +static const struct bb_mem_contains error_code[] = {
38123 + { 0x0, BBRG_UNDEFINED },
38125 +/* rbx already pushed */
38126 +static const struct bb_mem_contains rbx_pushed[] = {
38127 + { 0x0, BBRG_RBX },
38130 +static const struct bb_reg_contains all_regs[] = {
38131 + [BBRG_RAX] = { BBRG_RAX, 0 },
38132 + [BBRG_RBX] = { BBRG_RBX, 0 },
38133 + [BBRG_RCX] = { BBRG_RCX, 0 },
38134 + [BBRG_RDX] = { BBRG_RDX, 0 },
38135 + [BBRG_RDI] = { BBRG_RDI, 0 },
38136 + [BBRG_RSI] = { BBRG_RSI, 0 },
38137 + [BBRG_RBP] = { BBRG_RBP, 0 },
38138 + [BBRG_RSP] = { BBRG_OSP, 0 },
38140 +static const struct bb_reg_contains no_regs[] = {
38143 +static struct bb_name_state bb_special_cases[] = {
38145 + /* First the cases that pass data only in memory. We do not check any
38146 + * register state for these cases.
38149 + /* Simple cases, no exceptions */
38150 + NS_MEM("check_userspace", full_pt_regs, 0),
38151 + NS_MEM("device_not_available_emulate", full_pt_regs, 0),
38152 + NS_MEM("ldt_ss", full_pt_regs, 0),
38153 + NS_MEM("no_singlestep", full_pt_regs, 0),
38154 + NS_MEM("restore_all", full_pt_regs, 0),
38155 + NS_MEM("restore_nocheck", full_pt_regs, 0),
38156 + NS_MEM("restore_nocheck_notrace", full_pt_regs, 0),
38157 + NS_MEM("ret_from_exception", full_pt_regs, 0),
38158 + NS_MEM("ret_from_fork", full_pt_regs, 0),
38159 + NS_MEM("ret_from_intr", full_pt_regs, 0),
38160 + NS_MEM("work_notifysig", full_pt_regs, 0),
38161 + NS_MEM("work_pending", full_pt_regs, 0),
38163 +#ifdef CONFIG_PREEMPT
38164 + NS_MEM("resume_kernel", full_pt_regs, 0),
38165 +#endif /* CONFIG_PREEMPT */
38167 + NS_MEM("common_interrupt", error_code, 0),
38168 + NS_MEM("error_code", error_code, 0),
38170 + NS_MEM("bad_put_user", rbx_pushed, 0),
38172 + NS_MEM_FROM("resume_userspace", "syscall_badsys",
38173 + full_pt_regs, BB_SKIP(RAX)),
38174 + NS_MEM_FROM("resume_userspace", "syscall_fault",
38175 + full_pt_regs, BB_SKIP(RAX)),
38176 + NS_MEM_FROM("resume_userspace", "syscall_trace_entry",
38177 + full_pt_regs, BB_SKIP(RAX)),
38178 + /* Too difficult to trace through the various vm86 functions for now.
38179 + * They are C functions that start off with some memory state, fiddle
38180 + * the registers then jmp directly to resume_userspace. For the
38181 + * moment, just assume that they are valid and do no checks.
38183 + NS_FROM("resume_userspace", "do_int",
38184 + no_memory, no_regs, 0, 0, 0),
38185 + NS_FROM("resume_userspace", "do_sys_vm86",
38186 + no_memory, no_regs, 0, 0, 0),
38187 + NS_FROM("resume_userspace", "handle_vm86_fault",
38188 + no_memory, no_regs, 0, 0, 0),
38189 + NS_FROM("resume_userspace", "handle_vm86_trap",
38190 + no_memory, no_regs, 0, 0, 0),
38191 + NS_MEM("resume_userspace", full_pt_regs, 0),
38193 + NS_MEM_FROM("syscall_badsys", "sysenter_entry",
38194 + full_pt_regs, BB_SKIP(RBP)),
38195 + NS_MEM("syscall_badsys", full_pt_regs, 0),
38197 + NS_MEM_FROM("syscall_call", "syscall_trace_entry",
38198 + full_pt_regs, BB_SKIP(RAX)),
38199 + NS_MEM("syscall_call", full_pt_regs, 0),
38201 + NS_MEM_FROM("syscall_exit", "syscall_trace_entry",
38202 + full_pt_regs, BB_SKIP(RAX)),
38203 + NS_MEM("syscall_exit", full_pt_regs, 0),
38205 + NS_MEM_FROM("syscall_exit_work", "sysenter_entry",
38206 + full_pt_regs, BB_SKIP(RAX) | BB_SKIP(RBP)),
38207 + NS_MEM_FROM("syscall_exit_work", "system_call",
38208 + full_pt_regs, BB_SKIP(RAX)),
38209 + NS_MEM("syscall_exit_work", full_pt_regs, 0),
38211 + NS_MEM_FROM("syscall_trace_entry", "sysenter_entry",
38212 + full_pt_regs, BB_SKIP(RBP)),
38213 + NS_MEM_FROM("syscall_trace_entry", "system_call",
38214 + full_pt_regs, BB_SKIP(RAX)),
38215 + NS_MEM("syscall_trace_entry", full_pt_regs, 0),
38217 + /* Now the cases that pass data in registers. We do not check any
38218 + * memory state for these cases.
38221 + NS_REG("syscall_fault", all_regs, 0),
38223 + NS_REG("bad_get_user", all_regs,
38224 + BB_SKIP(RAX) | BB_SKIP(RDX)),
38226 + /* Finally the cases that pass data in both registers and memory.
38229 + /* This entry is redundant now because bb_fixup_switch_to() hides the
38230 + * jmp __switch_to case, however the entry is left here as
38233 + * NS("__switch_to", no_memory, no_regs, 0, 0, 0),
38237 +static const char *bb_spurious[] = {
38238 + /* ret_from_exception */
38240 + "check_userspace",
38241 + "resume_userspace",
38242 + /* resume_kernel */
38243 +#ifdef CONFIG_PREEMPT
38245 +#endif /* CONFIG_PREEMPT */
38246 + /* sysenter_entry */
38247 + "sysenter_past_esp",
38248 + /* system_call */
38253 + "restore_nocheck",
38254 + "restore_nocheck_notrace",
38256 + /* do not include iret_exc, it is in a .fixup section */
38257 + /* work_pending */
38259 + "work_notifysig",
38260 +#ifdef CONFIG_VM86
38261 + "work_notifysig_v86",
38262 +#endif /* CONFIG_VM86 */
38265 + /* device_not_available */
38266 + "device_not_available_emulate",
38268 + "debug_esp_fix_insn",
38269 + "debug_stack_correct",
38271 + "nmi_stack_correct",
38272 + "nmi_stack_fixup",
38273 + "nmi_debug_stack_check",
38274 + "nmi_espfix_stack",
38277 +#define HARDWARE_PUSHED (2 * KDB_WORD_SIZE)
38279 +static const char *bb_hardware_handlers[] = {
38280 + "ret_from_exception",
38285 + "coprocessor_error",
38286 + "simd_coprocessor_error",
38287 + "device_not_available",
38294 + "coprocessor_segment_overrun",
38296 + "segment_not_present",
38298 + "general_protection",
38299 + "alignment_check",
38303 + "spurious_interrupt_bug",
38307 +bb_start_block0(void)
38309 + bb_reg_code_set_value(BBRG_RAX, BBRG_RAX);
38310 + bb_reg_code_set_value(BBRG_RBX, BBRG_RBX);
38311 + bb_reg_code_set_value(BBRG_RCX, BBRG_RCX);
38312 + bb_reg_code_set_value(BBRG_RDX, BBRG_RDX);
38313 + bb_reg_code_set_value(BBRG_RDI, BBRG_RDI);
38314 + bb_reg_code_set_value(BBRG_RSI, BBRG_RSI);
38315 + bb_reg_code_set_value(BBRG_RBP, BBRG_RBP);
38316 + bb_reg_code_set_value(BBRG_RSP, BBRG_OSP);
38319 +/* The i386 code that switches stack in a context switch is an extremely
38320 + * special case. It saves the rip pointing to a label that is not otherwise
38321 + * referenced, saves the current rsp then pushes a word. The magic code that
38322 + * resumes the new task picks up the saved rip and rsp, effectively referencing
38323 + * a label that otherwise is not used and ignoring the pushed word.
38325 + * The simplest way to handle this very strange case is to recognise jmp
38326 + * address <__switch_to> and treat it as a popfl instruction. This avoids
38327 + * terminating the block on this jmp and removes one word from the stack state,
38328 + * which is the end effect of all the magic code.
38330 + * Called with the instruction line, starting after the first ':'.
38334 +bb_fixup_switch_to(char *p)
38337 + p += strspn(p, " \t"); /* start of instruction */
38338 + if (strncmp(p, "jmp", 3))
38340 + p += strcspn(p, " \t"); /* end of instruction */
38341 + p += strspn(p, " \t"); /* start of address */
38342 + p += strcspn(p, " \t"); /* end of address */
38343 + p += strspn(p, " \t"); /* start of comment */
38344 + if (strcmp(p, "<__switch_to>") == 0)
38345 + strcpy(p1, "popfl");
38349 +bb_asmlinkage_arch(void)
38351 + return strcmp(bb_func_name, "ret_from_exception") == 0 ||
38352 + strcmp(bb_func_name, "syscall_trace_entry") == 0;
38355 +#endif /* CONFIG_X86_64 */
38358 +/*============================================================================*/
38360 +/* Common code and data. */
38362 +/*============================================================================*/
38365 +/* Tracking registers by decoding the instructions is quite a bit harder than
38366 + * doing the same tracking using compiler generated information. Register
38367 + * contents can remain in the same register, they can be copied to other
38368 + * registers, they can be stored on stack or they can be modified/overwritten.
38369 + * At any one time, there are 0 or more copies of the original value that was
38370 + * supplied in each register on input to the current function. If a register
38371 + * exists in multiple places, one copy of that register is the master version,
38372 + * the others are temporary copies which may or may not be destroyed before the
38373 + * end of the function.
38375 + * The compiler knows which copy of a register is the master and which are
38376 + * temporary copies, which makes it relatively easy to track register contents
38377 + * as they are saved and restored. Without that compiler based knowledge, this
38378 + * code has to track _every_ possible copy of each register, simply because we
38379 + * do not know which is the master copy and which are temporary copies which
38380 + * may be destroyed later.
38382 + * It gets worse: registers that contain parameters can be copied to other
38383 + * registers which are then saved on stack in a lower level function. Also the
38384 + * stack pointer may be held in multiple registers (typically RSP and RBP)
38385 + * which contain different offsets from the base of the stack on entry to this
38386 + * function. All of which means that we have to track _all_ register
38387 + * movements, or at least as much as possible.
38389 + * Start with the basic block that contains the start of the function, by
38390 + * definition all registers contain their initial value. Track each
38391 + * instruction's effect on register contents, this includes reading from a
38392 + * parameter register before any write to that register, IOW the register
38393 + * really does contain a parameter. The register state is represented by a
38394 + * dynamically sized array with each entry containing :-
38397 + * Location it is copied to (another register or stack + offset)
38399 + * Besides the register tracking array, we track which parameter registers are
38400 + * read before being written, to determine how many parameters are passed in
38401 + * registers. We also track which registers contain stack pointers, including
38402 + * their offset from the original stack pointer on entry to the function.
38404 + * At each exit from the current basic block (via JMP instruction or drop
38405 + * through), the register state is cloned to form the state on input to the
38406 + * target basic block and the target is marked for processing using this state.
38407 + * When there are multiple ways to enter a basic block (e.g. several JMP
38408 + * instructions referencing the same target) then there will be multiple sets
38409 + * of register state to form the "input" for that basic block, there is no
38410 + * guarantee that all paths to that block will have the same register state.
38412 + * As each target block is processed, all the known sets of register state are
38413 + * merged to form a suitable subset of the state which agrees with all the
38414 + * inputs. The most common case is where one path to this block copies a
38415 + * register to another register but another path does not, therefore the copy
38416 + * is only a temporary and should not be propogated into this block.
38418 + * If the target block already has an input state from the current transfer
38419 + * point and the new input state is identical to the previous input state then
38420 + * we have reached a steady state for the arc from the current location to the
38421 + * target block. Therefore there is no need to process the target block again.
38423 + * The steps of "process a block, create state for target block(s), pick a new
38424 + * target block, merge state for target block, process target block" will
38425 + * continue until all the state changes have propogated all the way down the
38426 + * basic block tree, including round any cycles in the tree. The merge step
38427 + * only deletes tracking entries from the input state(s), it never adds a
38428 + * tracking entry. Therefore the overall algorithm is guaranteed to converge
38429 + * to a steady state, the worst possible case is that every tracking entry into
38430 + * a block is deleted, which will result in an empty output state.
38432 + * As each instruction is decoded, it is checked to see if this is the point at
38433 + * which execution left this function. This can be a call to another function
38434 + * (actually the return address to this function) or is the instruction which
38435 + * was about to be executed when an interrupt occurred (including an oops).
38436 + * Save the register state at this point.
38438 + * We always know what the registers contain when execution left this function.
38439 + * For an interrupt, the registers are in struct pt_regs. For a call to
38440 + * another function, we have already deduced the register state on entry to the
38441 + * other function by unwinding to the start of that function. Given the
38442 + * register state on exit from this function plus the known register contents
38443 + * on entry to the next function, we can determine the stack pointer value on
38444 + * input to this function. That in turn lets us calculate the address of input
38445 + * registers that have been stored on stack, giving us the input parameters.
38446 + * Finally the stack pointer gives us the return address which is the exit
38447 + * point from the calling function, repeat the unwind process on that function.
38449 + * The data that tracks which registers contain input parameters is function
38450 + * global, not local to any basic block. To determine which input registers
38451 + * contain parameters, we have to decode the entire function. Otherwise an
38452 + * exit early in the function might not have read any parameters yet.
38455 +/* Record memory contents in terms of the values that were passed to this
38456 + * function, IOW track which memory locations contain an input value. A memory
38457 + * location's contents can be undefined, it can contain an input register value
38458 + * or it can contain an offset from the original stack pointer.
38460 + * This structure is used to record register contents that have been stored in
38461 + * memory. Location (BBRG_OSP + 'offset_address') contains the input value
38462 + * from register 'value'. When 'value' is BBRG_OSP then offset_value contains
38463 + * the offset from the original stack pointer that was stored in this memory
38464 + * location. When 'value' is not BBRG_OSP then the memory location contains
38465 + * the original contents of an input register and offset_value is ignored.
38467 + * An input register 'value' can be stored in more than one register and/or in
38468 + * more than one memory location.
38471 +struct bb_memory_contains
38473 + short offset_address;
38474 + enum bb_reg_code value: 8;
38475 + short offset_value;
38478 +/* Track the register state in each basic block. */
38480 +struct bb_reg_state
38482 + /* Indexed by register value 'reg - BBRG_RAX' */
38483 + struct bb_reg_contains contains[KDB_INT_REGISTERS];
38486 + /* dynamic size for memory locations, see mem_count */
38487 + struct bb_memory_contains memory[0];
38490 +static struct bb_reg_state *bb_reg_state, *bb_exit_state;
38491 +static int bb_reg_state_max, bb_reg_params, bb_memory_params;
38499 +/* Contains the actual hex value of a register, plus a valid bit. Indexed by
38500 + * register value 'reg - BBRG_RAX'
38502 +static struct bb_actual bb_actual[KDB_INT_REGISTERS];
38504 +static bfd_vma bb_func_start, bb_func_end;
38505 +static bfd_vma bb_common_interrupt, bb_error_entry, bb_ret_from_intr,
38506 + bb_thread_return, bb_sync_regs, bb_save_v86_state,
38507 + bb__sched_text_start, bb__sched_text_end;
38509 +/* Record jmp instructions, both conditional and unconditional. These form the
38510 + * arcs between the basic blocks. This is also used to record the state when
38511 + * one block drops through into the next.
38513 + * A bb can have multiple associated bb_jmp entries, one for each jcc
38514 + * instruction plus at most one bb_jmp for the drop through case. If a bb
38515 + * drops through to the next bb then the drop through bb_jmp entry will be the
38516 + * last entry in the set of bb_jmp's that are associated with the bb. This is
38517 + * enforced by the fact that jcc entries are added during the disassembly phase
38518 + * of pass 1, the drop through entries are added near the end of pass 1.
38520 + * At address 'from' in this block, we have a jump to address 'to'. The
38521 + * register state at 'from' is copied to the target block.
38528 + struct bb_reg_state *state;
38529 + unsigned int drop_through: 1;
38535 + /* The end address of a basic block is sloppy. It can be the first
38536 + * byte of the last instruction in the block or it can be the last byte
38540 + unsigned int changed: 1;
38541 + unsigned int drop_through: 1;
38544 +static struct bb **bb_list, *bb_curr;
38545 +static int bb_max, bb_count;
38547 +static struct bb_jmp *bb_jmp_list;
38548 +static int bb_jmp_max, bb_jmp_count;
38550 +static int bb_giveup;
38552 +/* Add a new bb entry to the list. This does an insert sort. */
38554 +static struct bb *
38555 +bb_new(bfd_vma order)
38558 + struct bb *bb, *p;
38561 + if (bb_count == bb_max) {
38562 + struct bb **bb_list_new;
38564 + bb_list_new = debug_kmalloc(bb_max*sizeof(*bb_list_new),
38566 + if (!bb_list_new) {
38567 + kdb_printf("\n\n%s: out of debug_kmalloc\n", __FUNCTION__);
38571 + memcpy(bb_list_new, bb_list, bb_count*sizeof(*bb_list));
38572 + debug_kfree(bb_list);
38573 + bb_list = bb_list_new;
38575 + bb = debug_kmalloc(sizeof(*bb), GFP_ATOMIC);
38577 + kdb_printf("\n\n%s: out of debug_kmalloc\n", __FUNCTION__);
38581 + memset(bb, 0, sizeof(*bb));
38582 + for (i = 0; i < bb_count; ++i) {
38584 + if ((p->start && p->start > order) ||
38585 + (p->end && p->end > order))
38588 + for (j = bb_count-1; j >= i; --j)
38589 + bb_list[j+1] = bb_list[j];
38595 +/* Add a new bb_jmp entry to the list. This list is not sorted. */
38597 +static struct bb_jmp *
38598 +bb_jmp_new(bfd_vma from, bfd_vma to, unsigned int drop_through)
38600 + struct bb_jmp *bb_jmp;
38603 + if (bb_jmp_count == bb_jmp_max) {
38604 + struct bb_jmp *bb_jmp_list_new;
38605 + bb_jmp_max += 10;
38606 + bb_jmp_list_new =
38607 + debug_kmalloc(bb_jmp_max*sizeof(*bb_jmp_list_new),
38609 + if (!bb_jmp_list_new) {
38610 + kdb_printf("\n\n%s: out of debug_kmalloc\n",
38615 + memcpy(bb_jmp_list_new, bb_jmp_list,
38616 + bb_jmp_count*sizeof(*bb_jmp_list));
38617 + debug_kfree(bb_jmp_list);
38618 + bb_jmp_list = bb_jmp_list_new;
38620 + bb_jmp = bb_jmp_list + bb_jmp_count++;
38621 + bb_jmp->from = from;
38623 + bb_jmp->drop_through = drop_through;
38624 + bb_jmp->state = NULL;
38631 + struct bb *bb = bb_list[i];
38632 + memcpy(bb_list+i, bb_list+i+1, (bb_count-i-1)*sizeof(*bb_list));
38633 + bb_list[--bb_count] = NULL;
38637 +static struct bb *
38638 +bb_add(bfd_vma start, bfd_vma end)
38642 + /* Ignore basic blocks whose start address is outside the current
38643 + * function. These occur for call instructions and for tail recursion.
38646 + (start < bb_func_start || start >= bb_func_end))
38648 + for (i = 0; i < bb_count; ++i) {
38650 + if ((start && bb->start == start) ||
38651 + (end && bb->end == end))
38654 + bb = bb_new(start ? start : end);
38656 + bb->start = start;
38662 +static struct bb_jmp *
38663 +bb_jmp_add(bfd_vma from, bfd_vma to, unsigned int drop_through)
38666 + struct bb_jmp *bb_jmp;
38667 + for (i = 0, bb_jmp = bb_jmp_list; i < bb_jmp_count; ++i, ++bb_jmp) {
38668 + if (bb_jmp->from == from &&
38669 + bb_jmp->to == to &&
38670 + bb_jmp->drop_through == drop_through)
38673 + bb_jmp = bb_jmp_new(from, to, drop_through);
38677 +static unsigned long bb_curr_addr, bb_exit_addr;
38678 +static char bb_buffer[256]; /* A bit too big to go on stack */
38680 +/* Computed jmp uses 'jmp *addr(,%reg,[48])' where 'addr' is the start of a
38681 + * table of addresses that point into the current function. Run the table and
38682 + * generate bb starts for each target address plus a bb_jmp from this address
38683 + * to the target address.
38685 + * Only called for 'jmp' instructions, with the pointer starting at 'jmp'.
38689 +bb_pass1_computed_jmp(char *p)
38691 + unsigned long table, scale;
38692 + kdb_machreg_t addr;
38694 + p += strcspn(p, " \t"); /* end of instruction */
38695 + p += strspn(p, " \t"); /* start of address */
38698 + table = simple_strtoul(p, &p, 0);
38699 + if (strncmp(p, "(,%", 3) != 0)
38702 + p += strcspn(p, ","); /* end of reg */
38705 + scale = simple_strtoul(p, &p, 0);
38706 + if (scale != KDB_WORD_SIZE || strcmp(p, ")"))
38708 + while (!bb_giveup) {
38709 + if (kdb_getword(&addr, table, sizeof(addr)))
38711 + if (addr < bb_func_start || addr >= bb_func_end)
38713 + bb = bb_add(addr, 0);
38715 + bb_jmp_add(bb_curr_addr, addr, 0);
38716 + table += KDB_WORD_SIZE;
38720 +/* Pass 1, identify the start and end of each basic block */
38723 +bb_dis_pass1(PTR file, const char *fmt, ...)
38725 + int l = strlen(bb_buffer);
38728 + va_start(ap, fmt);
38729 + vsnprintf(bb_buffer + l, sizeof(bb_buffer) - l, fmt, ap);
38731 + if ((p = strchr(bb_buffer, '\n'))) {
38733 + /* ret[q], iret[q], sysexit, sysret, ud2a or jmp[q] end a
38737 + p += strcspn(p, ":");
38738 + if (*p++ == ':') {
38739 + bb_fixup_switch_to(p);
38740 + p += strspn(p, " \t"); /* start of instruction */
38741 + if (strncmp(p, "ret", 3) == 0 ||
38742 + strncmp(p, "iret", 4) == 0 ||
38743 + strncmp(p, "sysexit", 7) == 0 ||
38744 + strncmp(p, "sysret", 6) == 0 ||
38745 + strncmp(p, "ud2a", 4) == 0 ||
38746 + strncmp(p, "jmp", 3) == 0) {
38747 + if (strncmp(p, "jmp", 3) == 0)
38748 + bb_pass1_computed_jmp(p);
38749 + bb_add(0, bb_curr_addr);
38752 + bb_buffer[0] = '\0';
38758 +bb_printaddr_pass1(bfd_vma addr, disassemble_info *dip)
38760 + kdb_symtab_t symtab;
38761 + unsigned int offset;
38763 + /* disasm only calls the printaddr routine for the target of jmp, loop
38764 + * or call instructions, i.e. the start of a basic block. call is
38765 + * ignored by bb_add because the target address is outside the current
38768 + dip->fprintf_func(dip->stream, "0x%lx", addr);
38769 + kdbnearsym(addr, &symtab);
38770 + if (symtab.sym_name) {
38771 + dip->fprintf_func(dip->stream, " <%s", symtab.sym_name);
38772 + if ((offset = addr - symtab.sym_start))
38773 + dip->fprintf_func(dip->stream, "+0x%x", offset);
38774 + dip->fprintf_func(dip->stream, ">");
38776 + bb = bb_add(addr, 0);
38778 + bb_jmp_add(bb_curr_addr, addr, 0);
38785 + unsigned long addr;
38787 + struct bb_jmp *bb_jmp;
38789 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
38790 + kdb_printf("%s: func_name %s func_start " kdb_bfd_vma_fmt0
38791 + " func_end " kdb_bfd_vma_fmt0 "\n",
38796 + kdb_di.fprintf_func = bb_dis_pass1;
38797 + kdb_di.print_address_func = bb_printaddr_pass1;
38799 + bb_add(bb_func_start, 0);
38800 + for (bb_curr_addr = bb_func_start;
38801 + bb_curr_addr < bb_func_end;
38802 + ++bb_curr_addr) {
38804 + if (kdb_getarea(c, bb_curr_addr)) {
38805 + kdb_printf("%s: unreadable function code at ",
38807 + kdb_symbol_print(bb_curr_addr, NULL, KDB_SP_DEFAULT);
38808 + kdb_printf(", giving up\n");
38813 + for (addr = bb_func_start; addr < bb_func_end; ) {
38814 + bb_curr_addr = addr;
38815 + addr += kdba_id_printinsn(addr, &kdb_di);
38816 + kdb_di.fprintf_func(NULL, "\n");
38821 + /* Special case: a block consisting of a single instruction which is
38822 + * both the target of a jmp and is also an ending instruction, so we
38823 + * add two blocks using the same address, one as a start and one as an
38824 + * end, in no guaranteed order. The end must be ordered after the
38827 + for (i = 0; i < bb_count-1; ++i) {
38828 + struct bb *bb1 = bb_list[i], *bb2 = bb_list[i+1];
38829 + if (bb1->end && bb1->end == bb2->start) {
38830 + bb = bb_list[i+1];
38831 + bb_list[i+1] = bb_list[i];
38836 + /* Some bb have a start address, some have an end address. Collapse
38837 + * them into entries that have both start and end addresses. The first
38838 + * entry is guaranteed to have a start address.
38840 + for (i = 0; i < bb_count-1; ++i) {
38841 + struct bb *bb1 = bb_list[i], *bb2 = bb_list[i+1];
38844 + if (bb2->start) {
38845 + bb1->end = bb2->start - 1;
38846 + bb1->drop_through = 1;
38847 + bb_jmp_add(bb1->end, bb2->start, 1);
38849 + bb1->end = bb2->end;
38853 + bb = bb_list[bb_count-1];
38855 + bb->end = bb_func_end - 1;
38857 + /* It would be nice to check that all bb have a valid start and end
38858 + * address but there is just too much garbage code in the kernel to do
38859 + * that check. Aligned functions in assembler code mean that there is
38860 + * space between the end of one function and the start of the next and
38861 + * that space contains previous code from the assembler's buffers. It
38862 + * looks like dead code with nothing that branches to it, so no start
38863 + * address. do_sys_vm86() ends with 'jmp resume_userspace' which the C
38864 + * compiler does not know about so gcc appends the normal exit code,
38865 + * again nothing branches to this dangling code.
38867 + * The best we can do is delete bb entries with no start address.
38869 + for (i = 0; i < bb_count; ++i) {
38870 + struct bb *bb = bb_list[i];
38874 + for (i = 0; i < bb_count; ++i) {
38875 + struct bb *bb = bb_list[i];
38877 + kdb_printf("%s: incomplete bb state\n", __FUNCTION__);
38884 + if (!KDB_DEBUG(BB))
38887 + kdb_printf("%s: end\n", __FUNCTION__);
38888 + for (i = 0; i < bb_count; ++i) {
38890 + kdb_printf(" bb[%d] start "
38892 + " end " kdb_bfd_vma_fmt0
38893 + " drop_through %d",
38894 + i, bb->start, bb->end, bb->drop_through);
38895 + kdb_printf("\n");
38897 + for (i = 0; i < bb_jmp_count; ++i) {
38898 + bb_jmp = bb_jmp_list + i;
38899 + kdb_printf(" bb_jmp[%d] from "
38901 + " to " kdb_bfd_vma_fmt0
38902 + " drop_through %d\n",
38903 + i, bb_jmp->from, bb_jmp->to, bb_jmp->drop_through);
38907 +/* Pass 2, record register changes in each basic block */
38909 +/* For each opcode that we care about, indicate how it uses its operands. Most
38910 + * opcodes can be handled generically because they completely specify their
38911 + * operands in the instruction, however many opcodes have side effects such as
38912 + * reading or writing rax or updating rsp. Instructions that change registers
38913 + * that are not listed in the operands must be handled as special cases. In
38914 + * addition, instructions that copy registers while preserving their contents
38915 + * (push, pop, mov) or change the contents in a well defined way (add with an
38916 + * immediate, lea) must be handled as special cases in order to track the
38917 + * register contents.
38919 + * The tables below only list opcodes that are actually used in the Linux
38920 + * kernel, so they omit most of the floating point and all of the SSE type
38921 + * instructions. The operand usage entries only cater for accesses to memory
38922 + * and to the integer registers, accesses to floating point registers and flags
38923 + * are not relevant for kernel backtraces.
38926 +enum bb_operand_usage {
38927 + BBOU_UNKNOWN = 0,
38928 + /* generic entries. because xchg can do any combinations of
38929 + * read src, write src, read dst and write dst we need to
38930 + * define all 16 possibilities. These are ordered by rs = 1,
38931 + * rd = 2, ws = 4, wd = 8, bb_usage_x*() functions rely on this
38934 + BBOU_RS = 1, /* read src */ /* 1 */
38935 + BBOU_RD, /* read dst */ /* 2 */
38936 + BBOU_RSRD, /* 3 */
38937 + BBOU_WS, /* write src */ /* 4 */
38938 + BBOU_RSWS, /* 5 */
38939 + BBOU_RDWS, /* 6 */
38940 + BBOU_RSRDWS, /* 7 */
38941 + BBOU_WD, /* write dst */ /* 8 */
38942 + BBOU_RSWD, /* 9 */
38943 + BBOU_RDWD, /* 10 */
38944 + BBOU_RSRDWD, /* 11 */
38945 + BBOU_WSWD, /* 12 */
38946 + BBOU_RSWSWD, /* 13 */
38947 + BBOU_RDWSWD, /* 14 */
38948 + BBOU_RSRDWSWD, /* 15 */
38949 + /* opcode specific entries */
38994 +struct bb_opcode_usage {
38996 + enum bb_operand_usage usage;
38997 + const char *opcode;
39000 +/* This table is sorted in alphabetical order of opcode, except that the
39001 + * trailing '"' is treated as a high value. For example, 'in' sorts after
39002 + * 'inc', 'bt' after 'btc'. This modified sort order ensures that shorter
39003 + * opcodes come after long ones. A normal sort would put 'in' first, so 'in'
39004 + * would match both 'inc' and 'in'. When adding any new entries to this table,
39005 + * be careful to put shorter entries last in their group.
39007 + * To automatically sort the table (in vi)
39008 + * Mark the first and last opcode line with 'a and 'b
39010 + * !'bsed -e 's/"}/}}/' | LANG=C sort -t '"' -k2 | sed -e 's/}}/"}/'
39012 + * If a new instruction has to be added, first consider if it affects registers
39013 + * other than those listed in the operands. Also consider if you want to track
39014 + * the results of issuing the instruction, IOW can you extract useful
39015 + * information by looking in detail at the modified registers or memory. If
39016 + * either test is true then you need a special case to handle the instruction.
39018 + * The generic entries at the start of enum bb_operand_usage all have one thing
39019 + * in common, if a register or memory location is updated then that location
39020 + * becomes undefined, i.e. we lose track of anything that was previously saved
39021 + * in that location. So only use a generic BBOU_* value when the result of the
39022 + * instruction cannot be calculated exactly _and_ when all the affected
39023 + * registers are listed in the operands.
39027 + * 'call' does not generate a known result, but as a side effect of call,
39028 + * several scratch registers become undefined, so it needs a special BBOU_CALL
39031 + * 'adc' generates a variable result, it depends on the carry flag, so 'adc'
39032 + * gets a generic entry. 'add' can generate an exact result (add with
39033 + * immediate on a register that points to the stack) or it can generate an
39034 + * unknown result (add a variable, or add immediate to a register that does not
39035 + * contain a stack pointer) so 'add' has its own BBOU_ADD entry.
39038 +static const struct bb_opcode_usage
39039 +bb_opcode_usage_all[] = {
39040 + {3, BBOU_RSRDWD, "adc"},
39041 + {3, BBOU_ADD, "add"},
39042 + {3, BBOU_RSRDWD, "and"},
39043 + {3, BBOU_RSWD, "bsf"},
39044 + {3, BBOU_RSWD, "bsr"},
39045 + {5, BBOU_RSWS, "bswap"},
39046 + {3, BBOU_RSRDWD, "btc"},
39047 + {3, BBOU_RSRDWD, "btr"},
39048 + {3, BBOU_RSRDWD, "bts"},
39049 + {2, BBOU_RSRD, "bt"},
39050 + {4, BBOU_CALL, "call"},
39051 + {4, BBOU_CBW, "cbtw"}, /* Intel cbw */
39052 + {3, BBOU_NOP, "clc"},
39053 + {3, BBOU_NOP, "cld"},
39054 + {7, BBOU_RS, "clflush"},
39055 + {3, BBOU_NOP, "cli"},
39056 + {4, BBOU_CWD, "cltd"}, /* Intel cdq */
39057 + {4, BBOU_CBW, "cltq"}, /* Intel cdqe */
39058 + {4, BBOU_NOP, "clts"},
39059 + {4, BBOU_CMOV, "cmov"},
39060 + {9, BBOU_CMPXCHGD,"cmpxchg16"},
39061 + {8, BBOU_CMPXCHGD,"cmpxchg8"},
39062 + {7, BBOU_CMPXCHG, "cmpxchg"},
39063 + {3, BBOU_RSRD, "cmp"},
39064 + {5, BBOU_CPUID, "cpuid"},
39065 + {4, BBOU_CWD, "cqto"}, /* Intel cdo */
39066 + {4, BBOU_CWD, "cwtd"}, /* Intel cwd */
39067 + {4, BBOU_CBW, "cwtl"}, /* Intel cwde */
39068 + {4, BBOU_NOP, "data"}, /* alternative ASM_NOP<n> generates data16 on x86_64 */
39069 + {3, BBOU_RSWS, "dec"},
39070 + {3, BBOU_DIV, "div"},
39071 + {5, BBOU_RS, "fdivl"},
39072 + {5, BBOU_NOP, "finit"},
39073 + {6, BBOU_RS, "fistpl"},
39074 + {4, BBOU_RS, "fldl"},
39075 + {5, BBOU_RS, "fmull"},
39076 + {6, BBOU_NOP, "fnclex"},
39077 + {6, BBOU_NOP, "fninit"},
39078 + {6, BBOU_RS, "fnsave"},
39079 + {7, BBOU_NOP, "fnsetpm"},
39080 + {6, BBOU_RS, "frstor"},
39081 + {5, BBOU_WS, "fstsw"},
39082 + {5, BBOU_RS, "fsubp"},
39083 + {5, BBOU_NOP, "fwait"},
39084 + {7, BBOU_RS, "fxrstor"},
39085 + {6, BBOU_RS, "fxsave"},
39086 + {3, BBOU_NOP, "hlt"},
39087 + {4, BBOU_IDIV, "idiv"},
39088 + {4, BBOU_IMUL, "imul"},
39089 + {3, BBOU_RSWS, "inc"},
39090 + {3, BBOU_NOP, "int"},
39091 + {6, BBOU_RS, "invlpg"},
39092 + {2, BBOU_RSWD, "in"},
39093 + {4, BBOU_IRET, "iret"},
39094 + {1, BBOU_JMP, "j"},
39095 + {4, BBOU_LAHF, "lahf"},
39096 + {3, BBOU_RSWD, "lar"},
39097 + {5, BBOU_RS, "lcall"},
39098 + {5, BBOU_LEAVE, "leave"},
39099 + {3, BBOU_LEA, "lea"},
39100 + {6, BBOU_NOP, "lfence"},
39101 + {4, BBOU_RS, "lgdt"},
39102 + {4, BBOU_RS, "lidt"},
39103 + {4, BBOU_RS, "ljmp"},
39104 + {4, BBOU_RS, "lldt"},
39105 + {4, BBOU_RS, "lmsw"},
39106 + {4, BBOU_LODS, "lods"},
39107 + {4, BBOU_LOOP, "loop"},
39108 + {4, BBOU_NOP, "lret"},
39109 + {3, BBOU_RSWD, "lsl"},
39110 + {3, BBOU_LSS, "lss"},
39111 + {3, BBOU_RS, "ltr"},
39112 + {6, BBOU_NOP, "mfence"},
39113 + {7, BBOU_MONITOR, "monitor"},
39114 + {4, BBOU_MOVS, "movs"},
39115 + {3, BBOU_MOV, "mov"},
39116 + {3, BBOU_MUL, "mul"},
39117 + {5, BBOU_MWAIT, "mwait"},
39118 + {3, BBOU_RSWS, "neg"},
39119 + {3, BBOU_NOP, "nop"},
39120 + {3, BBOU_RSWS, "not"},
39121 + {2, BBOU_RSRDWD, "or"},
39122 + {4, BBOU_OUTS, "outs"},
39123 + {3, BBOU_RSRD, "out"},
39124 + {5, BBOU_NOP, "pause"},
39125 + {4, BBOU_POPF, "popf"},
39126 + {3, BBOU_POP, "pop"},
39127 + {8, BBOU_RS, "prefetch"},
39128 + {5, BBOU_PUSHF, "pushf"},
39129 + {4, BBOU_PUSH, "push"},
39130 + {3, BBOU_RSRDWD, "rcr"},
39131 + {5, BBOU_RDMSR, "rdmsr"},
39132 + {5, BBOU_RDTSC, "rdtsc"},
39133 + {3, BBOU_RET, "ret"},
39134 + {3, BBOU_RSRDWD, "rol"},
39135 + {3, BBOU_RSRDWD, "ror"},
39136 + {4, BBOU_SAHF, "sahf"},
39137 + {3, BBOU_RSRDWD, "sar"},
39138 + {3, BBOU_RSRDWD, "sbb"},
39139 + {4, BBOU_SCAS, "scas"},
39140 + {3, BBOU_WS, "set"},
39141 + {6, BBOU_NOP, "sfence"},
39142 + {4, BBOU_WS, "sgdt"},
39143 + {3, BBOU_RSRDWD, "shl"},
39144 + {3, BBOU_RSRDWD, "shr"},
39145 + {4, BBOU_WS, "sidt"},
39146 + {4, BBOU_WS, "sldt"},
39147 + {3, BBOU_NOP, "stc"},
39148 + {3, BBOU_NOP, "std"},
39149 + {3, BBOU_NOP, "sti"},
39150 + {4, BBOU_SCAS, "stos"},
39151 + {4, BBOU_WS, "strl"},
39152 + {3, BBOU_WS, "str"},
39153 + {3, BBOU_SUB, "sub"},
39154 + {6, BBOU_NOP, "swapgs"},
39155 + {7, BBOU_SYSEXIT, "sysexit"},
39156 + {6, BBOU_SYSRET, "sysret"},
39157 + {4, BBOU_NOP, "test"},
39158 + {4, BBOU_NOP, "ud2a"},
39159 + {6, BBOU_NOP, "wbinvd"},
39160 + {5, BBOU_WRMSR, "wrmsr"},
39161 + {4, BBOU_XADD, "xadd"},
39162 + {4, BBOU_XCHG, "xchg"},
39163 + {3, BBOU_XOR, "xor"},
39166 +/* To speed up searching, index bb_opcode_usage_all by the first letter of each
39170 + const struct bb_opcode_usage *opcode;
39172 +} bb_opcode_usage[26];
39174 +struct bb_operand {
39179 + unsigned int scale;
39180 + enum bb_reg_code base_rc; /* UNDEFINED or RAX through R15 */
39181 + enum bb_reg_code index_rc; /* UNDEFINED or RAX through R15 */
39182 + unsigned int present :1;
39183 + unsigned int disp_present :1;
39184 + unsigned int indirect :1; /* must be combined with reg or memory */
39185 + unsigned int immediate :1; /* exactly one of these 3 must be set */
39186 + unsigned int reg :1;
39187 + unsigned int memory :1;
39190 +struct bb_decode {
39193 + const struct bb_opcode_usage *match;
39194 + struct bb_operand src;
39195 + struct bb_operand dst;
39196 + struct bb_operand dst2;
39199 +static struct bb_decode bb_decode;
39201 +static enum bb_reg_code
39202 +bb_reg_map(const char *reg)
39205 + const struct bb_reg_code_map *p;
39207 + hi = ARRAY_SIZE(bb_reg_code_map) - 1;
39208 + while (lo <= hi) {
39209 + int mid = (hi + lo) / 2;
39210 + p = bb_reg_code_map + mid;
39211 + c = strcmp(p->name, reg+1);
39219 + return BBRG_UNDEFINED;
39223 +bb_parse_operand(char *str, struct bb_operand *operand)
39227 + operand->present = 1;
39228 + /* extract any segment prefix */
39229 + if (p[0] == '%' && p[1] && p[2] == 's' && p[3] == ':') {
39230 + operand->memory = 1;
39231 + operand->segment = p;
39235 + /* extract displacement, base, index, scale */
39237 + /* jmp/call *disp(%reg), *%reg or *0xnnn */
39238 + operand->indirect = 1;
39246 + operand->immediate = 1;
39247 + operand->disp_present = 1;
39248 + operand->disp = simple_strtoul(p+1, &p, 0);
39249 + } else if (isdigit(*p)) {
39250 + operand->memory = 1;
39251 + operand->disp_present = 1;
39252 + operand->disp = simple_strtoul(p, &p, 0) * sign;
39255 + operand->reg = 1;
39256 + operand->base = p;
39257 + } else if (*p == '(') {
39258 + operand->memory = 1;
39259 + operand->base = ++p;
39260 + p += strcspn(p, ",)");
39261 + if (p == operand->base)
39262 + operand->base = NULL;
39265 + operand->index = ++p;
39266 + p += strcspn(p, ",)");
39267 + if (p == operand->index)
39268 + operand->index = NULL;
39272 + operand->scale = simple_strtoul(p+1, &p, 0);
39276 + kdb_printf("%s: unexpected token '%c' after disp '%s'\n",
39277 + __FUNCTION__, *p, str);
39280 + if ((operand->immediate + operand->reg + operand->memory != 1) ||
39281 + (operand->indirect && operand->immediate)) {
39282 + kdb_printf("%s: incorrect decode '%s' N %d I %d R %d M %d\n",
39283 + __FUNCTION__, str,
39284 + operand->indirect, operand->immediate, operand->reg,
39285 + operand->memory);
39288 + if (operand->base)
39289 + operand->base_rc = bb_reg_map(operand->base);
39290 + if (operand->index)
39291 + operand->index_rc = bb_reg_map(operand->index);
39295 +bb_print_operand(const char *type, const struct bb_operand *operand)
39297 + if (!operand->present)
39299 + kdb_printf(" %s %c%c: ",
39301 + operand->indirect ? 'N' : ' ',
39302 + operand->immediate ? 'I' :
39303 + operand->reg ? 'R' :
39304 + operand->memory ? 'M' :
39307 + if (operand->segment)
39308 + kdb_printf("%s:", operand->segment);
39309 + if (operand->immediate) {
39310 + kdb_printf("$0x%lx", operand->disp);
39311 + } else if (operand->reg) {
39312 + if (operand->indirect)
39314 + kdb_printf("%s", operand->base);
39315 + } else if (operand->memory) {
39316 + if (operand->indirect && (operand->base || operand->index))
39318 + if (operand->disp_present) {
39319 + kdb_printf("0x%lx", operand->disp);
39321 + if (operand->base || operand->index || operand->scale) {
39323 + if (operand->base)
39324 + kdb_printf("%s", operand->base);
39325 + if (operand->index || operand->scale)
39327 + if (operand->index)
39328 + kdb_printf("%s", operand->index);
39329 + if (operand->scale)
39330 + kdb_printf(",%d", operand->scale);
39334 + if (operand->base_rc)
39335 + kdb_printf(" base_rc %d (%s)",
39336 + operand->base_rc, bbrg_name[operand->base_rc]);
39337 + if (operand->index_rc)
39338 + kdb_printf(" index_rc %d (%s)",
39339 + operand->index_rc,
39340 + bbrg_name[operand->index_rc]);
39341 + kdb_printf("\n");
39345 +bb_print_opcode(void)
39347 + const struct bb_opcode_usage *o = bb_decode.match;
39349 + if (bb_decode.prefix)
39350 + kdb_printf("%s ", bb_decode.prefix);
39351 + kdb_printf("opcode '%s' matched by '%s', usage %d\n",
39352 + bb_decode.opcode, o->opcode, o->usage);
39356 +bb_parse_opcode(void)
39359 + const struct bb_opcode_usage *o;
39360 + static int bb_parse_opcode_error_limit = 5;
39361 + c = bb_decode.opcode[0] - 'a';
39362 + if (c < 0 || c >= ARRAY_SIZE(bb_opcode_usage))
39364 + o = bb_opcode_usage[c].opcode;
39367 + for (i = 0; i < bb_opcode_usage[c].size; ++i, ++o) {
39368 + if (strncmp(bb_decode.opcode, o->opcode, o->length) == 0) {
39369 + bb_decode.match = o;
39370 + if (KDB_DEBUG(BB))
39371 + bb_print_opcode();
39376 + if (!bb_parse_opcode_error_limit)
39378 + --bb_parse_opcode_error_limit;
39379 + kdb_printf("%s: no match at [%s]%s " kdb_bfd_vma_fmt0 " - '%s'\n",
39381 + bb_mod_name, bb_func_name, bb_curr_addr,
39382 + bb_decode.opcode);
39387 +bb_is_int_reg(enum bb_reg_code reg)
39389 + return reg >= BBRG_RAX && reg < (BBRG_RAX + KDB_INT_REGISTERS);
39393 +bb_is_simple_memory(const struct bb_operand *operand)
39395 + return operand->memory &&
39396 + bb_is_int_reg(operand->base_rc) &&
39397 + !operand->index_rc &&
39398 + operand->scale == 0 &&
39399 + !operand->segment;
39403 +bb_is_static_disp(const struct bb_operand *operand)
39405 + return operand->memory &&
39406 + !operand->base_rc &&
39407 + !operand->index_rc &&
39408 + operand->scale == 0 &&
39409 + !operand->segment &&
39410 + !operand->indirect;
39413 +static enum bb_reg_code
39414 +bb_reg_code_value(enum bb_reg_code reg)
39416 + BB_CHECK(!bb_is_int_reg(reg), reg, 0);
39417 + return bb_reg_state->contains[reg - BBRG_RAX].value;
39421 +bb_reg_code_offset(enum bb_reg_code reg)
39423 + BB_CHECK(!bb_is_int_reg(reg), reg, 0);
39424 + return bb_reg_state->contains[reg - BBRG_RAX].offset;
39428 +bb_reg_code_set_value(enum bb_reg_code dst, enum bb_reg_code src)
39430 + BB_CHECK(!bb_is_int_reg(dst), dst, );
39431 + bb_reg_state->contains[dst - BBRG_RAX].value = src;
39435 +bb_reg_code_set_offset(enum bb_reg_code dst, short offset)
39437 + BB_CHECK(!bb_is_int_reg(dst), dst, );
39438 + bb_reg_state->contains[dst - BBRG_RAX].offset = offset;
39442 +bb_is_osp_defined(enum bb_reg_code reg)
39444 + if (bb_is_int_reg(reg))
39445 + return bb_reg_code_value(reg) == BBRG_OSP;
39451 +bb_actual_value(enum bb_reg_code reg)
39453 + BB_CHECK(!bb_is_int_reg(reg), reg, 0);
39454 + return bb_actual[reg - BBRG_RAX].value;
39458 +bb_actual_valid(enum bb_reg_code reg)
39460 + BB_CHECK(!bb_is_int_reg(reg), reg, 0);
39461 + return bb_actual[reg - BBRG_RAX].valid;
39465 +bb_actual_set_value(enum bb_reg_code reg, bfd_vma value)
39467 + BB_CHECK(!bb_is_int_reg(reg), reg, );
39468 + bb_actual[reg - BBRG_RAX].value = value;
39472 +bb_actual_set_valid(enum bb_reg_code reg, int valid)
39474 + BB_CHECK(!bb_is_int_reg(reg), reg, );
39475 + bb_actual[reg - BBRG_RAX].valid = valid;
39478 +/* The scheduler code switches RSP then does PUSH, it is not an error for RSP
39479 + * to be undefined in this area of the code.
39482 +bb_is_scheduler_address(void)
39484 + return bb_curr_addr >= bb__sched_text_start &&
39485 + bb_curr_addr < bb__sched_text_end;
39489 +bb_reg_read(enum bb_reg_code reg)
39492 + if (!bb_is_int_reg(reg) ||
39493 + bb_reg_code_value(reg) != reg)
39496 + i < min_t(unsigned int, REGPARM, ARRAY_SIZE(bb_param_reg));
39498 + if (reg == bb_param_reg[i]) {
39503 + bb_reg_params = max(bb_reg_params, o);
39507 +bb_do_reg_state_print(const struct bb_reg_state *s)
39509 + int i, offset_address, offset_value;
39510 + struct bb_memory_contains *c;
39511 + enum bb_reg_code value;
39512 + kdb_printf(" bb_reg_state %p\n", s);
39513 + for (i = 0; i < ARRAY_SIZE(s->contains); ++i) {
39514 + value = s->contains[i].value;
39515 + offset_value = s->contains[i].offset;
39516 + kdb_printf(" %s = %s",
39517 + bbrg_name[i + BBRG_RAX], bbrg_name[value]);
39518 + if (value == BBRG_OSP)
39519 + KDB_DEBUG_BB_OFFSET_PRINTF(offset_value, "", "");
39520 + kdb_printf("\n");
39522 + for (i = 0, c = s->memory; i < s->mem_count; ++i, ++c) {
39523 + offset_address = c->offset_address;
39524 + value = c->value;
39525 + offset_value = c->offset_value;
39526 + kdb_printf(" slot %d offset_address %c0x%x %s",
39528 + offset_address >= 0 ? '+' : '-',
39529 + offset_address >= 0 ? offset_address : -offset_address,
39530 + bbrg_name[value]);
39531 + if (value == BBRG_OSP)
39532 + KDB_DEBUG_BB_OFFSET_PRINTF(offset_value, "", "");
39533 + kdb_printf("\n");
39538 +bb_reg_state_print(const struct bb_reg_state *s)
39540 + if (KDB_DEBUG(BB))
39541 + bb_do_reg_state_print(s);
39544 +/* Set register 'dst' to contain the value from 'src'. This includes reading
39545 + * from 'src' and writing to 'dst'. The offset value is copied iff 'src'
39546 + * contains a stack pointer.
39548 + * Be very careful about the context here. 'dst' and 'src' reflect integer
39549 + * registers by name, _not_ by the value of their contents. "mov %rax,%rsi"
39550 + * will call this function as bb_reg_set_reg(BBRG_RSI, BBRG_RAX), which
39551 + * reflects what the assembler code is doing. However we need to track the
39552 + * _values_ in the registers, not their names. IOW, we really care about "what
39553 + * value does rax contain when it is copied into rsi?", so we can record the
39554 + * fact that we now have two copies of that value, one in rax and one in rsi.
39558 +bb_reg_set_reg(enum bb_reg_code dst, enum bb_reg_code src)
39560 + enum bb_reg_code src_value = BBRG_UNDEFINED;
39561 + short offset_value = 0;
39562 + KDB_DEBUG_BB(" %s = %s", bbrg_name[dst], bbrg_name[src]);
39563 + if (bb_is_int_reg(src)) {
39564 + bb_reg_read(src);
39565 + src_value = bb_reg_code_value(src);
39566 + KDB_DEBUG_BB(" (%s", bbrg_name[src_value]);
39567 + if (bb_is_osp_defined(src)) {
39568 + offset_value = bb_reg_code_offset(src);
39569 + KDB_DEBUG_BB_OFFSET(offset_value, "", "");
39571 + KDB_DEBUG_BB(")");
39573 + if (bb_is_int_reg(dst)) {
39574 + bb_reg_code_set_value(dst, src_value);
39575 + bb_reg_code_set_offset(dst, offset_value);
39577 + KDB_DEBUG_BB("\n");
39581 +bb_reg_set_undef(enum bb_reg_code dst)
39583 + bb_reg_set_reg(dst, BBRG_UNDEFINED);
39586 +/* Delete any record of a stored register held in osp + 'offset' */
39589 +bb_delete_memory(short offset)
39592 + struct bb_memory_contains *c;
39593 + for (i = 0, c = bb_reg_state->memory;
39594 + i < bb_reg_state->mem_count;
39596 + if (c->offset_address == offset &&
39597 + c->value != BBRG_UNDEFINED) {
39598 + KDB_DEBUG_BB(" delete %s from ",
39599 + bbrg_name[c->value]);
39600 + KDB_DEBUG_BB_OFFSET(offset, "osp", "");
39601 + KDB_DEBUG_BB(" slot %d\n",
39602 + (int)(c - bb_reg_state->memory));
39603 + memset(c, BBRG_UNDEFINED, sizeof(*c));
39604 + if (i == bb_reg_state->mem_count - 1)
39605 + --bb_reg_state->mem_count;
39610 +/* Set memory location *('dst' + 'offset_address') to contain the supplied
39611 + * value and offset. 'dst' is assumed to be a register that contains a stack
39616 +bb_memory_set_reg_value(enum bb_reg_code dst, short offset_address,
39617 + enum bb_reg_code value, short offset_value)
39620 + struct bb_memory_contains *c, *free = NULL;
39621 + BB_CHECK(!bb_is_osp_defined(dst), dst, );
39622 + KDB_DEBUG_BB(" *(%s", bbrg_name[dst]);
39623 + KDB_DEBUG_BB_OFFSET(offset_address, "", "");
39624 + offset_address += bb_reg_code_offset(dst);
39625 + KDB_DEBUG_BB_OFFSET(offset_address, " osp", ") = ");
39626 + KDB_DEBUG_BB("%s", bbrg_name[value]);
39627 + if (value == BBRG_OSP)
39628 + KDB_DEBUG_BB_OFFSET(offset_value, "", "");
39629 + for (i = 0, c = bb_reg_state->memory;
39630 + i < bb_reg_state_max;
39632 + if (c->offset_address == offset_address)
39634 + else if (c->value == BBRG_UNDEFINED && !free)
39638 + struct bb_reg_state *new, *old = bb_reg_state;
39639 + size_t old_size, new_size;
39641 + old_size = sizeof(*old) + bb_reg_state_max *
39642 + sizeof(old->memory[0]);
39643 + slot = bb_reg_state_max;
39644 + bb_reg_state_max += 5;
39645 + new_size = sizeof(*new) + bb_reg_state_max *
39646 + sizeof(new->memory[0]);
39647 + new = debug_kmalloc(new_size, GFP_ATOMIC);
39649 + kdb_printf("\n\n%s: out of debug_kmalloc\n", __FUNCTION__);
39652 + memcpy(new, old, old_size);
39653 + memset((char *)new + old_size, BBRG_UNDEFINED,
39654 + new_size - old_size);
39655 + bb_reg_state = new;
39656 + debug_kfree(old);
39657 + free = bb_reg_state->memory + slot;
39661 + int slot = free - bb_reg_state->memory;
39662 + free->offset_address = offset_address;
39663 + free->value = value;
39664 + free->offset_value = offset_value;
39665 + KDB_DEBUG_BB(" slot %d", slot);
39666 + bb_reg_state->mem_count = max(bb_reg_state->mem_count, slot+1);
39668 + KDB_DEBUG_BB("\n");
39671 +/* Set memory location *('dst' + 'offset') to contain the value from register
39672 + * 'src'. 'dst' is assumed to be a register that contains a stack pointer.
39673 + * This differs from bb_memory_set_reg_value because it takes a src register
39674 + * which contains a value and possibly an offset, bb_memory_set_reg_value is
39675 + * passed the value and offset directly.
39679 +bb_memory_set_reg(enum bb_reg_code dst, enum bb_reg_code src,
39680 + short offset_address)
39682 + int offset_value;
39683 + enum bb_reg_code value;
39684 + BB_CHECK(!bb_is_osp_defined(dst), dst, );
39685 + if (!bb_is_int_reg(src))
39687 + value = bb_reg_code_value(src);
39688 + if (value == BBRG_UNDEFINED) {
39689 + bb_delete_memory(offset_address + bb_reg_code_offset(dst));
39692 + offset_value = bb_reg_code_offset(src);
39693 + bb_reg_read(src);
39694 + bb_memory_set_reg_value(dst, offset_address, value, offset_value);
39697 +/* Set register 'dst' to contain the value from memory *('src' + offset_address).
39698 + * 'src' is assumed to be a register that contains a stack pointer.
39702 +bb_reg_set_memory(enum bb_reg_code dst, enum bb_reg_code src, short offset_address)
39704 + int i, defined = 0;
39705 + struct bb_memory_contains *s;
39706 + BB_CHECK(!bb_is_osp_defined(src), src, );
39707 + KDB_DEBUG_BB(" %s = *(%s",
39708 + bbrg_name[dst], bbrg_name[src]);
39709 + KDB_DEBUG_BB_OFFSET(offset_address, "", ")");
39710 + offset_address += bb_reg_code_offset(src);
39711 + KDB_DEBUG_BB_OFFSET(offset_address, " (osp", ")");
39712 + for (i = 0, s = bb_reg_state->memory;
39713 + i < bb_reg_state->mem_count;
39715 + if (s->offset_address == offset_address && bb_is_int_reg(dst)) {
39716 + bb_reg_code_set_value(dst, s->value);
39717 + KDB_DEBUG_BB(" value %s", bbrg_name[s->value]);
39718 + if (s->value == BBRG_OSP) {
39719 + bb_reg_code_set_offset(dst, s->offset_value);
39720 + KDB_DEBUG_BB_OFFSET(s->offset_value, "", "");
39722 + bb_reg_code_set_offset(dst, 0);
39728 + bb_reg_set_reg(dst, BBRG_UNDEFINED);
39730 + KDB_DEBUG_BB("\n");
39733 +/* A generic read from an operand. */
39736 +bb_read_operand(const struct bb_operand *operand)
39739 + if (operand->base_rc)
39740 + bb_reg_read(operand->base_rc);
39741 + if (operand->index_rc)
39742 + bb_reg_read(operand->index_rc);
39743 + if (bb_is_simple_memory(operand) &&
39744 + bb_is_osp_defined(operand->base_rc) &&
39745 + bb_decode.match->usage != BBOU_LEA) {
39746 + o = (bb_reg_code_offset(operand->base_rc) + operand->disp +
39747 + KDB_WORD_SIZE - 1) / KDB_WORD_SIZE;
39748 + bb_memory_params = max(bb_memory_params, o);
39752 +/* A generic write to an operand, resulting in an undefined value in that
39753 + * location. All well defined operands are handled separately, this function
39754 + * only handles the opcodes where the result is undefined.
39758 +bb_write_operand(const struct bb_operand *operand)
39760 + enum bb_reg_code base_rc = operand->base_rc;
39761 + if (operand->memory) {
39763 + bb_reg_read(base_rc);
39764 + if (operand->index_rc)
39765 + bb_reg_read(operand->index_rc);
39766 + } else if (operand->reg && base_rc) {
39767 + bb_reg_set_undef(base_rc);
39769 + if (bb_is_simple_memory(operand) && bb_is_osp_defined(base_rc)) {
39771 + offset = bb_reg_code_offset(base_rc) + operand->disp;
39772 + offset = ALIGN(offset - KDB_WORD_SIZE + 1, KDB_WORD_SIZE);
39773 + bb_delete_memory(offset);
39777 +/* Adjust a register that contains a stack pointer */
39780 +bb_adjust_osp(enum bb_reg_code reg, int adjust)
39782 + int offset = bb_reg_code_offset(reg), old_offset = offset;
39783 + KDB_DEBUG_BB(" %s osp offset ", bbrg_name[reg]);
39784 + KDB_DEBUG_BB_OFFSET(bb_reg_code_offset(reg), "", " -> ");
39785 + offset += adjust;
39786 + bb_reg_code_set_offset(reg, offset);
39787 + KDB_DEBUG_BB_OFFSET(bb_reg_code_offset(reg), "", "\n");
39788 + /* When RSP is adjusted upwards, it invalidates any memory
39789 + * stored between the old and current stack offsets.
39791 + if (reg == BBRG_RSP) {
39792 + while (old_offset < bb_reg_code_offset(reg)) {
39793 + bb_delete_memory(old_offset);
39794 + old_offset += KDB_WORD_SIZE;
39799 +/* The current instruction adjusts a register that contains a stack pointer.
39800 + * Direction is 1 or -1, depending on whether the instruction is add/lea or
39805 +bb_adjust_osp_instruction(int direction)
39807 + enum bb_reg_code dst_reg = bb_decode.dst.base_rc;
39808 + if (bb_decode.src.immediate ||
39809 + bb_decode.match->usage == BBOU_LEA /* lea has its own checks */) {
39810 + int adjust = direction * bb_decode.src.disp;
39811 + bb_adjust_osp(dst_reg, adjust);
39813 + /* variable stack adjustment, osp offset is not well defined */
39814 + KDB_DEBUG_BB(" %s osp offset ", bbrg_name[dst_reg]);
39815 + KDB_DEBUG_BB_OFFSET(bb_reg_code_offset(dst_reg), "", " -> undefined\n");
39816 + bb_reg_code_set_value(dst_reg, BBRG_UNDEFINED);
39817 + bb_reg_code_set_offset(dst_reg, 0);
39821 +/* Some instructions using memory have an explicit length suffix (b, w, l, q).
39822 + * The equivalent instructions using a register imply the length from the
39823 + * register name. Deduce the operand length.
39827 +bb_operand_length(const struct bb_operand *operand, char opcode_suffix)
39830 + switch (opcode_suffix) {
39844 + if (l == 0 && operand->reg) {
39845 + switch (strlen(operand->base)) {
39847 + switch (operand->base[2]) {
39857 + if (operand->base[1] == 'r')
39868 +bb_reg_state_size(const struct bb_reg_state *state)
39870 + return sizeof(*state) +
39871 + state->mem_count * sizeof(state->memory[0]);
39874 +/* Canonicalize the current bb_reg_state so it can be compared against
39875 + * previously created states. Sort the memory entries in descending order of
39876 + * offset_address (stack grows down). Empty slots are moved to the end of the
39877 + * list and trimmed.
39881 +bb_reg_state_canonicalize(void)
39883 + int i, o, changed;
39884 + struct bb_memory_contains *p1, *p2, temp;
39887 + for (i = 0, p1 = bb_reg_state->memory;
39888 + i < bb_reg_state->mem_count-1;
39891 + if (p2->value == BBRG_UNDEFINED) {
39893 + } else if (p1->value == BBRG_UNDEFINED) {
39895 + } else if (p1->offset_address < p2->offset_address) {
39897 + } else if (p1->offset_address > p2->offset_address) {
39909 + } while(changed);
39910 + for (i = 0, p1 = bb_reg_state->memory;
39911 + i < bb_reg_state_max;
39913 + if (p1->value != BBRG_UNDEFINED)
39914 + bb_reg_state->mem_count = i + 1;
39916 + bb_reg_state_print(bb_reg_state);
39920 +bb_special_case(bfd_vma to)
39922 + int i, j, rsp_offset, expect_offset, offset, errors = 0, max_errors = 40;
39923 + enum bb_reg_code reg, expect_value, value;
39924 + struct bb_name_state *r;
39926 + for (i = 0, r = bb_special_cases;
39927 + i < ARRAY_SIZE(bb_special_cases);
39929 + if (to == r->address &&
39930 + (r->fname == NULL || strcmp(bb_func_name, r->fname) == 0))
39933 + /* Some inline assembler code has jumps to .fixup sections which result
39934 + * in out of line transfers with undefined state, ignore them.
39936 + if (strcmp(bb_func_name, "strnlen_user") == 0 ||
39937 + strcmp(bb_func_name, "copy_from_user") == 0)
39942 + /* Check the running registers match */
39943 + for (reg = BBRG_RAX; reg < r->regs_size; ++reg) {
39944 + expect_value = r->regs[reg].value;
39945 + if (test_bit(expect_value, r->skip_regs.bits)) {
39946 + /* this regs entry is not defined for this label */
39949 + if (expect_value == BBRG_UNDEFINED)
39951 + expect_offset = r->regs[reg].offset;
39952 + value = bb_reg_code_value(reg);
39953 + offset = bb_reg_code_offset(reg);
39954 + if (expect_value == value &&
39955 + (value != BBRG_OSP || r->osp_offset == offset))
39957 + kdb_printf("%s: Expected %s to contain %s",
39960 + bbrg_name[expect_value]);
39961 + if (r->osp_offset)
39962 + KDB_DEBUG_BB_OFFSET_PRINTF(r->osp_offset, "", "");
39963 + kdb_printf(". It actually contains %s", bbrg_name[value]);
39965 + KDB_DEBUG_BB_OFFSET_PRINTF(offset, "", "");
39966 + kdb_printf("\n");
39968 + if (max_errors-- == 0)
39971 + /* Check that any memory data on stack matches */
39973 + while (i < bb_reg_state->mem_count &&
39974 + j < r->mem_size) {
39975 + expect_value = r->mem[j].value;
39976 + if (test_bit(expect_value, r->skip_mem.bits) ||
39977 + expect_value == BBRG_UNDEFINED) {
39978 + /* this memory slot is not defined for this label */
39982 + rsp_offset = bb_reg_state->memory[i].offset_address -
39983 + bb_reg_code_offset(BBRG_RSP);
39985 + r->mem[j].offset_address) {
39986 + /* extra slots in memory are OK */
39988 + } else if (rsp_offset <
39989 + r->mem[j].offset_address) {
39990 + /* Required memory slot is missing */
39991 + kdb_printf("%s: Invalid bb_reg_state.memory, "
39992 + "missing memory entry[%d] %s\n",
39993 + __FUNCTION__, j, bbrg_name[expect_value]);
39995 + if (max_errors-- == 0)
39999 + if (bb_reg_state->memory[i].offset_value ||
40000 + bb_reg_state->memory[i].value != expect_value) {
40001 + /* memory slot is present but contains wrong
40004 + kdb_printf("%s: Invalid bb_reg_state.memory, "
40005 + "wrong value in slot %d, "
40006 + "should be %s, it is %s\n",
40008 + bbrg_name[expect_value],
40009 + bbrg_name[bb_reg_state->memory[i].value]);
40011 + if (max_errors-- == 0)
40018 + while (j < r->mem_size) {
40019 + expect_value = r->mem[j].value;
40020 + if (test_bit(expect_value, r->skip_mem.bits) ||
40021 + expect_value == BBRG_UNDEFINED)
40026 + if (j != r->mem_size) {
40027 + /* Hit end of memory before testing all the pt_reg slots */
40028 + kdb_printf("%s: Invalid bb_reg_state.memory, "
40029 + "missing trailing entries\n",
40032 + if (max_errors-- == 0)
40039 + kdb_printf("%s: on transfer to %s\n", __FUNCTION__, r->name);
40044 +/* Transfer of control to a label outside the current function. If the
40045 + * transfer is to a known common code path then do a sanity check on the state
40050 +bb_sanity_check(int type)
40052 + enum bb_reg_code expect, actual;
40053 + int i, offset, error = 0;
40055 + for (i = 0; i < ARRAY_SIZE(bb_preserved_reg); ++i) {
40056 + expect = bb_preserved_reg[i];
40057 + actual = bb_reg_code_value(expect);
40058 + offset = bb_reg_code_offset(expect);
40059 + if (expect == actual)
40061 + /* type == 1 is sysret/sysexit, ignore RSP */
40062 + if (type && expect == BBRG_RSP)
40064 +#ifndef CONFIG_X86_64
40065 + /* type == 1 is sysret/sysexit, ignore RBP for i386 */
40066 + if (type && expect == BBRG_RBP)
40068 +#endif /* !CONFIG_X86_64 */
40069 + /* RSP should contain OSP+0. Except for ptregscall_common and
40070 + * ia32_ptregs_common, they get a partial pt_regs, fudge the
40071 + * stack to make it a full pt_regs then reverse the effect on
40072 + * exit, so the offset is -0x50 on exit.
40074 + if (expect == BBRG_RSP &&
40075 + bb_is_osp_defined(expect) &&
40077 + (offset == -0x50 &&
40078 + (strcmp(bb_func_name, "ptregscall_common") == 0 ||
40079 + strcmp(bb_func_name, "ia32_ptregs_common") == 0))))
40081 + kdb_printf("%s: Expected %s, got %s",
40083 + bbrg_name[expect], bbrg_name[actual]);
40085 + KDB_DEBUG_BB_OFFSET_PRINTF(offset, "", "");
40086 + kdb_printf("\n");
40089 + BB_CHECK(error, error, );
40092 +/* Transfer of control. Follow the arc and save the current state as input to
40093 + * another basic block.
40097 +bb_transfer(bfd_vma from, bfd_vma to, unsigned int drop_through)
40101 + struct bb* bb = NULL; /*stupid gcc */
40102 + struct bb_jmp *bb_jmp;
40103 + struct bb_reg_state *state;
40104 + bb_reg_state_canonicalize();
40106 + for (i = 0; i < bb_jmp_count; ++i) {
40107 + bb_jmp = bb_jmp_list + i;
40108 + if (bb_jmp->from == from &&
40109 + bb_jmp->to == to &&
40110 + bb_jmp->drop_through == drop_through) {
40116 + /* Transfer outside the current function. Check the special
40117 + * cases (mainly in entry.S) first. If it is not a known
40118 + * special case then check if the target address is the start
40119 + * of a function or not. If it is the start of a function then
40120 + * assume tail recursion and require that the state be the same
40121 + * as on entry. Otherwise assume out of line code (e.g.
40122 + * spinlock contention path) and ignore it, the state can be
40125 + kdb_symtab_t symtab;
40126 + if (bb_special_case(to))
40128 + kdbnearsym(to, &symtab);
40129 + if (symtab.sym_start != to)
40131 + bb_sanity_check(0);
40134 +#ifdef NO_SIBLINGS
40135 + /* Only print this message when the kernel is compiled with
40136 + * -fno-optimize-sibling-calls. Otherwise it would print a
40137 + * message for every tail recursion call. If you see the
40138 + * message below then you probably have an assembler label that
40139 + * is not listed in the special cases.
40141 + kdb_printf(" not matched: from "
40143 + " to " kdb_bfd_vma_fmt0
40144 + " drop_through %d bb_jmp[%d]\n",
40145 + from, to, drop_through, i);
40146 +#endif /* NO_SIBLINGS */
40149 + KDB_DEBUG_BB(" matched: from " kdb_bfd_vma_fmt0
40150 + " to " kdb_bfd_vma_fmt0
40151 + " drop_through %d bb_jmp[%d]\n",
40152 + from, to, drop_through, i);
40154 + for (i = 0; i < bb_count; ++i) {
40156 + if (bb->start == to) {
40161 + BB_CHECK(!found, to, );
40162 + /* If the register state for this arc has already been set (we are
40163 + * rescanning the block that originates the arc) and the state is the
40164 + * same as the previous state for this arc then this input to the
40165 + * target block is the same as last time, so there is no need to rescan
40166 + * the target block.
40168 + state = bb_jmp->state;
40169 + size = bb_reg_state_size(bb_reg_state);
40171 + bb_reg_state->ref_count = state->ref_count;
40172 + if (memcmp(state, bb_reg_state, size) == 0) {
40173 + KDB_DEBUG_BB(" no state change\n");
40176 + if (--state->ref_count == 0)
40177 + debug_kfree(state);
40178 + bb_jmp->state = NULL;
40180 + /* New input state is required. To save space, check if any other arcs
40181 + * have the same state and reuse them where possible. The overall set
40182 + * of inputs to the target block is now different so the target block
40183 + * must be rescanned.
40186 + for (i = 0; i < bb_jmp_count; ++i) {
40187 + state = bb_jmp_list[i].state;
40190 + bb_reg_state->ref_count = state->ref_count;
40191 + if (memcmp(state, bb_reg_state, size) == 0) {
40192 + KDB_DEBUG_BB(" reuse bb_jmp[%d]\n", i);
40193 + bb_jmp->state = state;
40194 + ++state->ref_count;
40198 + state = debug_kmalloc(size, GFP_ATOMIC);
40200 + kdb_printf("\n\n%s: out of debug_kmalloc\n", __FUNCTION__);
40204 + memcpy(state, bb_reg_state, size);
40205 + state->ref_count = 1;
40206 + bb_jmp->state = state;
40207 + KDB_DEBUG_BB(" new state %p\n", state);
40210 +/* Isolate the processing for 'mov' so it can be used for 'xadd'/'xchg' as
40214 +static enum bb_operand_usage
40215 +bb_usage_mov(const struct bb_operand *src, const struct bb_operand *dst, int l)
40217 + int full_register_src, full_register_dst;
40218 + full_register_src = bb_operand_length(src, bb_decode.opcode[l])
40219 + == KDB_WORD_SIZE * 8;
40220 + full_register_dst = bb_operand_length(dst, bb_decode.opcode[l])
40221 + == KDB_WORD_SIZE * 8;
40222 + /* If both src and dst are full integer registers then record the
40223 + * register change.
40226 + bb_is_int_reg(src->base_rc) &&
40228 + bb_is_int_reg(dst->base_rc) &&
40229 + full_register_src &&
40230 + full_register_dst) {
40231 + bb_reg_set_reg(dst->base_rc, src->base_rc);
40234 + /* If the move is from a full integer register to stack then record it.
40237 + bb_is_simple_memory(dst) &&
40238 + bb_is_osp_defined(dst->base_rc) &&
40239 + full_register_src) {
40240 + /* Ugly special case. Initializing list heads on stack causes
40241 + * false references to stack variables when the list head is
40242 + * used. Static code analysis cannot detect that the list head
40243 + * has been changed by a previous execution loop and that a
40244 + * basic block is only executed after the list head has been
40247 + * These false references can result in valid stack variables
40248 + * being incorrectly cleared on some logic paths. Ignore
40249 + * stores to stack variables which point to themselves or to
40250 + * the previous word so the list head initialization is not
40253 + if (bb_is_osp_defined(src->base_rc)) {
40254 + int stack1 = bb_reg_code_offset(src->base_rc);
40255 + int stack2 = bb_reg_code_offset(dst->base_rc) +
40257 + if (stack1 == stack2 ||
40258 + stack1 == stack2 - KDB_WORD_SIZE)
40261 + bb_memory_set_reg(dst->base_rc, src->base_rc, dst->disp);
40264 + /* If the move is from stack to a full integer register then record it.
40266 + if (bb_is_simple_memory(src) &&
40267 + bb_is_osp_defined(src->base_rc) &&
40269 + bb_is_int_reg(dst->base_rc) &&
40270 + full_register_dst) {
40271 +#ifndef CONFIG_X86_64
40272 + /* mov from TSS_sysenter_esp0+offset to esp to fix up the
40273 + * sysenter stack, it leaves esp well defined. mov
40274 + * TSS_sysenter_esp0+offset(%esp),%esp is followed by up to 5
40275 + * push instructions to mimic the hardware stack push. If
40276 + * TSS_sysenter_esp0 is offset then only 3 words will be
40279 + if (dst->base_rc == BBRG_RSP &&
40280 + src->disp >= TSS_sysenter_esp0 &&
40281 + bb_is_osp_defined(BBRG_RSP)) {
40283 + pushes = src->disp == TSS_sysenter_esp0 ? 5 : 3;
40284 + bb_reg_code_set_offset(BBRG_RSP,
40285 + bb_reg_code_offset(BBRG_RSP) +
40286 + pushes * KDB_WORD_SIZE);
40287 + KDB_DEBUG_BB_OFFSET(
40288 + bb_reg_code_offset(BBRG_RSP),
40289 + " sysenter fixup, RSP",
40293 +#endif /* !CONFIG_X86_64 */
40294 + bb_read_operand(src);
40295 + bb_reg_set_memory(dst->base_rc, src->base_rc, src->disp);
40298 + /* move %gs:0x<nn>,%rsp is used to unconditionally switch to another
40299 + * stack. Ignore this special case, it is handled by the stack
40300 + * unwinding code.
40302 + if (src->segment &&
40303 + strcmp(src->segment, "%gs") == 0 &&
40305 + dst->base_rc == BBRG_RSP)
40307 + /* move %reg,%reg is a nop */
40312 + strcmp(src->base, dst->base) == 0)
40314 + /* Special case for the code that switches stacks in the scheduler
40315 + * (switch_to()). That code must modify RSP but it does it in a well
40316 + * defined manner. Do not invalidate RSP.
40319 + dst->base_rc == BBRG_RSP &&
40320 + full_register_dst &&
40321 + bb_is_scheduler_address())
40323 + return BBOU_RSWD;
40326 +static enum bb_operand_usage
40327 +bb_usage_xadd(const struct bb_operand *src, const struct bb_operand *dst)
40329 + /* Simulate xadd as a series of instructions including mov, that way we
40330 + * get the benefit of all the special cases already handled by
40333 + * tmp = src + dst, src = dst, dst = tmp.
40335 + * For tmp, pick a register that is undefined. If all registers are
40336 + * defined then pick one that is not being used by xadd.
40338 + enum bb_reg_code reg = BBRG_UNDEFINED;
40339 + struct bb_operand tmp;
40340 + struct bb_reg_contains save_tmp;
40341 + enum bb_operand_usage usage;
40342 + int undefined = 0;
40343 + for (reg = BBRG_RAX; reg < BBRG_RAX + KDB_INT_REGISTERS; ++reg) {
40344 + if (bb_reg_code_value(reg) == BBRG_UNDEFINED) {
40349 + if (!undefined) {
40350 + for (reg = BBRG_RAX; reg < BBRG_RAX + KDB_INT_REGISTERS; ++reg) {
40351 + if (reg != src->base_rc &&
40352 + reg != src->index_rc &&
40353 + reg != dst->base_rc &&
40354 + reg != dst->index_rc &&
40359 + KDB_DEBUG_BB(" %s saving tmp %s\n", __FUNCTION__, bbrg_name[reg]);
40360 + save_tmp = bb_reg_state->contains[reg - BBRG_RAX];
40361 + bb_reg_set_undef(reg);
40362 + memset(&tmp, 0, sizeof(tmp));
40365 + tmp.base = (char *)bbrg_name[reg];
40366 + tmp.base_rc = reg;
40367 + bb_read_operand(src);
40368 + bb_read_operand(dst);
40369 + if (bb_usage_mov(src, dst, sizeof("xadd")-1) == BBOU_NOP)
40370 + usage = BBOU_RSRD;
40372 + usage = BBOU_RSRDWS;
40373 + bb_usage_mov(&tmp, dst, sizeof("xadd")-1);
40374 + KDB_DEBUG_BB(" %s restoring tmp %s\n", __FUNCTION__, bbrg_name[reg]);
40375 + bb_reg_state->contains[reg - BBRG_RAX] = save_tmp;
40379 +static enum bb_operand_usage
40380 +bb_usage_xchg(const struct bb_operand *src, const struct bb_operand *dst)
40382 + /* Simulate xchg as a series of mov instructions, that way we get the
40383 + * benefit of all the special cases already handled by BBOU_MOV.
40385 + * mov dst,tmp; mov src,dst; mov tmp,src;
40387 + * For tmp, pick a register that is undefined. If all registers are
40388 + * defined then pick one that is not being used by xchg.
40390 + enum bb_reg_code reg = BBRG_UNDEFINED;
40391 + int rs = BBOU_RS, rd = BBOU_RD, ws = BBOU_WS, wd = BBOU_WD;
40392 + struct bb_operand tmp;
40393 + struct bb_reg_contains save_tmp;
40394 + int undefined = 0;
40395 + for (reg = BBRG_RAX; reg < BBRG_RAX + KDB_INT_REGISTERS; ++reg) {
40396 + if (bb_reg_code_value(reg) == BBRG_UNDEFINED) {
40401 + if (!undefined) {
40402 + for (reg = BBRG_RAX; reg < BBRG_RAX + KDB_INT_REGISTERS; ++reg) {
40403 + if (reg != src->base_rc &&
40404 + reg != src->index_rc &&
40405 + reg != dst->base_rc &&
40406 + reg != dst->index_rc &&
40411 + KDB_DEBUG_BB(" %s saving tmp %s\n", __FUNCTION__, bbrg_name[reg]);
40412 + save_tmp = bb_reg_state->contains[reg - BBRG_RAX];
40413 + memset(&tmp, 0, sizeof(tmp));
40416 + tmp.base = (char *)bbrg_name[reg];
40417 + tmp.base_rc = reg;
40418 + if (bb_usage_mov(dst, &tmp, sizeof("xchg")-1) == BBOU_NOP)
40420 + if (bb_usage_mov(src, dst, sizeof("xchg")-1) == BBOU_NOP) {
40424 + if (bb_usage_mov(&tmp, src, sizeof("xchg")-1) == BBOU_NOP)
40426 + KDB_DEBUG_BB(" %s restoring tmp %s\n", __FUNCTION__, bbrg_name[reg]);
40427 + bb_reg_state->contains[reg - BBRG_RAX] = save_tmp;
40428 + return rs | rd | ws | wd;
40431 +/* Invalidate all the scratch registers */
40434 +bb_invalidate_scratch_reg(void)
40437 + for (i = BBRG_RAX; i < BBRG_RAX + KDB_INT_REGISTERS; ++i) {
40438 + for (j = 0; j < ARRAY_SIZE(bb_preserved_reg); ++j) {
40439 + if (i == bb_preserved_reg[j])
40442 + bb_reg_set_undef(i);
40450 +bb_pass2_computed_jmp(const struct bb_operand *src)
40452 + unsigned long table = src->disp;
40453 + kdb_machreg_t addr;
40454 + while (!bb_giveup) {
40455 + if (kdb_getword(&addr, table, sizeof(addr)))
40457 + if (addr < bb_func_start || addr >= bb_func_end)
40459 + bb_transfer(bb_curr_addr, addr, 0);
40460 + table += KDB_WORD_SIZE;
40464 +/* The current instruction has been decoded and all the information is in
40465 + * bb_decode. Based on the opcode, track any operand usage that we care about.
40471 + enum bb_operand_usage usage = bb_decode.match->usage;
40472 + struct bb_operand *src = &bb_decode.src;
40473 + struct bb_operand *dst = &bb_decode.dst;
40474 + struct bb_operand *dst2 = &bb_decode.dst2;
40475 + int opcode_suffix, operand_length;
40477 + /* First handle all the special usage cases, and map them to a generic
40478 + * case after catering for the side effects.
40481 + if (usage == BBOU_IMUL &&
40482 + src->present && !dst->present && !dst2->present) {
40483 + /* single operand imul, same effects as mul */
40484 + usage = BBOU_MUL;
40487 + /* AT&T syntax uses movs<l1><l2> for move with sign extension, instead
40488 + * of the Intel movsx. The AT&T syntax causes problems for the opcode
40489 + * mapping; movs with sign extension needs to be treated as a generic
40490 + * read src, write dst, but instead it falls under the movs I/O
40491 + * instruction. Fix it.
40493 + if (usage == BBOU_MOVS && strlen(bb_decode.opcode) > 5)
40494 + usage = BBOU_RSWD;
40496 + /* This switch statement deliberately does not use 'default' at the top
40497 + * level. That way the compiler will complain if a new BBOU_ enum is
40498 + * added above and not explicitly handled here.
40501 + case BBOU_UNKNOWN: /* drop through */
40502 + case BBOU_RS: /* drop through */
40503 + case BBOU_RD: /* drop through */
40504 + case BBOU_RSRD: /* drop through */
40505 + case BBOU_WS: /* drop through */
40506 + case BBOU_RSWS: /* drop through */
40507 + case BBOU_RDWS: /* drop through */
40508 + case BBOU_RSRDWS: /* drop through */
40509 + case BBOU_WD: /* drop through */
40510 + case BBOU_RSWD: /* drop through */
40511 + case BBOU_RDWD: /* drop through */
40512 + case BBOU_RSRDWD: /* drop through */
40513 + case BBOU_WSWD: /* drop through */
40514 + case BBOU_RSWSWD: /* drop through */
40515 + case BBOU_RDWSWD: /* drop through */
40516 + case BBOU_RSRDWSWD:
40517 + break; /* ignore generic usage for now */
40519 + /* Special case for add instructions that adjust registers
40520 + * which are mapping the stack.
40522 + if (dst->reg && bb_is_osp_defined(dst->base_rc)) {
40523 + bb_adjust_osp_instruction(1);
40526 + usage = BBOU_RSRDWD;
40530 + /* Invalidate the scratch registers. Functions sync_regs and
40531 + * save_v86_state are special, their return value is the new
40534 + bb_reg_state_print(bb_reg_state);
40535 + bb_invalidate_scratch_reg();
40536 + if (bb_is_static_disp(src)) {
40537 + if (src->disp == bb_sync_regs) {
40538 + bb_reg_set_reg(BBRG_RAX, BBRG_RSP);
40539 + } else if (src->disp == bb_save_v86_state) {
40540 + bb_reg_set_reg(BBRG_RAX, BBRG_RSP);
40541 + bb_adjust_osp(BBRG_RAX, +KDB_WORD_SIZE);
40544 + usage = BBOU_NOP;
40547 + /* Convert word in RAX. Read RAX, write RAX */
40548 + bb_reg_read(BBRG_RAX);
40549 + bb_reg_set_undef(BBRG_RAX);
40550 + usage = BBOU_NOP;
40553 + /* cmove %gs:0x<nn>,%rsp is used to conditionally switch to
40554 + * another stack. Ignore this special case, it is handled by
40555 + * the stack unwinding code.
40557 + if (src->segment &&
40558 + strcmp(src->segment, "%gs") == 0 &&
40560 + dst->base_rc == BBRG_RSP)
40561 + usage = BBOU_NOP;
40563 + usage = BBOU_RSWD;
40565 + case BBOU_CMPXCHG:
40566 + /* Read RAX, write RAX plus src read, dst write */
40567 + bb_reg_read(BBRG_RAX);
40568 + bb_reg_set_undef(BBRG_RAX);
40569 + usage = BBOU_RSWD;
40571 + case BBOU_CMPXCHGD:
40572 + /* Read RAX, RBX, RCX, RDX, write RAX, RDX plus src read/write */
40573 + bb_reg_read(BBRG_RAX);
40574 + bb_reg_read(BBRG_RBX);
40575 + bb_reg_read(BBRG_RCX);
40576 + bb_reg_read(BBRG_RDX);
40577 + bb_reg_set_undef(BBRG_RAX);
40578 + bb_reg_set_undef(BBRG_RDX);
40579 + usage = BBOU_RSWS;
40582 + /* Read RAX, write RAX, RBX, RCX, RDX */
40583 + bb_reg_read(BBRG_RAX);
40584 + bb_reg_set_undef(BBRG_RAX);
40585 + bb_reg_set_undef(BBRG_RBX);
40586 + bb_reg_set_undef(BBRG_RCX);
40587 + bb_reg_set_undef(BBRG_RDX);
40588 + usage = BBOU_NOP;
40591 + /* Convert word in RAX, RDX. Read RAX, write RDX */
40592 + bb_reg_read(BBRG_RAX);
40593 + bb_reg_set_undef(BBRG_RDX);
40594 + usage = BBOU_NOP;
40596 + case BBOU_DIV: /* drop through */
40598 + /* The 8 bit variants only affect RAX, the 16, 32 and 64 bit
40599 + * variants affect RDX as well.
40603 + opcode_suffix = bb_decode.opcode[3];
40606 + opcode_suffix = bb_decode.opcode[4];
40609 + opcode_suffix = 'q';
40612 + operand_length = bb_operand_length(src, opcode_suffix);
40613 + bb_reg_read(BBRG_RAX);
40614 + bb_reg_set_undef(BBRG_RAX);
40615 + if (operand_length != 8) {
40616 + bb_reg_read(BBRG_RDX);
40617 + bb_reg_set_undef(BBRG_RDX);
40622 + /* Only the two and three operand forms get here. The one
40623 + * operand form is treated as mul.
40625 + if (dst2->present) {
40626 + /* The three operand form is a special case, read the first two
40627 + * operands, write the third.
40629 + bb_read_operand(src);
40630 + bb_read_operand(dst);
40631 + bb_write_operand(dst2);
40632 + usage = BBOU_NOP;
40634 + usage = BBOU_RSRDWD;
40638 + bb_sanity_check(0);
40639 + usage = BBOU_NOP;
40642 + if (bb_is_static_disp(src))
40643 + bb_transfer(bb_curr_addr, src->disp, 0);
40644 + else if (src->indirect &&
40646 + src->base == NULL &&
40648 + src->scale == KDB_WORD_SIZE)
40649 + bb_pass2_computed_jmp(src);
40654 + bb_reg_set_undef(BBRG_RAX);
40655 + usage = BBOU_NOP;
40658 + /* dst = src + disp. Often used to calculate offsets into the
40659 + * stack, so check if it uses a stack pointer.
40661 + usage = BBOU_RSWD;
40662 + if (bb_is_simple_memory(src)) {
40663 + if (bb_is_osp_defined(src->base_rc)) {
40664 + bb_reg_set_reg(dst->base_rc, src->base_rc);
40665 + bb_adjust_osp_instruction(1);
40667 + } else if (src->disp == 0 &&
40668 + src->base_rc == dst->base_rc) {
40669 + /* lea 0(%reg),%reg is generated by i386
40672 + usage = BBOU_NOP;
40677 + /* RSP = RBP; RBP = *(RSP); RSP += KDB_WORD_SIZE; */
40678 + bb_reg_set_reg(BBRG_RSP, BBRG_RBP);
40679 + if (bb_is_osp_defined(BBRG_RSP))
40680 + bb_reg_set_memory(BBRG_RBP, BBRG_RSP, 0);
40682 + bb_reg_set_undef(BBRG_RBP);
40683 + if (bb_is_osp_defined(BBRG_RSP))
40684 + bb_adjust_osp(BBRG_RSP, KDB_WORD_SIZE);
40685 + /* common_interrupt uses leave in a non-standard manner */
40686 + if (strcmp(bb_func_name, "common_interrupt") != 0)
40687 + bb_sanity_check(0);
40688 + usage = BBOU_NOP;
40691 + /* Read RSI, write RAX, RSI */
40692 + bb_reg_read(BBRG_RSI);
40693 + bb_reg_set_undef(BBRG_RAX);
40694 + bb_reg_set_undef(BBRG_RSI);
40695 + usage = BBOU_NOP;
40698 + /* Read and write RCX */
40699 + bb_reg_read(BBRG_RCX);
40700 + bb_reg_set_undef(BBRG_RCX);
40701 + if (bb_is_static_disp(src))
40702 + bb_transfer(bb_curr_addr, src->disp, 0);
40703 + usage = BBOU_NOP;
40706 + /* lss offset(%esp),%esp leaves esp well defined */
40708 + dst->base_rc == BBRG_RSP &&
40709 + bb_is_simple_memory(src) &&
40710 + src->base_rc == BBRG_RSP) {
40711 + bb_adjust_osp(BBRG_RSP, 2*KDB_WORD_SIZE + src->disp);
40712 + usage = BBOU_NOP;
40714 + usage = BBOU_RSWD;
40717 + case BBOU_MONITOR:
40718 + /* Read RAX, RCX, RDX */
40719 + bb_reg_set_undef(BBRG_RAX);
40720 + bb_reg_set_undef(BBRG_RCX);
40721 + bb_reg_set_undef(BBRG_RDX);
40722 + usage = BBOU_NOP;
40725 + usage = bb_usage_mov(src, dst, sizeof("mov")-1);
40728 + /* Read RSI, RDI, write RSI, RDI */
40729 + bb_reg_read(BBRG_RSI);
40730 + bb_reg_read(BBRG_RDI);
40731 + bb_reg_set_undef(BBRG_RSI);
40732 + bb_reg_set_undef(BBRG_RDI);
40733 + usage = BBOU_NOP;
40736 + /* imul (one operand form only) or mul. Read RAX. If the
40737 + * operand length is not 8 then write RDX.
40739 + if (bb_decode.opcode[0] == 'i')
40740 + opcode_suffix = bb_decode.opcode[4];
40742 + opcode_suffix = bb_decode.opcode[3];
40743 + operand_length = bb_operand_length(src, opcode_suffix);
40744 + bb_reg_read(BBRG_RAX);
40745 + if (operand_length != 8)
40746 + bb_reg_set_undef(BBRG_RDX);
40747 + usage = BBOU_NOP;
40750 + /* Read RAX, RCX */
40751 + bb_reg_read(BBRG_RAX);
40752 + bb_reg_read(BBRG_RCX);
40753 + usage = BBOU_NOP;
40758 + /* Read RSI, RDX, write RSI */
40759 + bb_reg_read(BBRG_RSI);
40760 + bb_reg_read(BBRG_RDX);
40761 + bb_reg_set_undef(BBRG_RSI);
40762 + usage = BBOU_NOP;
40765 + /* Complicated by the fact that you can pop from top of stack
40766 + * to a stack location, for this case the destination location
40767 + * is calculated after adjusting RSP. Analysis of the kernel
40768 + * code shows that gcc only uses this strange format to get the
40769 + * flags into a local variable, e.g. pushf; popl 0x10(%esp); so
40770 + * I am going to ignore this special case.
40773 + if (!bb_is_osp_defined(BBRG_RSP)) {
40774 + if (!bb_is_scheduler_address()) {
40775 + kdb_printf("pop when BBRG_RSP is undefined?\n");
40780 + bb_reg_set_memory(src->base_rc, BBRG_RSP, 0);
40781 + usage = BBOU_NOP;
40783 + bb_adjust_osp(BBRG_RSP, KDB_WORD_SIZE);
40787 + /* Do not care about flags, just adjust RSP */
40788 + if (!bb_is_osp_defined(BBRG_RSP)) {
40789 + if (!bb_is_scheduler_address()) {
40790 + kdb_printf("popf when BBRG_RSP is undefined?\n");
40794 + bb_adjust_osp(BBRG_RSP, KDB_WORD_SIZE);
40799 + /* Complicated by the fact that you can push from a stack
40800 + * location to top of stack, the source location is calculated
40801 + * before adjusting RSP. Analysis of the kernel code shows
40802 + * that gcc only uses this strange format to restore the flags
40803 + * from a local variable, e.g. pushl 0x10(%esp); popf; so I am
40804 + * going to ignore this special case.
40807 + if (!bb_is_osp_defined(BBRG_RSP)) {
40808 + if (!bb_is_scheduler_address()) {
40809 + kdb_printf("push when BBRG_RSP is undefined?\n");
40813 + bb_adjust_osp(BBRG_RSP, -KDB_WORD_SIZE);
40815 + bb_reg_code_offset(BBRG_RSP) <= 0)
40816 + bb_memory_set_reg(BBRG_RSP, src->base_rc, 0);
40820 + /* Do not care about flags, just adjust RSP */
40821 + if (!bb_is_osp_defined(BBRG_RSP)) {
40822 + if (!bb_is_scheduler_address()) {
40823 + kdb_printf("pushf when BBRG_RSP is undefined?\n");
40827 + bb_adjust_osp(BBRG_RSP, -KDB_WORD_SIZE);
40832 + /* Read RCX, write RAX, RDX */
40833 + bb_reg_read(BBRG_RCX);
40834 + bb_reg_set_undef(BBRG_RAX);
40835 + bb_reg_set_undef(BBRG_RDX);
40836 + usage = BBOU_NOP;
40839 + /* Write RAX, RDX */
40840 + bb_reg_set_undef(BBRG_RAX);
40841 + bb_reg_set_undef(BBRG_RDX);
40842 + usage = BBOU_NOP;
40845 + bb_sanity_check(0);
40846 + usage = BBOU_NOP;
40850 + bb_reg_read(BBRG_RAX);
40851 + usage = BBOU_NOP;
40854 + /* Read RAX, RDI, write RDI */
40855 + bb_reg_read(BBRG_RAX);
40856 + bb_reg_read(BBRG_RDI);
40857 + bb_reg_set_undef(BBRG_RDI);
40858 + usage = BBOU_NOP;
40861 + /* Special case for sub instructions that adjust registers
40862 + * which are mapping the stack.
40864 + if (dst->reg && bb_is_osp_defined(dst->base_rc)) {
40865 + bb_adjust_osp_instruction(-1);
40868 + usage = BBOU_RSRDWD;
40871 + case BBOU_SYSEXIT:
40872 + bb_sanity_check(1);
40873 + usage = BBOU_NOP;
40875 + case BBOU_SYSRET:
40876 + bb_sanity_check(1);
40877 + usage = BBOU_NOP;
40880 + /* Read RCX, RAX, RDX */
40881 + bb_reg_read(BBRG_RCX);
40882 + bb_reg_read(BBRG_RAX);
40883 + bb_reg_read(BBRG_RDX);
40884 + usage = BBOU_NOP;
40887 + usage = bb_usage_xadd(src, dst);
40890 + /* i386 do_IRQ with 4K stacks does xchg %ebx,%esp; call
40891 + * irq_handler; mov %ebx,%esp; to switch stacks. Ignore this
40892 + * stack switch when tracking registers, it is handled by
40893 + * higher level backtrace code. Convert xchg %ebx,%esp to mov
40894 + * %esp,%ebx so the later mov %ebx,%esp becomes a NOP and the
40895 + * stack remains defined so we can backtrace through do_IRQ's
40900 + src->base_rc == BBRG_RBX &&
40901 + dst->base_rc == BBRG_RSP &&
40902 + strcmp(bb_func_name, "do_IRQ") == 0) {
40903 + strcpy(bb_decode.opcode, "mov");
40904 + usage = bb_usage_mov(dst, src, sizeof("mov")-1);
40906 + usage = bb_usage_xchg(src, dst);
40910 + /* xor %reg,%reg only counts as a register write, the original
40911 + * contents of reg are irrelevant.
40913 + if (src->reg && dst->reg && src->base_rc == dst->base_rc)
40916 + usage = BBOU_RSRDWD;
40920 + /* The switch statement above handled all the special cases. Every
40921 + * opcode should now have a usage of NOP or one of the generic cases.
40923 + if (usage == BBOU_UNKNOWN || usage == BBOU_NOP) {
40924 + /* nothing to do */
40925 + } else if (usage >= BBOU_RS && usage <= BBOU_RSRDWSWD) {
40926 + if (usage & BBOU_RS)
40927 + bb_read_operand(src);
40928 + if (usage & BBOU_RD)
40929 + bb_read_operand(dst);
40930 + if (usage & BBOU_WS)
40931 + bb_write_operand(src);
40932 + if (usage & BBOU_WD)
40933 + bb_write_operand(dst);
40935 + kdb_printf("%s: opcode not fully handled\n", __FUNCTION__);
40936 + if (!KDB_DEBUG(BB)) {
40937 + bb_print_opcode();
40938 + if (bb_decode.src.present)
40939 + bb_print_operand("src", &bb_decode.src);
40940 + if (bb_decode.dst.present)
40941 + bb_print_operand("dst", &bb_decode.dst);
40942 + if (bb_decode.dst2.present)
40943 + bb_print_operand("dst2", &bb_decode.dst2);
40950 +bb_parse_buffer(void)
40952 + char *p, *src, *dst = NULL, *dst2 = NULL;
40955 + memset(&bb_decode, 0, sizeof(bb_decode));
40956 + KDB_DEBUG_BB(" '%s'\n", p);
40957 + p += strcspn(p, ":"); /* skip address and function name+offset: */
40958 + if (*p++ != ':') {
40959 + kdb_printf("%s: cannot find ':' in buffer '%s'\n",
40960 + __FUNCTION__, bb_buffer);
40964 + p += strspn(p, " \t"); /* step to opcode */
40965 + if (strncmp(p, "(bad)", 5) == 0)
40966 + strcpy(p, "nop");
40967 + /* separate any opcode prefix */
40968 + if (strncmp(p, "lock", 4) == 0 ||
40969 + strncmp(p, "rep", 3) == 0 ||
40970 + strncmp(p, "rex", 3) == 0 ||
40971 + strncmp(p, "addr", 4) == 0) {
40972 + bb_decode.prefix = p;
40973 + p += strcspn(p, " \t");
40975 + p += strspn(p, " \t");
40977 + bb_decode.opcode = p;
40978 + strsep(&p, " \t"); /* step to end of opcode */
40979 + if (bb_parse_opcode())
40982 + goto no_operands;
40983 + p += strspn(p, " \t"); /* step to operand(s) */
40985 + goto no_operands;
40987 + p = strsep(&p, " \t"); /* strip comments after operands */
40988 + /* split 'src','dst' but ignore ',' inside '(' ')' */
40992 + } else if (*p == ')') {
40994 + } else if (*p == ',' && paren == 0) {
41003 + bb_parse_operand(src, &bb_decode.src);
41004 + if (KDB_DEBUG(BB))
41005 + bb_print_operand("src", &bb_decode.src);
41006 + if (dst && !bb_giveup) {
41007 + bb_parse_operand(dst, &bb_decode.dst);
41008 + if (KDB_DEBUG(BB))
41009 + bb_print_operand("dst", &bb_decode.dst);
41011 + if (dst2 && !bb_giveup) {
41012 + bb_parse_operand(dst2, &bb_decode.dst2);
41013 + if (KDB_DEBUG(BB))
41014 + bb_print_operand("dst2", &bb_decode.dst2);
41022 +bb_dis_pass2(PTR file, const char *fmt, ...)
41025 + int l = strlen(bb_buffer);
41027 + va_start(ap, fmt);
41028 + vsnprintf(bb_buffer + l, sizeof(bb_buffer) - l, fmt, ap);
41030 + if ((p = strchr(bb_buffer, '\n'))) {
41033 + p += strcspn(p, ":");
41035 + bb_fixup_switch_to(p);
41036 + bb_parse_buffer();
41037 + bb_buffer[0] = '\0';
41043 +bb_printaddr_pass2(bfd_vma addr, disassemble_info *dip)
41045 + kdb_symtab_t symtab;
41046 + unsigned int offset;
41047 + dip->fprintf_func(dip->stream, "0x%lx", addr);
41048 + kdbnearsym(addr, &symtab);
41049 + if (symtab.sym_name) {
41050 + dip->fprintf_func(dip->stream, " <%s", symtab.sym_name);
41051 + if ((offset = addr - symtab.sym_start))
41052 + dip->fprintf_func(dip->stream, "+0x%x", offset);
41053 + dip->fprintf_func(dip->stream, ">");
41057 +/* Set the starting register and memory state for the current bb */
41060 +bb_start_block0_special(void)
41063 + short offset_address;
41064 + enum bb_reg_code reg, value;
41065 + struct bb_name_state *r;
41066 + for (i = 0, r = bb_special_cases;
41067 + i < ARRAY_SIZE(bb_special_cases);
41069 + if (bb_func_start == r->address && r->fname == NULL)
41074 + /* Set the running registers */
41075 + for (reg = BBRG_RAX; reg < r->regs_size; ++reg) {
41076 + value = r->regs[reg].value;
41077 + if (test_bit(value, r->skip_regs.bits)) {
41078 + /* this regs entry is not defined for this label */
41081 + bb_reg_code_set_value(reg, value);
41082 + bb_reg_code_set_offset(reg, r->regs[reg].offset);
41084 + /* Set any memory contents, e.g. pt_regs. Adjust RSP as required. */
41085 + offset_address = 0;
41086 + for (i = 0; i < r->mem_size; ++i) {
41087 + offset_address = max_t(int,
41088 + r->mem[i].offset_address + KDB_WORD_SIZE,
41091 + if (bb_reg_code_offset(BBRG_RSP) > -offset_address)
41092 + bb_adjust_osp(BBRG_RSP, -offset_address - bb_reg_code_offset(BBRG_RSP));
41093 + for (i = 0; i < r->mem_size; ++i) {
41094 + value = r->mem[i].value;
41095 + if (test_bit(value, r->skip_mem.bits)) {
41096 + /* this memory entry is not defined for this label */
41099 + bb_memory_set_reg_value(BBRG_RSP, r->mem[i].offset_address,
41101 + bb_reg_set_undef(value);
41107 +bb_pass2_start_block(int number)
41109 + int i, j, k, first, changed;
41111 + struct bb_jmp *bb_jmp;
41112 + struct bb_reg_state *state;
41113 + struct bb_memory_contains *c1, *c2;
41114 + bb_reg_state->mem_count = bb_reg_state_max;
41115 + size = bb_reg_state_size(bb_reg_state);
41116 + memset(bb_reg_state, 0, size);
41118 + if (number == 0) {
41119 + /* The first block is assumed to have well defined inputs */
41120 + bb_start_block0();
41121 + /* Some assembler labels have non-standard entry
41124 + bb_start_block0_special();
41125 + bb_reg_state_print(bb_reg_state);
41129 + /* Merge all the input states for the current bb together */
41132 + for (i = 0; i < bb_jmp_count; ++i) {
41133 + bb_jmp = bb_jmp_list + i;
41134 + if (bb_jmp->to != bb_curr->start)
41136 + state = bb_jmp->state;
41140 + size = bb_reg_state_size(state);
41141 + memcpy(bb_reg_state, state, size);
41142 + KDB_DEBUG_BB(" first state %p\n", state);
41143 + bb_reg_state_print(bb_reg_state);
41148 + KDB_DEBUG_BB(" merging state %p\n", state);
41149 + /* Merge the register states */
41150 + for (j = 0; j < ARRAY_SIZE(state->contains); ++j) {
41151 + if (memcmp(bb_reg_state->contains + j,
41152 + state->contains + j,
41153 + sizeof(bb_reg_state->contains[0]))) {
41154 + /* Different states for this register from two
41155 + * or more inputs, make it undefined.
41157 + if (bb_reg_state->contains[j].value !=
41158 + BBRG_UNDEFINED) {
41159 + bb_reg_set_undef(BBRG_RAX + j);
41165 + /* Merge the memory states. This relies on both
41166 + * bb_reg_state->memory and state->memory being sorted in
41167 + * descending order, with undefined entries at the end.
41169 + c1 = bb_reg_state->memory;
41170 + c2 = state->memory;
41172 + while (j < bb_reg_state->mem_count &&
41173 + k < state->mem_count) {
41174 + if (c1->offset_address < c2->offset_address) {
41175 + KDB_DEBUG_BB_OFFSET(c2->offset_address,
41176 + " ignoring c2->offset_address ",
41182 + if (c1->offset_address > c2->offset_address) {
41183 + /* Memory location is not in all input states,
41184 + * delete the memory location.
41186 + bb_delete_memory(c1->offset_address);
41192 + if (memcmp(c1, c2, sizeof(*c1))) {
41193 + /* Same location, different contents, delete
41194 + * the memory location.
41196 + bb_delete_memory(c1->offset_address);
41197 + KDB_DEBUG_BB_OFFSET(c2->offset_address,
41198 + " ignoring c2->offset_address ",
41207 + while (j < bb_reg_state->mem_count) {
41208 + bb_delete_memory(c1->offset_address);
41215 + KDB_DEBUG_BB(" final state\n");
41216 + bb_reg_state_print(bb_reg_state);
41220 +/* We have reached the exit point from the current function, either a call to
41221 + * the next function or the instruction that was about to executed when an
41222 + * interrupt occurred. Save the current register state in bb_exit_state.
41226 +bb_save_exit_state(void)
41229 + debug_kfree(bb_exit_state);
41230 + bb_exit_state = NULL;
41231 + bb_reg_state_canonicalize();
41232 + size = bb_reg_state_size(bb_reg_state);
41233 + bb_exit_state = debug_kmalloc(size, GFP_ATOMIC);
41234 + if (!bb_exit_state) {
41235 + kdb_printf("\n\n%s: out of debug_kmalloc\n", __FUNCTION__);
41239 + memcpy(bb_exit_state, bb_reg_state, size);
41243 +bb_pass2_do_changed_blocks(int allow_missing)
41245 + int i, j, missing, changed, maxloops;
41246 + unsigned long addr;
41247 + struct bb_jmp *bb_jmp;
41248 + KDB_DEBUG_BB("\n %s: allow_missing %d\n", __FUNCTION__, allow_missing);
41249 + /* Absolute worst case is we have to iterate over all the basic blocks,
41250 + * each iteration losing one register or memory state. Any more loops
41251 + * than that is a bug.
41253 + maxloops = KDB_INT_REGISTERS + bb_reg_state_max;
41257 + for (i = 0; i < bb_count; ++i) {
41258 + bb_curr = bb_list[i];
41259 + if (!bb_curr->changed)
41262 + for (j = 0, bb_jmp = bb_jmp_list;
41263 + j < bb_jmp_count;
41265 + if (bb_jmp->to == bb_curr->start &&
41269 + if (missing > allow_missing)
41271 + bb_curr->changed = 0;
41273 + KDB_DEBUG_BB("\n bb[%d]\n", i);
41274 + bb_pass2_start_block(i);
41275 + for (addr = bb_curr->start;
41276 + addr <= bb_curr->end; ) {
41277 + bb_curr_addr = addr;
41278 + if (addr == bb_exit_addr)
41279 + bb_save_exit_state();
41280 + addr += kdba_id_printinsn(addr, &kdb_di);
41281 + kdb_di.fprintf_func(NULL, "\n");
41285 + if (addr == bb_exit_addr)
41286 + bb_save_exit_state();
41287 + if (bb_curr->drop_through)
41288 + bb_transfer(bb_curr->end,
41289 + bb_list[i+1]->start, 1);
41291 + if (maxloops-- == 0) {
41292 + kdb_printf("\n\n%s maxloops reached\n",
41297 + } while(changed);
41299 + for (i = 0; i < bb_count; ++i) {
41300 + bb_curr = bb_list[i];
41301 + if (bb_curr->changed)
41302 + return 1; /* more to do, increase allow_missing */
41304 + return 0; /* all blocks done */
41307 +/* Assume that the current function is a pass through function that does not
41308 + * refer to its register parameters. Exclude known asmlinkage functions and
41309 + * assume the other functions actually use their registers.
41313 +bb_assume_pass_through(void)
41315 + static int first_time = 1;
41316 + if (strncmp(bb_func_name, "sys_", 4) == 0 ||
41317 + strncmp(bb_func_name, "compat_sys_", 11) == 0 ||
41318 + strcmp(bb_func_name, "schedule") == 0 ||
41319 + strcmp(bb_func_name, "do_softirq") == 0 ||
41320 + strcmp(bb_func_name, "printk") == 0 ||
41321 + strcmp(bb_func_name, "vprintk") == 0 ||
41322 + strcmp(bb_func_name, "preempt_schedule") == 0 ||
41323 + strcmp(bb_func_name, "start_kernel") == 0 ||
41324 + strcmp(bb_func_name, "csum_partial") == 0 ||
41325 + strcmp(bb_func_name, "csum_partial_copy_generic") == 0 ||
41326 + strcmp(bb_func_name, "math_state_restore") == 0 ||
41327 + strcmp(bb_func_name, "panic") == 0 ||
41328 + strcmp(bb_func_name, "kdb_printf") == 0 ||
41329 + strcmp(bb_func_name, "kdb_interrupt") == 0)
41331 + if (bb_asmlinkage_arch())
41333 + bb_reg_params = REGPARM;
41334 + if (first_time) {
41335 + kdb_printf(" %s has memory parameters but no register "
41336 + "parameters.\n Assuming it is a 'pass "
41337 + "through' function that does not refer to "
41338 + "its register\n parameters and setting %d "
41339 + "register parameters\n",
41340 + bb_func_name, REGPARM);
41344 + kdb_printf(" Assuming %s is 'pass through' with %d register "
41346 + bb_func_name, REGPARM);
41352 + int allow_missing;
41353 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
41354 + kdb_printf("%s: start\n", __FUNCTION__);
41356 + kdb_di.fprintf_func = bb_dis_pass2;
41357 + kdb_di.print_address_func = bb_printaddr_pass2;
41359 + bb_reg_state = debug_kmalloc(sizeof(*bb_reg_state), GFP_ATOMIC);
41360 + if (!bb_reg_state) {
41361 + kdb_printf("\n\n%s: out of debug_kmalloc\n", __FUNCTION__);
41365 + bb_list[0]->changed = 1;
41367 + /* If a block does not have all its input states available then it is
41368 + * possible for a register to initially appear to hold a known value,
41369 + * but when other inputs are available then it becomes a variable
41370 + * value. The initial false state of "known" can generate false values
41371 + * for other registers and can even make it look like stack locations
41372 + * are being changed.
41374 + * To avoid these false positives, only process blocks which have all
41375 + * their inputs defined. That gives a clean depth first traversal of
41376 + * the tree, except for loops. If there are any loops, then start
41377 + * processing blocks with one missing input, then two missing inputs
41380 + * Absolute worst case is we have to iterate over all the jmp entries,
41381 + * each iteration allowing one more missing input. Any more loops than
41382 + * that is a bug. Watch out for the corner case of 0 jmp entries.
41384 + for (allow_missing = 0; allow_missing <= bb_jmp_count; ++allow_missing) {
41385 + if (!bb_pass2_do_changed_blocks(allow_missing))
41390 + if (allow_missing > bb_jmp_count) {
41391 + kdb_printf("\n\n%s maxloops reached\n",
41397 + if (bb_memory_params && bb_reg_params)
41398 + bb_reg_params = REGPARM;
41400 + bb_memory_params &&
41402 + bb_assume_pass_through();
41403 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM)) {
41404 + kdb_printf("%s: end bb_reg_params %d bb_memory_params %d\n",
41405 + __FUNCTION__, bb_reg_params, bb_memory_params);
41406 + if (bb_exit_state) {
41407 + kdb_printf("%s: bb_exit_state at " kdb_bfd_vma_fmt0 "\n",
41408 + __FUNCTION__, bb_exit_addr);
41409 + bb_do_reg_state_print(bb_exit_state);
41419 + struct bb_reg_state *state;
41420 + while (bb_count) {
41424 + debug_kfree(bb_list);
41426 + bb_count = bb_max = 0;
41427 + for (i = 0; i < bb_jmp_count; ++i) {
41428 + state = bb_jmp_list[i].state;
41429 + if (state && --state->ref_count == 0)
41430 + debug_kfree(state);
41432 + debug_kfree(bb_jmp_list);
41433 + bb_jmp_list = NULL;
41434 + bb_jmp_count = bb_jmp_max = 0;
41435 + debug_kfree(bb_reg_state);
41436 + bb_reg_state = NULL;
41437 + bb_reg_state_max = 0;
41438 + debug_kfree(bb_exit_state);
41439 + bb_exit_state = NULL;
41440 + bb_reg_params = bb_memory_params = 0;
41445 +bb_spurious_global_label(const char *func_name)
41448 + for (i = 0; i < ARRAY_SIZE(bb_spurious); ++i) {
41449 + if (strcmp(bb_spurious[i], func_name) == 0)
41455 +/* Given the current actual register contents plus the exit state deduced from
41456 + * a basic block analysis of the current function, rollback the actual register
41457 + * contents to the values they had on entry to this function.
41461 +bb_actual_rollback(const struct kdb_activation_record *ar)
41463 + int i, offset_address;
41464 + struct bb_memory_contains *c;
41465 + enum bb_reg_code reg;
41466 + unsigned long address, new_rsp = 0;
41467 + struct bb_actual new[ARRAY_SIZE(bb_actual)];
41470 + if (!bb_exit_state) {
41471 + kdb_printf("%s: no bb_exit_state, cannot rollback\n",
41476 + memcpy(bb_reg_state, bb_exit_state, bb_reg_state_size(bb_exit_state));
41477 + memset(new, 0, sizeof(new));
41479 + /* The most important register for obtaining saved state is rsp so get
41480 + * its new value first. Prefer rsp if it is valid, then other
41481 + * registers. Saved values of rsp in memory are unusable without a
41482 + * register that points to memory.
41484 + if (!bb_actual_valid(BBRG_RSP)) {
41485 + kdb_printf("%s: no starting value for RSP, cannot rollback\n",
41490 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
41491 + kdb_printf("%s: rsp " kdb_bfd_vma_fmt0,
41492 + __FUNCTION__, bb_actual_value(BBRG_RSP));
41494 + if (!bb_is_osp_defined(i)) {
41495 + for (i = BBRG_RAX; i < BBRG_RAX + KDB_INT_REGISTERS; ++i) {
41496 + if (bb_is_osp_defined(i) && bb_actual_valid(i))
41500 + if (bb_is_osp_defined(i) && bb_actual_valid(i)) {
41501 + new_rsp = new[BBRG_RSP - BBRG_RAX].value =
41502 + bb_actual_value(i) - bb_reg_code_offset(i);
41503 + new[BBRG_RSP - BBRG_RAX].valid = 1;
41504 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
41505 + kdb_printf(" -> " kdb_bfd_vma_fmt0 "\n", new_rsp);
41507 + bb_actual_set_valid(BBRG_RSP, 0);
41508 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
41509 + kdb_printf(" -> undefined\n");
41510 + kdb_printf("%s: no ending value for RSP, cannot rollback\n",
41516 + /* Now the other registers. First look at register values that have
41517 + * been copied to other registers.
41519 + for (i = BBRG_RAX; i < BBRG_RAX + KDB_INT_REGISTERS; ++i) {
41520 + reg = bb_reg_code_value(i);
41521 + if (bb_is_int_reg(reg)) {
41522 + new[reg - BBRG_RAX] = bb_actual[i - BBRG_RAX];
41523 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
41524 + kdb_printf("%s: %s is in %s, "
41525 + kdb_bfd_vma_fmt0 "\n",
41529 + bb_actual_value(reg));
41533 + /* Finally register values that have been saved on stack */
41534 + for (i = 0, c = bb_reg_state->memory;
41535 + i < bb_reg_state->mem_count;
41537 + offset_address = c->offset_address;
41539 + if (!bb_is_int_reg(reg))
41541 + address = new_rsp + offset_address;
41542 + if (address < ar->stack.logical_start ||
41543 + address >= ar->stack.logical_end) {
41544 + new[reg - BBRG_RAX].value = 0;
41545 + new[reg - BBRG_RAX].valid = 0;
41546 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
41547 + kdb_printf("%s: %s -> undefined\n",
41551 + new[reg - BBRG_RAX].value = *(bfd_vma *)address;
41552 + new[reg - BBRG_RAX].valid = 1;
41553 + if (KDB_DEBUG(BB) | KDB_DEBUG(BB_SUMM))
41554 + kdb_printf("%s: %s -> " kdb_bfd_vma_fmt0 "\n",
41557 + new[reg - BBRG_RAX].value);
41561 + memcpy(bb_actual, new, sizeof(bb_actual));
41564 +/* Return the number of bytes pushed on stack by the hardware. Either 0 or the
41565 + * size of the hardware specific data.
41570 +bb_hardware_pushed(kdb_machreg_t rip)
41572 + unsigned long disp8, disp32, target, addr = (unsigned long)rip;
41573 + unsigned char code[5];
41576 + for (i = 0; i < ARRAY_SIZE(bb_hardware_handlers); ++i)
41577 + if (strcmp(bb_func_name, bb_hardware_handlers[i]) == 0)
41578 + return HARDWARE_PUSHED;
41580 + /* Given the large number of interrupt handlers, it is easiest to look
41581 + * at the next instruction and see if it is a jmp to the common exit
41584 + if (kdb_getarea(code, addr) ||
41585 + kdb_getword(&disp32, addr+1, 4) ||
41586 + kdb_getword(&disp8, addr+1, 1))
41587 + return 0; /* not a valid code address */
41588 + if (code[0] == 0xe9) {
41589 + target = addr + (s32) disp32 + 5; /* jmp disp32 */
41590 + if (target == bb_ret_from_intr ||
41591 + target == bb_common_interrupt ||
41592 + target == bb_error_entry)
41593 + return HARDWARE_PUSHED;
41595 + if (code[0] == 0xeb) {
41596 + target = addr + (s8) disp8 + 2; /* jmp disp8 */
41597 + if (target == bb_ret_from_intr ||
41598 + target == bb_common_interrupt ||
41599 + target == bb_error_entry)
41600 + return HARDWARE_PUSHED;
41602 + if (strcmp(bb_func_name, "kdb_call") == 0)
41603 + return HARDWARE_PUSHED;
41608 +/* Copy argument information that was deduced by the basic block analysis and
41609 + * rollback into the kdb stack activation record.
41613 +bb_arguments(struct kdb_activation_record *ar)
41616 + enum bb_reg_code reg;
41617 + kdb_machreg_t rsp;
41618 + ar->args = bb_reg_params + bb_memory_params;
41619 + bitmap_zero(ar->valid.bits, KDBA_MAXARGS);
41620 + for (i = 0; i < bb_reg_params; ++i) {
41621 + reg = bb_param_reg[i];
41622 + if (bb_actual_valid(reg)) {
41623 + ar->arg[i] = bb_actual_value(reg);
41624 + set_bit(i, ar->valid.bits);
41627 + if (!bb_actual_valid(BBRG_RSP))
41629 + rsp = bb_actual_value(BBRG_RSP);
41630 + for (i = bb_reg_params; i < ar->args; ++i) {
41631 + rsp += KDB_WORD_SIZE;
41632 + if (kdb_getarea(ar->arg[i], rsp) == 0)
41633 + set_bit(i, ar->valid.bits);
41637 +/* Given an exit address from a function, decompose the entire function into
41638 + * basic blocks and determine the register state at the exit point.
41642 +kdb_bb(unsigned long exit)
41644 + kdb_symtab_t symtab;
41645 + if (!kdbnearsym(exit, &symtab)) {
41646 + kdb_printf("%s: address " kdb_bfd_vma_fmt0 " not recognised\n",
41647 + __FUNCTION__, exit);
41651 + bb_exit_addr = exit;
41652 + bb_mod_name = symtab.mod_name;
41653 + bb_func_name = symtab.sym_name;
41654 + bb_func_start = symtab.sym_start;
41655 + bb_func_end = symtab.sym_end;
41656 + /* Various global labels exist in the middle of assembler code and have
41657 + * a non-standard state. Ignore these labels and use the start of the
41658 + * previous label instead.
41660 + while (bb_spurious_global_label(symtab.sym_name)) {
41661 + if (!kdbnearsym(symtab.sym_start - 1, &symtab))
41663 + bb_func_start = symtab.sym_start;
41665 + bb_mod_name = symtab.mod_name;
41666 + bb_func_name = symtab.sym_name;
41667 + bb_func_start = symtab.sym_start;
41668 + /* Ignore spurious labels past this point and use the next non-spurious
41669 + * label as the end point.
41671 + if (kdbnearsym(bb_func_end, &symtab)) {
41672 + while (bb_spurious_global_label(symtab.sym_name)) {
41673 + bb_func_end = symtab.sym_end;
41674 + if (!kdbnearsym(symtab.sym_end + 1, &symtab))
41682 + kdb_printf("%s: " kdb_bfd_vma_fmt0
41683 + " [%s]%s failed at " kdb_bfd_vma_fmt0 "\n\n",
41684 + __FUNCTION__, exit,
41685 + bb_mod_name, bb_func_name, bb_curr_addr);
41689 +kdb_bb1(int argc, const char **argv)
41692 + unsigned long addr;
41693 + bb_cleanup(); /* in case previous command was interrupted */
41694 + kdba_id_init(&kdb_di);
41696 + return KDB_ARGCOUNT;
41697 + if ((diag = kdbgetularg((char *)argv[1], &addr)))
41699 + kdb_save_flags();
41700 + kdb_flags |= KDB_DEBUG_FLAG_BB << KDB_DEBUG_FLAG_SHIFT;
41703 + kdb_restore_flags();
41704 + kdbnearsym_cleanup();
41708 +/* Run a basic block analysis on every function in the base kernel. Used as a
41709 + * global sanity check to find errors in the basic block code.
41713 +kdb_bb_all(int argc, const char **argv)
41716 + const char *symname;
41717 + unsigned long addr;
41718 + int i, max_errors = 20;
41719 + struct bb_name_state *r;
41720 + kdb_printf("%s: conditional build variables:"
41721 +#ifdef CONFIG_X86_64
41724 +#ifdef CONFIG_4KSTACKS
41725 + " CONFIG_4KSTACKS"
41727 +#ifdef CONFIG_PREEMPT
41728 + " CONFIG_PREEMPT"
41730 +#ifdef CONFIG_VM86
41733 +#ifdef CONFIG_FRAME_POINTER
41734 + " CONFIG_FRAME_POINTER"
41736 +#ifdef CONFIG_TRACE_IRQFLAGS
41737 + " CONFIG_TRACE_IRQFLAGS"
41739 +#ifdef NO_SIBLINGS
41742 + " REGPARM=" __stringify(REGPARM)
41743 + "\n\n", __FUNCTION__);
41744 + for (i = 0, r = bb_special_cases;
41745 + i < ARRAY_SIZE(bb_special_cases);
41748 + kdb_printf("%s: cannot find special_case name %s\n",
41749 + __FUNCTION__, r->name);
41751 + for (i = 0; i < ARRAY_SIZE(bb_spurious); ++i) {
41752 + if (!kallsyms_lookup_name(bb_spurious[i]))
41753 + kdb_printf("%s: cannot find spurious label %s\n",
41754 + __FUNCTION__, bb_spurious[i]);
41756 + while ((symname = kdb_walk_kallsyms(&pos))) {
41758 + if (strcmp(symname, "_stext") == 0 ||
41759 + strcmp(symname, "stext") == 0)
41763 + kdb_printf("%s: cannot find _stext\n", __FUNCTION__);
41766 + kdba_id_init(&kdb_di);
41768 + while ((symname = kdb_walk_kallsyms(&pos))) {
41769 + if (strcmp(symname, "_etext") == 0)
41771 + if (i++ % 100 == 0)
41773 + /* x86_64 has some 16 bit functions that appear between stext
41774 + * and _etext. Skip them.
41776 + if (strcmp(symname, "verify_cpu") == 0 ||
41777 + strcmp(symname, "verify_cpu_noamd") == 0 ||
41778 + strcmp(symname, "verify_cpu_sse_test") == 0 ||
41779 + strcmp(symname, "verify_cpu_no_longmode") == 0 ||
41780 + strcmp(symname, "verify_cpu_sse_ok") == 0 ||
41781 + strcmp(symname, "mode_seta") == 0 ||
41782 + strcmp(symname, "bad_address") == 0 ||
41783 + strcmp(symname, "wakeup_code") == 0 ||
41784 + strcmp(symname, "wakeup_code_start") == 0 ||
41785 + strcmp(symname, "wakeup_start") == 0 ||
41786 + strcmp(symname, "wakeup_32_vector") == 0 ||
41787 + strcmp(symname, "wakeup_32") == 0 ||
41788 + strcmp(symname, "wakeup_long64_vector") == 0 ||
41789 + strcmp(symname, "wakeup_long64") == 0 ||
41790 + strcmp(symname, "gdta") == 0 ||
41791 + strcmp(symname, "idt_48a") == 0 ||
41792 + strcmp(symname, "gdt_48a") == 0 ||
41793 + strcmp(symname, "bogus_real_magic") == 0 ||
41794 + strcmp(symname, "bogus_64_magic") == 0 ||
41795 + strcmp(symname, "no_longmode") == 0 ||
41796 + strcmp(symname, "mode_seta") == 0 ||
41797 + strcmp(symname, "setbada") == 0 ||
41798 + strcmp(symname, "check_vesaa") == 0 ||
41799 + strcmp(symname, "_setbada") == 0 ||
41800 + strcmp(symname, "wakeup_stack_begin") == 0 ||
41801 + strcmp(symname, "wakeup_stack") == 0 ||
41802 + strcmp(symname, "wakeup_level4_pgt") == 0 ||
41803 + strcmp(symname, "acpi_copy_wakeup_routine") == 0 ||
41804 + strcmp(symname, "wakeup_end") == 0 ||
41805 + strcmp(symname, "do_suspend_lowlevel_s4bios") == 0 ||
41806 + strcmp(symname, "do_suspend_lowlevel") == 0)
41808 + /* __kprobes_text_end contains branches to the middle of code,
41809 + * with undefined states.
41811 + if (strcmp(symname, "__kprobes_text_end") == 0)
41813 + if (bb_spurious_global_label(symname))
41815 + if ((addr = kallsyms_lookup_name(symname)) == 0)
41817 + // kdb_printf("BB " kdb_bfd_vma_fmt0 " %s\n", addr, symname);
41818 + bb_cleanup(); /* in case previous command was interrupted */
41819 + kdbnearsym_cleanup();
41821 + touch_nmi_watchdog();
41823 + if (max_errors-- == 0) {
41824 + kdb_printf("%s: max_errors reached, giving up\n",
41832 + kdb_printf("\n");
41834 + kdbnearsym_cleanup();
41839 + *=============================================================================
41841 + * Everything above this line is doing basic block analysis, function by
41842 + * function. Everything below this line uses the basic block data to do a
41843 + * complete backtrace over all functions that are used by a process.
41845 + *=============================================================================
41849 +/*============================================================================*/
41851 +/* Most of the backtrace code and data is common to x86_64 and i386. This */
41852 +/* large ifdef contains all of the differences between the two architectures. */
41854 +/* Make sure you update the correct section of this ifdef. */
41856 +/*============================================================================*/
41858 +#ifdef CONFIG_X86_64
41863 +#define ARCH_RSP rsp
41864 +#define ARCH_RIP rip
41865 +#define ARCH_NORMAL_PADDING (16 * 8)
41867 +/* x86_64 has multiple alternate stacks, with different sizes and different
41868 + * offsets to get the link from one stack to the next. Some of the stacks are
41869 + * referenced via cpu_pda, some via per_cpu orig_ist. Debug events can even
41870 + * have multiple nested stacks within the single physical stack, each nested
41871 + * stack has its own link and some of those links are wrong.
41873 + * Consistent it's not!
41875 + * Do not assume that these stacks are aligned on their size.
41877 +#define INTERRUPT_STACK (N_EXCEPTION_STACKS + 1)
41879 +kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
41880 + struct kdb_activation_record *ar)
41884 + unsigned int total_size;
41885 + unsigned int nested_size;
41886 + unsigned int next;
41887 + } *sdp, stack_data[] = {
41888 + [STACKFAULT_STACK - 1] = { "stackfault", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
41889 + [DOUBLEFAULT_STACK - 1] = { "doublefault", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
41890 + [NMI_STACK - 1] = { "nmi", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
41891 + [DEBUG_STACK - 1] = { "debug", DEBUG_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
41892 + [MCE_STACK - 1] = { "machine check", EXCEPTION_STKSZ, EXCEPTION_STKSZ, EXCEPTION_STKSZ - 2*sizeof(void *) },
41893 + [INTERRUPT_STACK - 1] = { "interrupt", IRQSTACKSIZE, IRQSTACKSIZE, IRQSTACKSIZE - sizeof(void *) },
41895 + unsigned long total_start = 0, total_size, total_end;
41896 + int sd, found = 0;
41897 + extern unsigned long kdba_orig_ist(int, int);
41899 + for (sd = 0, sdp = stack_data;
41900 + sd < ARRAY_SIZE(stack_data);
41902 + total_size = sdp->total_size;
41904 + continue; /* in case stack_data[] has any holes */
41906 + /* Arbitrary address which can be on any cpu, see if it
41907 + * falls within any of the alternate stacks
41910 + for_each_online_cpu(c) {
41911 + if (sd == INTERRUPT_STACK - 1)
41912 + total_end = (unsigned long)cpu_pda(c)->irqstackptr;
41914 + total_end = per_cpu(orig_ist, c).ist[sd];
41915 + total_start = total_end - total_size;
41916 + if (addr >= total_start && addr < total_end) {
41925 + /* Only check the supplied or found cpu */
41926 + if (sd == INTERRUPT_STACK - 1)
41927 + total_end = (unsigned long)cpu_pda(cpu)->irqstackptr;
41929 + total_end = per_cpu(orig_ist, cpu).ist[sd];
41930 + total_start = total_end - total_size;
41931 + if (addr >= total_start && addr < total_end) {
41938 + /* find which nested stack the address is in */
41939 + while (addr > total_start + sdp->nested_size)
41940 + total_start += sdp->nested_size;
41941 + ar->stack.physical_start = total_start;
41942 + ar->stack.physical_end = total_start + sdp->nested_size;
41943 + ar->stack.logical_start = total_start;
41944 + ar->stack.logical_end = total_start + sdp->next;
41945 + ar->stack.next = *(unsigned long *)ar->stack.logical_end;
41946 + ar->stack.id = sdp->id;
41948 + /* Nasty: when switching to the interrupt stack, the stack state of the
41949 + * caller is split over two stacks, the original stack and the
41950 + * interrupt stack. One word (the previous frame pointer) is stored on
41951 + * the interrupt stack, the rest of the interrupt data is in the old
41952 + * frame. To make the interrupted stack state look as though it is
41953 + * contiguous, copy the missing word from the interrupt stack to the
41954 + * original stack and adjust the new stack pointer accordingly.
41957 + if (sd == INTERRUPT_STACK - 1) {
41958 + *(unsigned long *)(ar->stack.next - KDB_WORD_SIZE) =
41960 + ar->stack.next -= KDB_WORD_SIZE;
41964 +/* rip is not in the thread struct for x86_64. We know that the stack value
41965 + * was saved in schedule near the label thread_return. Setting rip to
41966 + * thread_return lets the stack trace find that we are in schedule and
41967 + * correctly decode its prologue.
41970 +static kdb_machreg_t
41971 +kdba_bt_stack_rip(const struct task_struct *p)
41973 + return bb_thread_return;
41976 +#else /* !CONFIG_X86_64 */
41981 +#define ARCH_RSP esp
41982 +#define ARCH_RIP eip
41983 +#define ARCH_NORMAL_PADDING (19 * 4)
41985 +#ifdef CONFIG_4KSTACKS
41986 +static struct thread_info **kdba_hardirq_ctx, **kdba_softirq_ctx;
41987 +#endif /* CONFIG_4KSTACKS */
41989 +/* On a 4K stack kernel, hardirq_ctx and softirq_ctx are [NR_CPUS] arrays. The
41990 + * first element of each per-cpu stack is a struct thread_info.
41993 +kdba_get_stack_info_alternate(kdb_machreg_t addr, int cpu,
41994 + struct kdb_activation_record *ar)
41996 +#ifdef CONFIG_4KSTACKS
41997 + struct thread_info *tinfo;
41998 + tinfo = (struct thread_info *)(addr & -THREAD_SIZE);
42000 + /* Arbitrary address, see if it falls within any of the irq
42004 + for_each_online_cpu(cpu) {
42005 + if (tinfo == kdba_hardirq_ctx[cpu] ||
42006 + tinfo == kdba_softirq_ctx[cpu]) {
42014 + if (tinfo == kdba_hardirq_ctx[cpu] ||
42015 + tinfo == kdba_softirq_ctx[cpu]) {
42016 + ar->stack.physical_start = (kdb_machreg_t)tinfo;
42017 + ar->stack.physical_end = ar->stack.physical_start + THREAD_SIZE;
42018 + ar->stack.logical_start = ar->stack.physical_start +
42019 + sizeof(struct thread_info);
42020 + ar->stack.logical_end = ar->stack.physical_end;
42021 + ar->stack.next = tinfo->previous_esp;
42022 + if (tinfo == kdba_hardirq_ctx[cpu])
42023 + ar->stack.id = "hardirq_ctx";
42025 + ar->stack.id = "softirq_ctx";
42027 +#endif /* CONFIG_4KSTACKS */
42030 +/* rip is in the thread struct for i386 */
42032 +static kdb_machreg_t
42033 +kdba_bt_stack_rip(const struct task_struct *p)
42035 + return p->thread.eip;
42038 +#endif /* CONFIG_X86_64 */
42040 +/* Given an address which claims to be on a stack, an optional cpu number and
42041 + * an optional task address, get information about the stack.
42043 + * t == NULL, cpu < 0 indicates an arbitrary stack address with no associated
42044 + * struct task, the address can be in an alternate stack or any task's normal
42047 + * t != NULL, cpu >= 0 indicates a running task, the address can be in an
42048 + * alternate stack or that task's normal stack.
42050 + * t != NULL, cpu < 0 indicates a blocked task, the address can only be in that
42051 + * task's normal stack.
42053 + * t == NULL, cpu >= 0 is not a valid combination.
42057 +kdba_get_stack_info(kdb_machreg_t rsp, int cpu,
42058 + struct kdb_activation_record *ar,
42059 + const struct task_struct *t)
42061 + struct thread_info *tinfo;
42062 + struct task_struct *g, *p;
42063 + memset(&ar->stack, 0, sizeof(ar->stack));
42064 + if (KDB_DEBUG(ARA))
42065 + kdb_printf("%s: " RSP "=0x%lx cpu=%d task=%p\n",
42066 + __FUNCTION__, rsp, cpu, t);
42067 + if (t == NULL || cpu >= 0) {
42068 + kdba_get_stack_info_alternate(rsp, cpu, ar);
42069 + if (ar->stack.logical_start)
42072 + rsp &= -THREAD_SIZE;
42073 + tinfo = (struct thread_info *)rsp;
42075 + /* Arbitrary stack address without an associated task, see if
42076 + * it falls within any normal process stack, including the idle
42079 + kdb_do_each_thread(g, p) {
42080 + if (tinfo == task_thread_info(p)) {
42084 + } kdb_while_each_thread(g, p);
42085 + for_each_online_cpu(cpu) {
42086 + p = idle_task(cpu);
42087 + if (tinfo == task_thread_info(p)) {
42093 + if (KDB_DEBUG(ARA))
42094 + kdb_printf("%s: found task %p\n", __FUNCTION__, t);
42095 + } else if (cpu >= 0) {
42096 + /* running task */
42097 + struct kdb_running_process *krp = kdb_running_process + cpu;
42098 + if (krp->p != t || tinfo != task_thread_info(t))
42100 + if (KDB_DEBUG(ARA))
42101 + kdb_printf("%s: running task %p\n", __FUNCTION__, t);
42103 + /* blocked task */
42104 + if (tinfo != task_thread_info(t))
42106 + if (KDB_DEBUG(ARA))
42107 + kdb_printf("%s: blocked task %p\n", __FUNCTION__, t);
42110 + ar->stack.physical_start = rsp;
42111 + ar->stack.physical_end = rsp + THREAD_SIZE;
42112 + ar->stack.logical_start = rsp + sizeof(struct thread_info);
42113 + ar->stack.logical_end = ar->stack.physical_end - ARCH_NORMAL_PADDING;
42114 + ar->stack.next = 0;
42115 + ar->stack.id = "normal";
42118 + if (ar->stack.physical_start && KDB_DEBUG(ARA)) {
42119 + kdb_printf("%s: ar->stack\n", __FUNCTION__);
42120 + kdb_printf(" physical_start=0x%lx\n", ar->stack.physical_start);
42121 + kdb_printf(" physical_end=0x%lx\n", ar->stack.physical_end);
42122 + kdb_printf(" logical_start=0x%lx\n", ar->stack.logical_start);
42123 + kdb_printf(" logical_end=0x%lx\n", ar->stack.logical_end);
42124 + kdb_printf(" next=0x%lx\n", ar->stack.next);
42125 + kdb_printf(" id=%s\n", ar->stack.id);
42126 + kdb_printf(" set MDCOUNT %ld\n",
42127 + (ar->stack.physical_end - ar->stack.physical_start) /
42129 + kdb_printf(" mds " kdb_machreg_fmt0 "\n",
42130 + ar->stack.physical_start);
42135 +bt_print_one(kdb_machreg_t rip, kdb_machreg_t rsp,
42136 + const struct kdb_activation_record *ar,
42137 + const kdb_symtab_t *symtab, int argcount)
42139 + int btsymarg = 0;
42142 + kdbgetintenv("BTSYMARG", &btsymarg);
42143 + kdbgetintenv("NOSECT", &nosect);
42145 + kdb_printf(kdb_machreg_fmt0, rsp);
42146 + kdb_symbol_print(rip, symtab,
42147 + KDB_SP_SPACEB|KDB_SP_VALUE);
42148 + if (argcount && ar->args) {
42149 + int i, argc = ar->args;
42150 + kdb_printf(" (");
42151 + if (argc > argcount)
42153 + for (i = 0; i < argc; i++) {
42155 + kdb_printf(", ");
42156 + if (test_bit(i, ar->valid.bits))
42157 + kdb_printf("0x%lx", ar->arg[i]);
42159 + kdb_printf("invalid");
42163 + kdb_printf("\n");
42164 + if (symtab->sym_name) {
42166 + kdb_printf(" %s",
42167 + symtab->mod_name);
42168 + if (symtab->sec_name && symtab->sec_start)
42169 + kdb_printf(" 0x%lx 0x%lx",
42170 + symtab->sec_start, symtab->sec_end);
42171 + kdb_printf(" 0x%lx 0x%lx\n",
42172 + symtab->sym_start, symtab->sym_end);
42175 + if (argcount && ar->args && btsymarg) {
42176 + int i, argc = ar->args;
42177 + kdb_symtab_t arg_symtab;
42178 + for (i = 0; i < argc; i++) {
42179 + kdb_machreg_t arg = ar->arg[i];
42180 + if (test_bit(i, ar->valid.bits) &&
42181 + kdbnearsym(arg, &arg_symtab)) {
42182 + kdb_printf(" ARG %2d ", i);
42183 + kdb_symbol_print(arg, &arg_symtab,
42184 + KDB_SP_DEFAULT|KDB_SP_NEWLINE);
42191 +kdba_bt_new_stack(struct kdb_activation_record *ar, kdb_machreg_t *rsp,
42192 + int *count, int *suppress)
42194 + /* Nasty: common_interrupt builds a partial pt_regs, with r15 through
42195 + * rbx not being filled in. It passes struct pt_regs* to do_IRQ (in
42196 + * rdi) but the stack pointer is not adjusted to account for r15
42197 + * through rbx. This has two effects :-
42199 + * (1) struct pt_regs on an external interrupt actually overlaps with
42200 + * the local stack area used by do_IRQ. Not only are r15-rbx
42201 + * undefined, the area that claims to hold their values can even
42202 + * change as the irq is processed.
42204 + * (2) The back stack pointer saved for the new frame is not pointing
42205 + * at pt_regs, it is pointing at rbx within the pt_regs passed to
42208 + * There is nothing that I can do about (1) but I have to fix (2)
42209 + * because kdb backtrace looks for the "start" address of pt_regs as it
42210 + * walks back through the stacks. When switching from the interrupt
42211 + * stack to another stack, we have to assume that pt_regs has been
42212 + * seen and turn off backtrace supression.
42214 + int probable_pt_regs = strcmp(ar->stack.id, "interrupt") == 0;
42215 + *rsp = ar->stack.next;
42216 + if (KDB_DEBUG(ARA))
42217 + kdb_printf("new " RSP "=" kdb_machreg_fmt0 "\n", *rsp);
42218 + bb_actual_set_value(BBRG_RSP, *rsp);
42219 + kdba_get_stack_info(*rsp, -1, ar, NULL);
42220 + if (!ar->stack.physical_start) {
42221 + kdb_printf("+++ Cannot resolve next stack\n");
42222 + } else if (!*suppress) {
42223 + kdb_printf(" ======================= <%s>\n",
42227 + if (probable_pt_regs)
42235 + * addr Address provided to 'bt' command, if any.
42237 + * p Pointer to task for 'btp' command.
42241 + * zero for success, a kdb diagnostic if error
42245 + * Ultimately all the bt* commands come through this routine. If
42246 + * old_style is 0 then it uses the basic block analysis to get an accurate
42247 + * backtrace with arguments, otherwise it falls back to the old method of
42248 + * printing anything on stack that looks like a kernel address.
42252 +kdba_bt_stack(kdb_machreg_t addr, int argcount, const struct task_struct *p,
42255 + struct kdb_activation_record ar;
42256 + kdb_machreg_t rip = 0, rsp = 0, prev_rsp;
42257 + kdb_symtab_t symtab;
42258 + int rip_at_rsp = 0, count = 0, btsp = 0, suppress, hardware_pushed = 0;
42259 + struct pt_regs *regs = NULL;
42261 + kdbgetintenv("BTSP", &btsp);
42262 + suppress = !btsp;
42263 + memset(&ar, 0, sizeof(ar));
42265 + kdb_printf("Using old style backtrace, unreliable with no arguments\n");
42268 + * The caller may have supplied an address at which the stack traceback
42269 + * operation should begin. This address is assumed by this code to
42270 + * point to a return address on the stack to be traced back.
42272 + * Warning: type in the wrong address and you will get garbage in the
42277 + kdb_getword(&rip, rsp, sizeof(rip));
42280 + kdba_get_stack_info(rsp, -1, &ar, NULL);
42282 + if (task_curr(p)) {
42283 + struct kdb_running_process *krp =
42284 + kdb_running_process + task_cpu(p);
42285 + kdb_machreg_t cs;
42286 + regs = krp->regs;
42287 + if (krp->seqno &&
42289 + krp->seqno >= kdb_seqno - 1 &&
42290 + !KDB_NULL_REGS(regs)) {
42291 + /* valid saved state, continue processing */
42294 + ("Process did not save state, cannot backtrace\n");
42298 + kdba_getregcontents(XCS, regs, &cs);
42299 + if ((cs & 0xffff) != __KERNEL_CS) {
42300 + kdb_printf("Stack is not in kernel space, backtrace not available\n");
42303 + rip = krp->arch.ARCH_RIP;
42304 + rsp = krp->arch.ARCH_RSP;
42305 + kdba_get_stack_info(rsp, kdb_process_cpu(p), &ar, p);
42307 + /* Not on cpu, assume blocked. Blocked tasks do not
42308 + * have pt_regs. p->thread contains some data, alas
42309 + * what it contains differs between i386 and x86_64.
42311 + rip = kdba_bt_stack_rip(p);
42312 + rsp = p->thread.ARCH_RSP;
42314 + kdba_get_stack_info(rsp, -1, &ar, p);
42317 + if (!ar.stack.physical_start) {
42318 + kdb_printf(RSP "=0x%lx is not in a valid kernel stack, backtrace not available\n",
42322 + memset(&bb_actual, 0, sizeof(bb_actual));
42323 + bb_actual_set_value(BBRG_RSP, rsp);
42324 + bb_actual_set_valid(BBRG_RSP, 1);
42326 + kdb_printf(RSP "%*s" RIP "%*sFunction (args)\n",
42327 + 2*KDB_WORD_SIZE, " ",
42328 + 2*KDB_WORD_SIZE, " ");
42329 + if (ar.stack.next && !suppress)
42330 + kdb_printf(" ======================= <%s>\n",
42334 + /* Run through all the stacks */
42335 + while (ar.stack.physical_start) {
42337 + rip = *(kdb_machreg_t *)rsp;
42338 + kdbnearsym(rip, &symtab);
42340 + if (__kernel_text_address(rip) && !suppress) {
42341 + bt_print_one(rip, rsp, &ar, &symtab, 0);
42344 + if (rsp == (unsigned long)regs) {
42345 + if (ar.stack.next && suppress)
42346 + kdb_printf(" ======================= <%s>\n",
42351 + rsp += sizeof(rip);
42353 + if (rsp >= ar.stack.logical_end) {
42354 + if (!ar.stack.next)
42356 + kdba_bt_new_stack(&ar, &rsp, &count, &suppress);
42361 + /* Start each analysis with no dynamic data from the
42362 + * previous kdb_bb() run.
42369 + if (rip_at_rsp) {
42370 + rsp += sizeof(rip) + hardware_pushed;
42371 + hardware_pushed = 0;
42372 + if (rsp >= ar.stack.logical_end &&
42374 + kdba_bt_new_stack(&ar, &rsp, &count,
42379 + bb_actual_set_value(BBRG_RSP, rsp);
42382 + bb_actual_rollback(&ar);
42385 + if (bb_actual_value(BBRG_RSP) < rsp) {
42386 + kdb_printf("%s: " RSP " is going backwards, "
42387 + kdb_machreg_fmt0 " -> "
42388 + kdb_machreg_fmt0 "\n",
42391 + bb_actual_value(BBRG_RSP));
42395 + bb_arguments(&ar);
42397 + bt_print_one(rip, prev_rsp, &ar, &symtab, argcount);
42400 + /* Functions that terminate the backtrace */
42401 + if (strcmp(bb_func_name, "cpu_idle") == 0)
42403 + if (rsp >= ar.stack.logical_end &&
42406 + if (rsp <= (unsigned long)regs &&
42407 + bb_actual_value(BBRG_RSP) > (unsigned long)regs) {
42408 + if (ar.stack.next && suppress)
42409 + kdb_printf(" ======================= <%s>\n",
42414 + rsp = bb_actual_value(BBRG_RSP);
42415 + hardware_pushed = bb_hardware_pushed(rip);
42423 + kdbnearsym_cleanup();
42425 + if (count > 200) {
42426 + kdb_printf("bt truncated, count limit reached\n");
42428 + } else if (suppress) {
42430 + ("bt did not find pt_regs - no trace produced. Suggest 'set BTSP 1'\n");
42438 + * kdba_bt_address
42440 + * Do a backtrace starting at a specified stack address. Use this if the
42441 + * heuristics get the stack decode wrong.
42444 + * addr Address provided to 'bt' command.
42449 + * zero for success, a kdb diagnostic if error
42453 + * mds %rsp comes in handy when examining the stack to do a manual
42457 +int kdba_bt_address(kdb_machreg_t addr, int argcount)
42460 + kdba_id_init(&kdb_di); /* kdb_bb needs this done once */
42461 + ret = kdba_bt_stack(addr, argcount, NULL, 0);
42463 + ret = kdba_bt_stack(addr, argcount, NULL, 1);
42468 + * kdba_bt_process
42470 + * Do a backtrace for a specified process.
42473 + * p Struct task pointer extracted by 'bt' command.
42478 + * zero for success, a kdb diagnostic if error
42483 +int kdba_bt_process(const struct task_struct *p, int argcount)
42486 + kdba_id_init(&kdb_di); /* kdb_bb needs this done once */
42487 + ret = kdba_bt_stack(0, argcount, p, 0);
42489 + ret = kdba_bt_stack(0, argcount, p, 1);
42493 +static int __init kdba_bt_x86_init(void)
42495 + int i, c, cp = -1;
42496 + struct bb_name_state *r;
42498 + kdb_register_repeat("bb1", kdb_bb1, "<vaddr>", "Analyse one basic block", 0, KDB_REPEAT_NONE);
42499 + kdb_register_repeat("bb_all", kdb_bb_all, "", "Backtrace check on all built in functions", 0, KDB_REPEAT_NONE);
42501 + /* Split the opcode usage table by the first letter of each set of
42502 + * opcodes, for faster mapping of opcode to its operand usage.
42504 + for (i = 0; i < ARRAY_SIZE(bb_opcode_usage_all); ++i) {
42505 + c = bb_opcode_usage_all[i].opcode[0] - 'a';
42508 + bb_opcode_usage[c].opcode = bb_opcode_usage_all + i;
42510 + ++bb_opcode_usage[c].size;
42513 + bb_common_interrupt = kallsyms_lookup_name("common_interrupt");
42514 + bb_error_entry = kallsyms_lookup_name("error_entry");
42515 + bb_ret_from_intr = kallsyms_lookup_name("ret_from_intr");
42516 + bb_thread_return = kallsyms_lookup_name("thread_return");
42517 + bb_sync_regs = kallsyms_lookup_name("sync_regs");
42518 + bb_save_v86_state = kallsyms_lookup_name("save_v86_state");
42519 + bb__sched_text_start = kallsyms_lookup_name("__sched_text_start");
42520 + bb__sched_text_end = kallsyms_lookup_name("__sched_text_end");
42521 + for (i = 0, r = bb_special_cases;
42522 + i < ARRAY_SIZE(bb_special_cases);
42524 + r->address = kallsyms_lookup_name(r->name);
42527 +#ifdef CONFIG_4KSTACKS
42528 + kdba_hardirq_ctx = (struct thread_info **)kallsyms_lookup_name("hardirq_ctx");
42529 + kdba_softirq_ctx = (struct thread_info **)kallsyms_lookup_name("softirq_ctx");
42530 +#endif /* CONFIG_4KSTACKS */
42535 +static void __exit kdba_bt_x86_exit(void)
42537 + kdb_unregister("bb1");
42538 + kdb_unregister("bb_all");
42541 +module_init(kdba_bt_x86_init)
42542 +module_exit(kdba_bt_x86_exit)
42543 diff -Nurp linux-2.6.22-590/kdb/kdb_bp.c linux-2.6.22-600/kdb/kdb_bp.c
42544 --- linux-2.6.22-590/kdb/kdb_bp.c 1970-01-01 01:00:00.000000000 +0100
42545 +++ linux-2.6.22-600/kdb/kdb_bp.c 2008-04-09 18:14:28.000000000 +0200
42548 + * Kernel Debugger Architecture Independent Breakpoint Handler
42550 + * This file is subject to the terms and conditions of the GNU General Public
42551 + * License. See the file "COPYING" in the main directory of this archive
42552 + * for more details.
42554 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
42557 +#include <linux/string.h>
42558 +#include <linux/kernel.h>
42559 +#include <linux/init.h>
42560 +#include <linux/kdb.h>
42561 +#include <linux/kdbprivate.h>
42562 +#include <linux/smp.h>
42563 +#include <linux/sched.h>
42564 +#include <linux/interrupt.h>
42565 +#include <asm/system.h>
42568 + * Table of kdb_breakpoints
42570 +kdb_bp_t kdb_breakpoints[KDB_MAXBPT];
42573 + * kdb_bp_install_global
42575 + * Install global kdb_breakpoints prior to returning from the
42576 + * kernel debugger. This allows the kdb_breakpoints to be set
42577 + * upon functions that are used internally by kdb, such as
42581 + * regs Execution frame.
42590 + * This function is only called once per kdb session.
42594 +kdb_bp_install_global(struct pt_regs *regs)
42598 + for(i=0; i<KDB_MAXBPT; i++) {
42599 + if (KDB_DEBUG(BP)) {
42600 + kdb_printf("kdb_bp_install_global bp %d bp_enabled %d bp_global %d\n",
42601 + i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global);
42603 + if (kdb_breakpoints[i].bp_enabled
42604 + && kdb_breakpoints[i].bp_global) {
42605 + kdba_installbp(regs, &kdb_breakpoints[i]);
42611 + * kdb_bp_install_local
42613 + * Install local kdb_breakpoints prior to returning from the
42614 + * kernel debugger. This allows the kdb_breakpoints to be set
42615 + * upon functions that are used internally by kdb, such as
42619 + * regs Execution frame.
42628 + * This function is called once per processor.
42632 +kdb_bp_install_local(struct pt_regs *regs)
42636 + for(i=0; i<KDB_MAXBPT; i++) {
42637 + if (KDB_DEBUG(BP)) {
42638 + kdb_printf("kdb_bp_install_local bp %d bp_enabled %d bp_global %d cpu %d bp_cpu %d\n",
42639 + i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global,
42640 + smp_processor_id(), kdb_breakpoints[i].bp_cpu);
42642 + if (kdb_breakpoints[i].bp_enabled
42643 + && kdb_breakpoints[i].bp_cpu == smp_processor_id()
42644 + && !kdb_breakpoints[i].bp_global){
42645 + kdba_installbp(regs, &kdb_breakpoints[i]);
42651 + * kdb_bp_remove_global
42653 + * Remove global kdb_breakpoints upon entry to the kernel debugger.
42667 +kdb_bp_remove_global(void)
42671 + for(i=KDB_MAXBPT-1; i>=0; i--) {
42672 + if (KDB_DEBUG(BP)) {
42673 + kdb_printf("kdb_bp_remove_global bp %d bp_enabled %d bp_global %d\n",
42674 + i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global);
42676 + if (kdb_breakpoints[i].bp_enabled
42677 + && kdb_breakpoints[i].bp_global) {
42678 + kdba_removebp(&kdb_breakpoints[i]);
42685 + * kdb_bp_remove_local
42687 + * Remove local kdb_breakpoints upon entry to the kernel debugger.
42701 +kdb_bp_remove_local(void)
42705 + for(i=KDB_MAXBPT-1; i>=0; i--) {
42706 + if (KDB_DEBUG(BP)) {
42707 + kdb_printf("kdb_bp_remove_local bp %d bp_enabled %d bp_global %d cpu %d bp_cpu %d\n",
42708 + i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global,
42709 + smp_processor_id(), kdb_breakpoints[i].bp_cpu);
42711 + if (kdb_breakpoints[i].bp_enabled
42712 + && kdb_breakpoints[i].bp_cpu == smp_processor_id()
42713 + && !kdb_breakpoints[i].bp_global){
42714 + kdba_removebp(&kdb_breakpoints[i]);
42722 + * Internal function to format and print a breakpoint entry.
42736 +kdb_printbp(kdb_bp_t *bp, int i)
42738 + if (bp->bp_forcehw) {
42739 + kdb_printf("Forced ");
42742 + if (!bp->bp_template.bph_free) {
42743 + kdb_printf("%s ", kdba_bptype(&bp->bp_template));
42745 + kdb_printf("Instruction(i) ");
42748 + kdb_printf("BP #%d at ", i);
42749 + kdb_symbol_print(bp->bp_addr, NULL, KDB_SP_DEFAULT);
42751 + if (bp->bp_enabled) {
42752 + kdba_printbp(bp);
42753 + if (bp->bp_global)
42754 + kdb_printf(" globally");
42756 + kdb_printf(" on cpu %d", bp->bp_cpu);
42757 + if (bp->bp_adjust)
42758 + kdb_printf(" adjust %d", bp->bp_adjust);
42760 + kdb_printf("\n is disabled");
42763 + kdb_printf("\n");
42769 + * Handle the bp, and bpa commands.
42771 + * [bp|bpa|bph] <addr-expression> [DATAR|DATAW|IO [length]]
42774 + * argc Count of arguments in argv
42775 + * argv Space delimited command line arguments
42779 + * Zero for success, a kdb diagnostic if failure.
42784 + * bp Set breakpoint. Only use hardware assist if necessary.
42785 + * bpa Set breakpoint on all cpus, only use hardware regs if necessary
42786 + * bph Set breakpoint - force hardware register
42787 + * bpha Set breakpoint on all cpus, force hardware register
42791 +kdb_bp(int argc, const char **argv)
42794 + kdb_bp_t *bp, *bp_check;
42797 + kdb_machreg_t addr;
42798 + char *symname = NULL;
42799 + long offset = 0ul;
42806 + * Display breakpoint table
42808 + for(bpno=0,bp=kdb_breakpoints; bpno<KDB_MAXBPT; bpno++, bp++) {
42809 + if (bp->bp_free) continue;
42811 + kdb_printbp(bp, bpno);
42817 + global = ((strcmp(argv[0], "bpa") == 0)
42818 + || (strcmp(argv[0], "bpha") == 0));
42819 + hardware = ((strcmp(argv[0], "bph") == 0)
42820 + || (strcmp(argv[0], "bpha") == 0));
42823 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, &symname);
42827 + return KDB_BADINT;
42830 + * Allocate a new bp structure
42832 + free = KDB_MAXBPT;
42833 + for(bpno=0,bp=kdb_breakpoints; bpno<KDB_MAXBPT; bpno++,bp++) {
42834 + if (bp->bp_free) {
42839 + if (bpno == KDB_MAXBPT)
42840 + return KDB_TOOMANYBPT;
42842 + memset(bp, 0, sizeof(*bp));
42844 + kdba_check_pc(&addr);
42845 + for(i=0,bp_check=kdb_breakpoints; i<KDB_MAXBPT; i++,bp_check++) {
42846 + if (!bp_check->bp_free && bp_check->bp_addr == addr) {
42847 + kdb_printf("You already have a breakpoint at " kdb_bfd_vma_fmt0 "\n", addr);
42848 + return KDB_DUPBPT;
42851 + bp->bp_addr = addr;
42854 + bp->bp_forcehw = hardware;
42855 + if (KDB_DEBUG(BP))
42856 + kdb_printf("kdb_bp: forcehw is %d hardware is %d\n", bp->bp_forcehw, hardware);
42859 + * Handle architecture dependent parsing
42861 + diag = kdba_parsebp(argc, argv, &nextarg, bp);
42866 + bp->bp_enabled = 1;
42867 + bp->bp_global = 1; /* Most breakpoints are global */
42869 + if (hardware && !global) {
42870 + bp->bp_global = 0;
42871 + bp->bp_cpu = smp_processor_id();
42875 + * Allocate a hardware breakpoint. If one is not available,
42876 + * disable the breakpoint, but leave it in the breakpoint
42877 + * table. When the breakpoint is re-enabled (via 'be'), we'll
42878 + * attempt to allocate a hardware register for it.
42880 + if (!bp->bp_template.bph_free) {
42881 + bp->bp_hard = kdba_allocbp(&bp->bp_template, &diag);
42883 + bp->bp_enabled = 0;
42886 + bp->bp_hardtype = 1;
42889 + kdb_printbp(bp, bpno);
42897 + * Handles the 'bc', 'be', and 'bd' commands
42899 + * [bd|bc|be] <breakpoint-number>
42903 + * argc Count of arguments in argv
42904 + * argv Space delimited command line arguments
42908 + * Zero for success, a kdb diagnostic for failure
42914 +#define KDBCMD_BC 0
42915 +#define KDBCMD_BE 1
42916 +#define KDBCMD_BD 2
42919 +kdb_bc(int argc, const char **argv)
42921 + kdb_machreg_t addr;
42922 + kdb_bp_t *bp = NULL;
42923 + int lowbp = KDB_MAXBPT;
42928 + int cmd; /* KDBCMD_B? */
42930 + if (strcmp(argv[0], "be") == 0) {
42932 + } else if (strcmp(argv[0], "bd") == 0) {
42938 + return KDB_ARGCOUNT;
42940 + if (strcmp(argv[1], "*") == 0) {
42942 + highbp = KDB_MAXBPT;
42944 + diag = kdbgetularg(argv[1], &addr);
42949 + * For addresses less than the maximum breakpoint number,
42950 + * assume that the breakpoint number is desired.
42952 + if (addr < KDB_MAXBPT) {
42953 + bp = &kdb_breakpoints[addr];
42954 + lowbp = highbp = addr;
42957 + for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
42958 + if (bp->bp_addr == addr) {
42959 + lowbp = highbp = i;
42968 + * Now operate on the set of breakpoints matching the input
42969 + * criteria (either '*' for all, or an individual breakpoint).
42971 + for(bp=&kdb_breakpoints[lowbp], i=lowbp;
42981 + if (bp->bp_hardtype) {
42982 + kdba_freebp(bp->bp_hard);
42983 + bp->bp_hard = NULL;
42984 + bp->bp_hardtype = 0;
42987 + bp->bp_enabled = 0;
42988 + bp->bp_global = 0;
42990 + kdb_printf("Breakpoint %d at " kdb_bfd_vma_fmt " cleared\n",
42999 + * Allocate a hardware breakpoint. If one is not
43000 + * available, don't enable the breakpoint.
43002 + if (!bp->bp_template.bph_free
43003 + && !bp->bp_hardtype) {
43004 + bp->bp_hard = kdba_allocbp(&bp->bp_template, &diag);
43006 + bp->bp_enabled = 0;
43009 + bp->bp_hardtype = 1;
43012 + bp->bp_enabled = 1;
43014 + kdb_printf("Breakpoint %d at " kdb_bfd_vma_fmt " enabled",
43017 + kdb_printf("\n");
43020 + if (!bp->bp_enabled)
43024 + * Since this breakpoint is now disabled, we can
43025 + * give up the hardware register which is allocated
43028 + if (bp->bp_hardtype) {
43029 + kdba_freebp(bp->bp_hard);
43030 + bp->bp_hard = NULL;
43031 + bp->bp_hardtype = 0;
43034 + bp->bp_enabled = 0;
43036 + kdb_printf("Breakpoint %d at " kdb_bfd_vma_fmt " disabled\n",
43041 + if (bp->bp_delay && (cmd == KDBCMD_BC || cmd == KDBCMD_BD)) {
43042 + bp->bp_delay = 0;
43043 + KDB_STATE_CLEAR(SSBPT);
43047 + return (!done)?KDB_BPTNOTFOUND:0;
43053 + * Process the 'ss' (Single Step) and 'ssb' (Single Step to Branch)
43060 + * argc Argument count
43061 + * argv Argument vector
43065 + * KDB_CMD_SS[B] for success, a kdb error if failure.
43070 + * Set the arch specific option to trigger a debug trap after the next
43073 + * For 'ssb', set the trace flag in the debug trap handler
43074 + * after printing the current insn and return directly without
43075 + * invoking the kdb command processor, until a branch instruction
43076 + * is encountered.
43080 +kdb_ss(int argc, const char **argv)
43083 + struct pt_regs *regs = get_irq_regs();
43085 + ssb = (strcmp(argv[0], "ssb") == 0);
43087 + return KDB_ARGCOUNT;
43090 + kdb_printf("%s: pt_regs not available\n", __FUNCTION__);
43091 + return KDB_BADREG;
43095 + * Set trace flag and go.
43097 + KDB_STATE_SET(DOING_SS);
43099 + KDB_STATE_SET(DOING_SSB);
43101 + kdba_setsinglestep(regs); /* Enable single step */
43104 + return KDB_CMD_SSB;
43105 + return KDB_CMD_SS;
43111 + * Initialize the breakpoint table. Register breakpoint commands.
43125 +kdb_initbptab(void)
43131 + * First time initialization.
43133 + memset(&kdb_breakpoints, '\0', sizeof(kdb_breakpoints));
43135 + for (i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
43138 + * The bph_free flag is architecturally required. It
43139 + * is set by architecture-dependent code to false (zero)
43140 + * in the event a hardware breakpoint register is required
43141 + * for this breakpoint.
43143 + * The rest of the template is reserved to the architecture
43144 + * dependent code and _must_ not be touched by the architecture
43145 + * independent code.
43147 + bp->bp_template.bph_free = 1;
43150 + kdb_register_repeat("bp", kdb_bp, "[<vaddr>]", "Set/Display breakpoints", 0, KDB_REPEAT_NO_ARGS);
43151 + kdb_register_repeat("bl", kdb_bp, "[<vaddr>]", "Display breakpoints", 0, KDB_REPEAT_NO_ARGS);
43152 + kdb_register_repeat("bpa", kdb_bp, "[<vaddr>]", "Set/Display global breakpoints", 0, KDB_REPEAT_NO_ARGS);
43153 + kdb_register_repeat("bph", kdb_bp, "[<vaddr>]", "Set hardware breakpoint", 0, KDB_REPEAT_NO_ARGS);
43154 + kdb_register_repeat("bpha", kdb_bp, "[<vaddr>]", "Set global hardware breakpoint", 0, KDB_REPEAT_NO_ARGS);
43155 + kdb_register_repeat("bc", kdb_bc, "<bpnum>", "Clear Breakpoint", 0, KDB_REPEAT_NONE);
43156 + kdb_register_repeat("be", kdb_bc, "<bpnum>", "Enable Breakpoint", 0, KDB_REPEAT_NONE);
43157 + kdb_register_repeat("bd", kdb_bc, "<bpnum>", "Disable Breakpoint", 0, KDB_REPEAT_NONE);
43159 + kdb_register_repeat("ss", kdb_ss, "", "Single Step", 1, KDB_REPEAT_NO_ARGS);
43160 + kdb_register_repeat("ssb", kdb_ss, "", "Single step to branch/call", 0, KDB_REPEAT_NO_ARGS);
43162 + * Architecture dependent initialization.
43166 diff -Nurp linux-2.6.22-590/kdb/kdb_bt.c linux-2.6.22-600/kdb/kdb_bt.c
43167 --- linux-2.6.22-590/kdb/kdb_bt.c 1970-01-01 01:00:00.000000000 +0100
43168 +++ linux-2.6.22-600/kdb/kdb_bt.c 2008-04-09 18:14:28.000000000 +0200
43171 + * Kernel Debugger Architecture Independent Stack Traceback
43173 + * This file is subject to the terms and conditions of the GNU General Public
43174 + * License. See the file "COPYING" in the main directory of this archive
43175 + * for more details.
43177 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
43180 +#include <linux/ctype.h>
43181 +#include <linux/string.h>
43182 +#include <linux/kernel.h>
43183 +#include <linux/sched.h>
43184 +#include <linux/kdb.h>
43185 +#include <linux/kdbprivate.h>
43186 +#include <linux/nmi.h>
43187 +#include <asm/system.h>
43193 + * This function implements the 'bt' command. Print a stack
43196 + * bt [<address-expression>] (addr-exp is for alternate stacks)
43197 + * btp <pid> Kernel stack for <pid>
43198 + * btt <address-expression> Kernel stack for task structure at <address-expression>
43199 + * bta [DRSTCZEUIMA] All useful processes, optionally filtered by state
43200 + * btc [<cpu>] The current process on one cpu, default is all cpus
43202 + * bt <address-expression> refers to a address on the stack, that location
43203 + * is assumed to contain a return address.
43205 + * btt <address-expression> refers to the address of a struct task.
43208 + * argc argument count
43209 + * argv argument vector
43213 + * zero for success, a kdb diagnostic if error
43217 + * Backtrack works best when the code uses frame pointers. But even
43218 + * without frame pointers we should get a reasonable trace.
43220 + * mds comes in handy when examining the stack to do a manual traceback or
43221 + * to get a starting point for bt <address-expression>.
43225 +kdb_bt1(const struct task_struct *p, unsigned long mask, int argcount, int btaprompt)
43229 + if (kdb_getarea(buffer[0], (unsigned long)p) ||
43230 + kdb_getarea(buffer[0], (unsigned long)(p+1)-1))
43231 + return KDB_BADADDR;
43232 + if (!kdb_task_state(p, mask))
43234 + kdb_printf("Stack traceback for pid %d\n", p->pid);
43236 + diag = kdba_bt_process(p, argcount);
43238 + kdb_getstr(buffer, sizeof(buffer), "Enter <q> to end, <cr> to continue:");
43239 + if (buffer[0] == 'q') {
43240 + kdb_printf("\n");
43244 + touch_nmi_watchdog();
43249 +kdb_bt(int argc, const char **argv)
43252 + int argcount = 5;
43253 + int btaprompt = 1;
43255 + unsigned long addr;
43258 + kdbgetintenv("BTARGS", &argcount); /* Arguments to print */
43259 + kdbgetintenv("BTAPROMPT", &btaprompt); /* Prompt after each proc in bta */
43261 + if (strcmp(argv[0], "bta") == 0) {
43262 + struct task_struct *g, *p;
43263 + unsigned long cpu;
43264 + unsigned long mask = kdb_task_state_string(argc ? argv[1] : NULL);
43266 + kdb_ps_suppressed();
43267 + /* Run the active tasks first */
43268 + for (cpu = 0; cpu < NR_CPUS; ++cpu) {
43269 + if (!cpu_online(cpu))
43271 + p = kdb_curr_task(cpu);
43272 + if (kdb_bt1(p, mask, argcount, btaprompt))
43275 + /* Now the inactive tasks */
43276 + kdb_do_each_thread(g, p) {
43277 + if (task_curr(p))
43279 + if (kdb_bt1(p, mask, argcount, btaprompt))
43281 + } kdb_while_each_thread(g, p);
43282 + } else if (strcmp(argv[0], "btp") == 0) {
43283 + struct task_struct *p;
43284 + unsigned long pid;
43286 + return KDB_ARGCOUNT;
43287 + if ((diag = kdbgetularg((char *)argv[1], &pid)))
43289 + if ((p = find_task_by_pid(pid))) {
43290 + kdba_set_current_task(p);
43291 + return kdb_bt1(p, ~0UL, argcount, 0);
43293 + kdb_printf("No process with pid == %ld found\n", pid);
43295 + } else if (strcmp(argv[0], "btt") == 0) {
43297 + return KDB_ARGCOUNT;
43298 + if ((diag = kdbgetularg((char *)argv[1], &addr)))
43300 + kdba_set_current_task((struct task_struct *)addr);
43301 + return kdb_bt1((struct task_struct *)addr, ~0UL, argcount, 0);
43302 + } else if (strcmp(argv[0], "btc") == 0) {
43303 + unsigned long cpu = ~0;
43304 + struct kdb_running_process *krp;
43305 + const struct task_struct *save_current_task = kdb_current_task;
43308 + return KDB_ARGCOUNT;
43309 + if (argc == 1 && (diag = kdbgetularg((char *)argv[1], &cpu)))
43311 + /* Recursive use of kdb_parse, do not use argv after this point */
43314 + krp = kdb_running_process + cpu;
43315 + if (cpu >= NR_CPUS || !krp->seqno || !cpu_online(cpu)) {
43316 + kdb_printf("no process for cpu %ld\n", cpu);
43319 + sprintf(buf, "btt 0x%p\n", krp->p);
43323 + kdb_printf("btc: cpu status: ");
43324 + kdb_parse("cpu\n");
43325 + for (cpu = 0, krp = kdb_running_process; cpu < NR_CPUS; ++cpu, ++krp) {
43326 + if (!cpu_online(cpu) || !krp->seqno)
43328 + sprintf(buf, "btt 0x%p\n", krp->p);
43330 + touch_nmi_watchdog();
43332 + kdba_set_current_task(save_current_task);
43337 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr,
43341 + return kdba_bt_address(addr, argcount);
43343 + return kdb_bt1(kdb_current_task, ~0UL, argcount, 0);
43350 diff -Nurp linux-2.6.22-590/kdb/kdb_cmds linux-2.6.22-600/kdb/kdb_cmds
43351 --- linux-2.6.22-590/kdb/kdb_cmds 1970-01-01 01:00:00.000000000 +0100
43352 +++ linux-2.6.22-600/kdb/kdb_cmds 2008-04-09 18:14:28.000000000 +0200
43354 +# Initial commands for kdb, alter to suit your needs.
43355 +# These commands are executed in kdb_init() context, no SMP, no
43356 +# processes. Commands that require process data (including stack or
43357 +# registers) are not reliable this early. set and bp commands should
43358 +# be safe. Global breakpoint commands affect each cpu as it is booted.
43360 +# Standard debugging information for first level support, just type archkdb
43361 +# or archkdbcpu or archkdbshort at the kdb prompt.
43363 +defcmd archkdb "" "First line arch debugging"
43371 +defcmd archkdbcpu "" "archkdb with only tasks on cpus"
43379 +defcmd archkdbshort "" "archkdb with less detailed backtrace"
43386 diff -Nurp linux-2.6.22-590/kdb/kdb_id.c linux-2.6.22-600/kdb/kdb_id.c
43387 --- linux-2.6.22-590/kdb/kdb_id.c 1970-01-01 01:00:00.000000000 +0100
43388 +++ linux-2.6.22-600/kdb/kdb_id.c 2008-04-09 18:14:28.000000000 +0200
43391 + * Kernel Debugger Architecture Independent Instruction Disassembly
43393 + * This file is subject to the terms and conditions of the GNU General Public
43394 + * License. See the file "COPYING" in the main directory of this archive
43395 + * for more details.
43397 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
43400 +#include <stdarg.h>
43401 +#include <linux/kernel.h>
43402 +#include <linux/init.h>
43403 +#include <linux/ctype.h>
43404 +#include <linux/string.h>
43405 +#include <linux/kdb.h>
43406 +#include <linux/kdbprivate.h>
43408 +disassemble_info kdb_di;
43413 + * Handle the id (instruction display) command.
43418 + * argc Count of arguments in argv
43419 + * argv Space delimited command line arguments
43423 + * Zero for success, a kdb diagnostic if failure.
43430 +kdb_id(int argc, const char **argv)
43432 + kdb_machreg_t pc;
43439 + static kdb_machreg_t lastpc;
43440 + struct disassemble_info *dip = &kdb_di;
43441 + char lastbuf[50];
43442 + unsigned long word;
43444 + kdb_di.fprintf_func = kdb_dis_fprintf;
43445 + kdba_id_init(&kdb_di);
43448 + if (lastpc == 0) {
43449 + return KDB_ARGCOUNT;
43451 + sprintf(lastbuf, "0x%lx", lastpc);
43452 + argv[1] = lastbuf;
43459 + * Fetch PC. First, check to see if it is a symbol, if not,
43463 + diag = kdbgetaddrarg(argc, argv, &nextarg, &pc, &offset, NULL);
43466 + kdba_check_pc(&pc);
43467 + if (kdb_getarea(word, pc))
43471 + * Number of lines to display
43473 + diag = kdbgetintenv("IDCOUNT", &icount);
43477 + mode = kdbgetenv("IDMODE");
43478 + diag = kdba_id_parsemode(mode, dip);
43483 + for(i=0; i<icount; i++) {
43484 + pc += kdba_id_printinsn(pc, &kdb_di);
43485 + kdb_printf("\n");
43496 + * Disassemble a single instruction at 'pc'.
43499 + * pc Address of instruction to disassemble
43503 + * Zero for success, a kdb diagnostic if failure.
43510 +kdb_id1(unsigned long pc)
43515 + kdb_di.fprintf_func = kdb_dis_fprintf;
43516 + kdba_id_init(&kdb_di);
43519 + * Allow the user to specify that this instruction
43520 + * should be treated differently.
43523 + mode = kdbgetenv("IDMODE");
43524 + diag = kdba_id_parsemode(mode, &kdb_di);
43526 + kdb_printf("kdb_id: bad value in 'IDMODE' environment variable ignored\n");
43529 + (void) kdba_id_printinsn(pc, &kdb_di);
43530 + kdb_printf("\n");
43534 + * kdb_dis_fprintf
43536 + * Format and print a string.
43539 + * file Unused paramter.
43540 + * fmt Format string
43541 + * ... Optional additional parameters.
43546 + * Result of format conversion cannot exceed 255 bytes.
43550 +kdb_dis_fprintf(PTR file, const char *fmt, ...)
43552 + char buffer[256];
43555 + va_start(ap, fmt);
43556 + vsprintf(buffer, fmt, ap);
43559 + kdb_printf("%s", buffer);
43565 + * kdb_dis_fprintf_dummy
43567 + * A dummy printf function for the disassembler, it does nothing.
43568 + * This lets code call the disassembler to step through
43569 + * instructions without actually printing anything.
43571 + * Always ignored.
43583 +kdb_dis_fprintf_dummy(PTR file, const char *fmt, ...)
43591 + * Initialize the disassembly information structure
43592 + * for the GNU disassembler.
43599 + * Zero for success, a kdb diagnostic if failure.
43608 + kdb_di.stream = NULL;
43609 + kdb_di.application_data = NULL;
43610 + kdb_di.symbols = NULL;
43611 + kdb_di.num_symbols = 0;
43612 + kdb_di.flags = 0;
43613 + kdb_di.private_data = NULL;
43614 + kdb_di.buffer = NULL;
43615 + kdb_di.buffer_vma = 0;
43616 + kdb_di.buffer_length = 0;
43617 + kdb_di.bytes_per_line = 0;
43618 + kdb_di.bytes_per_chunk = 0;
43619 + kdb_di.insn_info_valid = 0;
43620 + kdb_di.branch_delay_insns = 0;
43621 + kdb_di.data_size = 0;
43622 + kdb_di.insn_type = 0;
43623 + kdb_di.target = 0;
43624 + kdb_di.target2 = 0;
43626 diff -Nurp linux-2.6.22-590/kdb/kdb_io.c linux-2.6.22-600/kdb/kdb_io.c
43627 --- linux-2.6.22-590/kdb/kdb_io.c 1970-01-01 01:00:00.000000000 +0100
43628 +++ linux-2.6.22-600/kdb/kdb_io.c 2008-04-09 18:14:28.000000000 +0200
43631 + * Kernel Debugger Architecture Independent Console I/O handler
43633 + * This file is subject to the terms and conditions of the GNU General Public
43634 + * License. See the file "COPYING" in the main directory of this archive
43635 + * for more details.
43637 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
43640 +#include <linux/module.h>
43641 +#include <linux/types.h>
43642 +#include <linux/ctype.h>
43643 +#include <linux/kernel.h>
43644 +#include <linux/init.h>
43645 +#include <linux/kdev_t.h>
43646 +#include <linux/console.h>
43647 +#include <linux/string.h>
43648 +#include <linux/sched.h>
43649 +#include <linux/smp.h>
43650 +#include <linux/nmi.h>
43651 +#include <linux/delay.h>
43653 +#include <linux/kdb.h>
43654 +#include <linux/kdbprivate.h>
43655 +#include <linux/kallsyms.h>
43657 +static struct console *kdbcons;
43659 +#ifdef CONFIG_PPC64
43660 +#include <asm/udbg.h>
43663 +#define CMD_BUFLEN 256
43664 +char kdb_prompt_str[CMD_BUFLEN];
43669 + * This function reads a string of characters, terminated by
43670 + * a newline, or by reaching the end of the supplied buffer,
43671 + * from the current kernel debugger console device.
43673 + * buffer - Address of character buffer to receive input characters.
43674 + * bufsize - size, in bytes, of the character buffer
43676 + * Returns a pointer to the buffer containing the received
43677 + * character string. This string will be terminated by a
43678 + * newline character.
43680 + * No locks are required to be held upon entry to this
43681 + * function. It is not reentrant - it relies on the fact
43682 + * that while kdb is running on any one processor all other
43683 + * processors will be spinning at the kdb barrier.
43686 + * Davidm asks, why doesn't kdb use the console abstraction;
43687 + * here are some reasons:
43688 + * - you cannot debug the console abstraction with kdb if
43690 + * - you rely on the correct functioning of the abstraction
43691 + * in the presence of general system failures.
43692 + * - You must acquire the console spinlock thus restricting
43693 + * the usability - what if the kernel fails with the spinlock
43694 + * held - one still wishes to debug such situations.
43695 + * - How about debugging before the console(s) are registered?
43696 + * - None of the current consoles (sercons, vt_console_driver)
43697 + * have read functions defined.
43698 + * - The standard pc keyboard and terminal drivers are interrupt
43699 + * driven. We cannot enable interrupts while kdb is active,
43700 + * so the standard input functions cannot be used by kdb.
43702 + * An implementation could be improved by removing the need for
43703 + * lock acquisition - just keep a 'struct console *kdbconsole;' global
43704 + * variable which refers to the preferred kdb console.
43706 + * The bulk of this function is architecture dependent.
43708 + * The buffer size must be >= 2. A buffer size of 2 means that the caller only
43709 + * wants a single key.
43711 + * An escape key could be the start of a vt100 control sequence such as \e[D
43712 + * (left arrow) or it could be a character in its own right. The standard
43713 + * method for detecting the difference is to wait for 2 seconds to see if there
43714 + * are any other characters. kdb is complicated by the lack of a timer service
43715 + * (interrupts are off), by multiple input sources and by the need to sometimes
43716 + * return after just one key. Escape sequence processing has to be done as
43717 + * states in the polling loop.
43721 +kdb_read(char *buffer, size_t bufsize)
43723 + char *cp = buffer;
43724 + char *bufend = buffer+bufsize-2; /* Reserve space for newline and null byte */
43729 + static char tmpbuffer[CMD_BUFLEN];
43730 + int len = strlen(buffer);
43735 + int diag, dtab_count;
43737 +#define ESCAPE_UDELAY 1000
43738 +#define ESCAPE_DELAY 2*1000000/ESCAPE_UDELAY /* 2 seconds worth of udelays */
43739 + char escape_data[5]; /* longest vt100 escape sequence is 4 bytes */
43740 + char *ped = escape_data;
43741 + int escape_delay = 0;
43742 + get_char_func *f, *f_escape = NULL;
43744 + diag = kdbgetintenv("DTABCOUNT",&dtab_count);
43750 + if (*(buffer+len-1) == '\n')
43756 + kdb_printf("%s", buffer);
43760 + for (f = &poll_funcs[0]; ; ++f) {
43761 + if (*f == NULL) {
43762 + /* Reset NMI watchdog once per poll loop */
43763 + touch_nmi_watchdog();
43764 + f = &poll_funcs[0];
43766 + if (escape_delay == 2) {
43768 + ped = escape_data;
43771 + if (escape_delay == 1) {
43779 + if (escape_delay) {
43780 + udelay(ESCAPE_UDELAY);
43785 + if (bufsize <= 2) {
43788 + kdb_printf("%c", key);
43793 + if (escape_delay == 0 && key == '\e') {
43794 + escape_delay = ESCAPE_DELAY;
43795 + ped = escape_data;
43798 + if (escape_delay) {
43800 + if (f_escape != f) {
43801 + escape_delay = 2;
43804 + if (ped - escape_data == 1) {
43808 + else if (ped - escape_data == 2) {
43809 + /* \e<something> */
43811 + escape_delay = 2;
43813 + } else if (ped - escape_data == 3) {
43814 + /* \e[<something> */
43817 + case 'A': mapkey = 16; break; /* \e[A, up arrow */
43818 + case 'B': mapkey = 14; break; /* \e[B, down arrow */
43819 + case 'C': mapkey = 6; break; /* \e[C, right arrow */
43820 + case 'D': mapkey = 2; break; /* \e[D, left arrow */
43821 + case '1': /* dropthrough */
43822 + case '3': /* dropthrough */
43823 + case '4': mapkey = -1; break; /* \e[<1,3,4>], may be home, del, end */
43825 + if (mapkey != -1) {
43826 + if (mapkey > 0) {
43827 + escape_data[0] = mapkey;
43828 + escape_data[1] = '\0';
43830 + escape_delay = 2;
43833 + } else if (ped - escape_data == 4) {
43834 + /* \e[<1,3,4><something> */
43836 + if (key == '~') {
43837 + switch (escape_data[2]) {
43838 + case '1': mapkey = 1; break; /* \e[1~, home */
43839 + case '3': mapkey = 4; break; /* \e[3~, del */
43840 + case '4': mapkey = 5; break; /* \e[4~, end */
43843 + if (mapkey > 0) {
43844 + escape_data[0] = mapkey;
43845 + escape_data[1] = '\0';
43847 + escape_delay = 2;
43851 + break; /* A key to process */
43857 + case 8: /* backspace */
43858 + if (cp > buffer) {
43859 + if (cp < lastchar) {
43860 + memcpy(tmpbuffer, cp, lastchar - cp);
43861 + memcpy(cp-1, tmpbuffer, lastchar - cp);
43863 + *(--lastchar) = '\0';
43865 + kdb_printf("\b%s \r", cp);
43868 + kdb_printf(kdb_prompt_str);
43869 + kdb_printf("%s", buffer);
43873 + case 13: /* enter */
43874 + *lastchar++ = '\n';
43875 + *lastchar++ = '\0';
43876 + kdb_printf("\n");
43878 + case 4: /* Del */
43879 + if(cp < lastchar) {
43880 + memcpy(tmpbuffer, cp+1, lastchar - cp -1);
43881 + memcpy(cp, tmpbuffer, lastchar - cp -1);
43882 + *(--lastchar) = '\0';
43883 + kdb_printf("%s \r", cp);
43886 + kdb_printf(kdb_prompt_str);
43887 + kdb_printf("%s", buffer);
43891 + case 1: /* Home */
43892 + if(cp > buffer) {
43893 + kdb_printf("\r");
43894 + kdb_printf(kdb_prompt_str);
43898 + case 5: /* End */
43899 + if(cp < lastchar) {
43900 + kdb_printf("%s", cp);
43904 + case 2: /* Left */
43905 + if (cp > buffer) {
43906 + kdb_printf("\b");
43910 + case 14: /* Down */
43911 + memset(tmpbuffer, ' ', strlen(kdb_prompt_str)+(lastchar-buffer));
43912 + *(tmpbuffer+strlen(kdb_prompt_str)+(lastchar-buffer)) = '\0';
43913 + kdb_printf("\r%s\r", tmpbuffer);
43914 + *lastchar = (char)key;
43915 + *(lastchar+1) = '\0';
43917 + case 6: /* Right */
43918 + if (cp < lastchar) {
43919 + kdb_printf("%c", *cp);
43923 + case 16: /* Up */
43924 + memset(tmpbuffer, ' ', strlen(kdb_prompt_str)+(lastchar-buffer));
43925 + *(tmpbuffer+strlen(kdb_prompt_str)+(lastchar-buffer)) = '\0';
43926 + kdb_printf("\r%s\r", tmpbuffer);
43927 + *lastchar = (char)key;
43928 + *(lastchar+1) = '\0';
43930 + case 9: /* Tab */
43934 + while(*p_tmp==' ') p_tmp++;
43936 + memcpy(tmpbuffer, p_tmp, cp-p_tmp);
43937 + *(tmpbuffer + (cp-p_tmp)) = '\0';
43938 + p_tmp = strrchr(tmpbuffer, ' ');
43942 + p_tmp = tmpbuffer;
43943 + len = strlen(p_tmp);
43944 + count = kallsyms_symbol_complete(p_tmp, sizeof(tmpbuffer) - (p_tmp - tmpbuffer));
43947 + kdb_printf("\n%d symbols are found.", count);
43948 + if(count>dtab_count) {
43949 + count=dtab_count;
43950 + kdb_printf(" But only first %d symbols will be printed.\nYou can change the environment variable DTABCOUNT.", count);
43952 + kdb_printf("\n");
43953 + for(i=0;i<count;i++) {
43954 + if(kallsyms_symbol_next(p_tmp, i)<0)
43956 + kdb_printf("%s ",p_tmp);
43957 + *(p_tmp+len)='\0';
43959 + if(i>=dtab_count)kdb_printf("...");
43960 + kdb_printf("\n");
43961 + kdb_printf(kdb_prompt_str);
43962 + kdb_printf("%s", buffer);
43967 + len_tmp = strlen(p_tmp);
43968 + strncpy(p_tmp+len_tmp,cp, lastchar-cp+1);
43969 + len_tmp = strlen(p_tmp);
43970 + strncpy(cp, p_tmp+len, len_tmp-len+1);
43971 + len = len_tmp - len;
43972 + kdb_printf("%s", cp);
43977 + kdb_nextline = 1; /* reset output line number */
43981 + if (key >= 32 &&lastchar < bufend) {
43982 + if (cp < lastchar) {
43983 + memcpy(tmpbuffer, cp, lastchar - cp);
43984 + memcpy(cp+1, tmpbuffer, lastchar - cp);
43985 + *++lastchar = '\0';
43987 + kdb_printf("%s\r", cp);
43991 + kdb_printf(kdb_prompt_str);
43992 + kdb_printf("%s", buffer);
43995 + *++lastchar = '\0';
43997 + kdb_printf("%c", key);
44008 + * Print the prompt string and read a command from the
44012 + * buffer Address of buffer to receive command
44013 + * bufsize Size of buffer in bytes
44014 + * prompt Pointer to string to use as prompt string
44016 + * Pointer to command buffer.
44020 + * For SMP kernels, the processor number will be
44021 + * substituted for %d, %x or %o in the prompt.
44025 +kdb_getstr(char *buffer, size_t bufsize, char *prompt)
44027 + if(prompt && kdb_prompt_str!=prompt)
44028 + strncpy(kdb_prompt_str, prompt, CMD_BUFLEN);
44029 + kdb_printf(kdb_prompt_str);
44030 + kdb_nextline = 1; /* Prompt and input resets line number */
44031 + return kdb_read(buffer, bufsize);
44035 + * kdb_input_flush
44037 + * Get rid of any buffered console input.
44046 + * Call this function whenever you want to flush input. If there is any
44047 + * outstanding input, it ignores all characters until there has been no
44048 + * data for approximately half a second.
44051 +#define FLUSH_UDELAY 100
44052 +#define FLUSH_DELAY 500000/FLUSH_UDELAY /* 0.5 seconds worth of udelays */
44055 +kdb_input_flush(void)
44057 + get_char_func *f;
44058 + int flush_delay = 1;
44059 + while (flush_delay--) {
44060 + touch_nmi_watchdog();
44061 + for (f = &poll_funcs[0]; *f; ++f) {
44062 + if ((*f)() != -1) {
44063 + flush_delay = FLUSH_DELAY;
44068 + udelay(FLUSH_UDELAY);
44075 + * Print a string to the output device(s).
44078 + * printf-like format and optional args.
44084 + * use 'kdbcons->write()' to avoid polluting 'log_buf' with
44088 +static char kdb_buffer[256]; /* A bit too big to go on stack */
44091 +kdb_printf(const char *fmt, ...)
44096 + int logging, saved_loglevel = 0;
44097 + int do_longjmp = 0;
44098 + int got_printf_lock = 0;
44099 + struct console *c = console_drivers;
44100 + static DEFINE_SPINLOCK(kdb_printf_lock);
44101 + unsigned long uninitialized_var(flags);
44103 + preempt_disable();
44104 + /* Serialize kdb_printf if multiple cpus try to write at once.
44105 + * But if any cpu goes recursive in kdb, just print the output,
44106 + * even if it is interleaved with any other text.
44108 + if (!KDB_STATE(PRINTF_LOCK)) {
44109 + KDB_STATE_SET(PRINTF_LOCK);
44110 + spin_lock_irqsave(&kdb_printf_lock, flags);
44111 + got_printf_lock = 1;
44112 + atomic_inc(&kdb_event);
44114 + __acquire(kdb_printf_lock);
44117 + diag = kdbgetintenv("LINES", &linecount);
44118 + if (diag || linecount <= 1)
44121 + diag = kdbgetintenv("LOGGING", &logging);
44125 + va_start(ap, fmt);
44126 + vsnprintf(kdb_buffer, sizeof(kdb_buffer), fmt, ap);
44130 + * Write to all consoles.
44132 +#ifdef CONFIG_SPARC64
44134 + prom_printf("%s", kdb_buffer);
44138 +#ifdef CONFIG_PPC64
44140 + udbg_write(kdb_buffer, strlen(kdb_buffer));
44145 + c->write(c, kdb_buffer, strlen(kdb_buffer));
44149 + saved_loglevel = console_loglevel;
44150 + console_loglevel = 0;
44151 + printk("%s", kdb_buffer);
44154 + if (KDB_STATE(LONGJMP) && strchr(kdb_buffer, '\n'))
44157 + if (kdb_nextline == linecount) {
44158 + char buf1[16]="";
44159 +#if defined(CONFIG_SMP)
44162 + char *moreprompt;
44164 + /* Watch out for recursion here. Any routine that calls
44165 + * kdb_printf will come back through here. And kdb_read
44166 + * uses kdb_printf to echo on serial consoles ...
44168 + kdb_nextline = 1; /* In case of recursion */
44171 + * Pause until cr.
44173 + moreprompt = kdbgetenv("MOREPROMPT");
44174 + if (moreprompt == NULL) {
44175 + moreprompt = "more> ";
44178 +#if defined(CONFIG_SMP)
44179 + if (strchr(moreprompt, '%')) {
44180 + sprintf(buf2, moreprompt, get_cpu());
44182 + moreprompt = buf2;
44186 + kdb_input_flush();
44187 + c = console_drivers;
44188 +#ifdef CONFIG_SPARC64
44190 + prom_printf("%s", moreprompt);
44194 +#ifdef CONFIG_PPC64
44196 + udbg_write(moreprompt, strlen(moreprompt));
44201 + c->write(c, moreprompt, strlen(moreprompt));
44206 + printk("%s", moreprompt);
44208 + kdb_read(buf1, 2); /* '2' indicates to return immediately after getting one key. */
44209 + kdb_nextline = 1; /* Really set output line 1 */
44211 + if ((buf1[0] == 'q') || (buf1[0] == 'Q')) {
44213 + KDB_FLAG_SET(CMD_INTERRUPT); /* command was interrupted */
44214 + kdb_printf("\n");
44216 + else if (buf1[0] && buf1[0] != '\n') {
44217 + kdb_printf("\nOnly 'q' or 'Q' are processed at more prompt, input ignored\n");
44219 + kdb_input_flush();
44223 + console_loglevel = saved_loglevel;
44225 + if (KDB_STATE(PRINTF_LOCK) && got_printf_lock) {
44226 + got_printf_lock = 0;
44227 + spin_unlock_irqrestore(&kdb_printf_lock, flags);
44228 + KDB_STATE_CLEAR(PRINTF_LOCK);
44229 + atomic_dec(&kdb_event);
44231 + __release(kdb_printf_lock);
44233 + preempt_enable();
44235 +#ifdef kdba_setjmp
44236 + kdba_longjmp(&kdbjmpbuf[smp_processor_id()], 1)
44237 +#endif /* kdba_setjmp */
44244 + * Initialize kernel debugger output environment.
44253 + * Select a console device. Only use a VT console if the user specified
44254 + * or defaulted console= /^tty[0-9]*$/
44256 + * FIXME: 2.6.22-rc1 initializes the serial console long after kdb starts,
44257 + * so booting with 'console=tty console=ttyS0' does not create the console
44258 + * entry for ttyS0 in time. For now simply assume that we have a working
44259 + * console, until a better solution can be found.
44266 + * Select a console.
44268 + struct console *c = console_drivers;
44269 + int vt_console = 0;
44272 +#if 0 /* FIXME: we don't register serial consoles in time */
44273 + if ((c->flags & CON_CONSDEV) && !kdbcons)
44279 + if ((c->flags & CON_ENABLED) &&
44280 + strncmp(c->name, "tty", 3) == 0) {
44281 + char *p = c->name + 3;
44282 + while (isdigit(*p))
44290 + if (kdbcons == NULL) {
44291 + printk(KERN_ERR "kdb: Initialization failed - no console. kdb is disabled.\n");
44292 + KDB_FLAG_SET(NO_CONSOLE);
44296 + KDB_FLAG_SET(NO_VT_CONSOLE);
44297 + kdb_input_flush();
44301 +EXPORT_SYMBOL(kdb_read);
44302 diff -Nurp linux-2.6.22-590/kdb/kdbmain.c linux-2.6.22-600/kdb/kdbmain.c
44303 --- linux-2.6.22-590/kdb/kdbmain.c 1970-01-01 01:00:00.000000000 +0100
44304 +++ linux-2.6.22-600/kdb/kdbmain.c 2008-04-09 18:14:28.000000000 +0200
44307 + * Kernel Debugger Architecture Independent Main Code
44309 + * This file is subject to the terms and conditions of the GNU General Public
44310 + * License. See the file "COPYING" in the main directory of this archive
44311 + * for more details.
44313 + * Copyright (C) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
44314 + * Copyright (C) 2000 Stephane Eranian <eranian@hpl.hp.com>
44315 + * Xscale (R) modifications copyright (C) 2003 Intel Corporation.
44319 + * Updated for Xscale (R) architecture support
44320 + * Eddie Dong <eddie.dong@intel.com> 8 Jan 03
44323 +#include <linux/ctype.h>
44324 +#include <linux/string.h>
44325 +#include <linux/kernel.h>
44326 +#include <linux/reboot.h>
44327 +#include <linux/sched.h>
44328 +#include <linux/sysrq.h>
44329 +#include <linux/smp.h>
44330 +#include <linux/utsname.h>
44331 +#include <linux/vmalloc.h>
44332 +#include <linux/module.h>
44333 +#include <linux/mm.h>
44334 +#include <linux/init.h>
44335 +#include <linux/kallsyms.h>
44336 +#include <linux/kdb.h>
44337 +#include <linux/kdbprivate.h>
44338 +#include <linux/notifier.h>
44339 +#include <linux/interrupt.h>
44340 +#include <linux/delay.h>
44341 +#include <linux/nmi.h>
44342 +#include <linux/ptrace.h>
44343 +#include <linux/sysctl.h>
44344 +#if defined(CONFIG_LKCD_DUMP) || defined(CONFIG_LKCD_DUMP_MODULE)
44345 +#include <linux/dump.h>
44347 +#include <linux/cpu.h>
44348 +#include <linux/kdebug.h>
44350 +#include <acpi/acpi_bus.h>
44352 +#include <asm/system.h>
44353 +#include <asm/kdebug.h>
44356 + * Kernel debugger state flags
44358 +volatile int kdb_flags;
44359 +atomic_t kdb_event;
44360 +atomic_t kdb_8250;
44363 + * kdb_lock protects updates to kdb_initial_cpu. Used to
44364 + * single thread processors through the kernel debugger.
44366 +static DEFINE_SPINLOCK(kdb_lock);
44367 +volatile int kdb_initial_cpu = -1; /* cpu number that owns kdb */
44368 +int kdb_seqno = 2; /* how many times kdb has been entered */
44370 +volatile int kdb_nextline = 1;
44371 +static volatile int kdb_new_cpu; /* Which cpu to switch to */
44373 +volatile int kdb_state[NR_CPUS]; /* Per cpu state */
44375 +const struct task_struct *kdb_current_task;
44376 +EXPORT_SYMBOL(kdb_current_task);
44377 +struct pt_regs *kdb_current_regs;
44379 +#ifdef CONFIG_KDB_OFF
44380 +int kdb_on = 0; /* Default is off */
44382 +int kdb_on = 1; /* Default is on */
44383 +#endif /* CONFIG_KDB_OFF */
44385 +const char *kdb_diemsg;
44386 +static int kdb_go_count;
44387 +#ifdef CONFIG_KDB_CONTINUE_CATASTROPHIC
44388 +static unsigned int kdb_continue_catastrophic = CONFIG_KDB_CONTINUE_CATASTROPHIC;
44390 +static unsigned int kdb_continue_catastrophic = 0;
44393 +#ifdef kdba_setjmp
44395 + * Must have a setjmp buffer per CPU. Switching cpus will
44396 + * cause the jump buffer to be setup for the new cpu, and
44397 + * subsequent switches (and pager aborts) will use the
44398 + * appropriate per-processor values.
44400 +kdb_jmp_buf *kdbjmpbuf;
44401 +#endif /* kdba_setjmp */
44404 + * kdb_commands describes the available commands.
44406 +static kdbtab_t *kdb_commands;
44407 +static int kdb_max_commands;
44409 +typedef struct _kdbmsg {
44410 + int km_diag; /* kdb diagnostic */
44411 + char *km_msg; /* Corresponding message text */
44414 +#define KDBMSG(msgnum, text) \
44415 + { KDB_##msgnum, text }
44417 +static kdbmsg_t kdbmsgs[] = {
44418 + KDBMSG(NOTFOUND,"Command Not Found"),
44419 + KDBMSG(ARGCOUNT, "Improper argument count, see usage."),
44420 + KDBMSG(BADWIDTH, "Illegal value for BYTESPERWORD use 1, 2, 4 or 8, 8 is only allowed on 64 bit systems"),
44421 + KDBMSG(BADRADIX, "Illegal value for RADIX use 8, 10 or 16"),
44422 + KDBMSG(NOTENV, "Cannot find environment variable"),
44423 + KDBMSG(NOENVVALUE, "Environment variable should have value"),
44424 + KDBMSG(NOTIMP, "Command not implemented"),
44425 + KDBMSG(ENVFULL, "Environment full"),
44426 + KDBMSG(ENVBUFFULL, "Environment buffer full"),
44427 + KDBMSG(TOOMANYBPT, "Too many breakpoints defined"),
44428 +#ifdef CONFIG_CPU_XSCALE
44429 + KDBMSG(TOOMANYDBREGS, "More breakpoints than ibcr registers defined"),
44431 + KDBMSG(TOOMANYDBREGS, "More breakpoints than db registers defined"),
44433 + KDBMSG(DUPBPT, "Duplicate breakpoint address"),
44434 + KDBMSG(BPTNOTFOUND, "Breakpoint not found"),
44435 + KDBMSG(BADMODE, "Invalid IDMODE"),
44436 + KDBMSG(BADINT, "Illegal numeric value"),
44437 + KDBMSG(INVADDRFMT, "Invalid symbolic address format"),
44438 + KDBMSG(BADREG, "Invalid register name"),
44439 + KDBMSG(BADCPUNUM, "Invalid cpu number"),
44440 + KDBMSG(BADLENGTH, "Invalid length field"),
44441 + KDBMSG(NOBP, "No Breakpoint exists"),
44442 + KDBMSG(BADADDR, "Invalid address"),
44446 +static const int __nkdb_err = sizeof(kdbmsgs) / sizeof(kdbmsg_t);
44450 + * Initial environment. This is all kept static and local to
44451 + * this file. We don't want to rely on the memory allocation
44452 + * mechanisms in the kernel, so we use a very limited allocate-only
44453 + * heap for new and altered environment variables. The entire
44454 + * environment is limited to a fixed number of entries (add more
44455 + * to __env[] if required) and a fixed amount of heap (add more to
44456 + * KDB_ENVBUFSIZE if required).
44459 +static char *__env[] = {
44460 +#if defined(CONFIG_SMP)
44461 + "PROMPT=[%d]kdb> ",
44462 + "MOREPROMPT=[%d]more> ",
44465 + "MOREPROMPT=more> ",
44470 + "MDCOUNT=8", /* lines of md output */
44471 + "BTARGS=9", /* 9 possible args in bt */
44472 + KDB_PLATFORM_ENV,
44500 +static const int __nenv = (sizeof(__env) / sizeof(char *));
44503 + * kdb_serial_str is the sequence that the user must enter on a serial
44504 + * console to invoke kdb. It can be a single character such as "\001"
44505 + * (control-A) or multiple characters such as "\eKDB". NOTE: All except the
44506 + * last character are passed through to the application reading from the serial
44509 + * I tried to make the sequence a CONFIG_ option but most of CML1 cannot cope
44510 + * with '\' in strings. CML2 would have been able to do it but we lost CML2.
44513 +const char kdb_serial_str[] = "\eKDB";
44514 +EXPORT_SYMBOL(kdb_serial_str);
44516 +struct task_struct *
44517 +kdb_curr_task(int cpu)
44519 + struct task_struct *p = curr_task(cpu);
44520 +#ifdef _TIF_MCA_INIT
44521 + struct kdb_running_process *krp = kdb_running_process + cpu;
44522 + if ((task_thread_info(p)->flags & _TIF_MCA_INIT) && krp->p)
44531 + * This function will return the character string value of
44532 + * an environment variable.
44535 + * match A character string representing an environment variable.
44539 + * NULL No environment variable matches 'match'
44540 + * char* Pointer to string value of environment variable.
44542 + * No locking considerations required.
44546 +kdbgetenv(const char *match)
44548 + char **ep = __env;
44549 + int matchlen = strlen(match);
44552 + for(i=0; i<__nenv; i++) {
44555 + if (!e) continue;
44557 + if ((strncmp(match, e, matchlen) == 0)
44558 + && ((e[matchlen] == '\0')
44559 + ||(e[matchlen] == '='))) {
44560 + char *cp = strchr(e, '=');
44561 + return (cp ? ++cp :"");
44570 + * This function is used to allocate bytes for environment entries.
44573 + * match A character string representing a numeric value
44575 + * *value the unsigned long represntation of the env variable 'match'
44577 + * Zero on success, a kdb diagnostic on failure.
44579 + * No locking considerations required. Must be called with all
44580 + * processors halted.
44582 + * We use a static environment buffer (envbuffer) to hold the values
44583 + * of dynamically generated environment variables (see kdb_set). Buffer
44584 + * space once allocated is never free'd, so over time, the amount of space
44585 + * (currently 512 bytes) will be exhausted if env variables are changed
44589 +kdballocenv(size_t bytes)
44591 +#define KDB_ENVBUFSIZE 512
44592 + static char envbuffer[KDB_ENVBUFSIZE];
44593 + static int envbufsize;
44596 + if ((KDB_ENVBUFSIZE - envbufsize) >= bytes) {
44597 + ep = &envbuffer[envbufsize];
44598 + envbufsize += bytes;
44606 + * This function will return the value of an unsigned long-valued
44607 + * environment variable.
44610 + * match A character string representing a numeric value
44612 + * *value the unsigned long represntation of the env variable 'match'
44614 + * Zero on success, a kdb diagnostic on failure.
44616 + * No locking considerations required.
44621 +kdbgetulenv(const char *match, unsigned long *value)
44625 + ep = kdbgetenv(match);
44626 + if (!ep) return KDB_NOTENV;
44627 + if (strlen(ep) == 0) return KDB_NOENVVALUE;
44629 + *value = simple_strtoul(ep, NULL, 0);
44637 + * This function will return the value of an integer-valued
44638 + * environment variable.
44641 + * match A character string representing an integer-valued env variable
44643 + * *value the integer representation of the environment variable 'match'
44645 + * Zero on success, a kdb diagnostic on failure.
44647 + * No locking considerations required.
44652 +kdbgetintenv(const char *match, int *value) {
44653 + unsigned long val;
44656 + diag = kdbgetulenv(match, &val);
44658 + *value = (int) val;
44666 + * This function will convert a numeric string
44667 + * into an unsigned long value.
44670 + * arg A character string representing a numeric value
44672 + * *value the unsigned long represntation of arg.
44674 + * Zero on success, a kdb diagnostic on failure.
44676 + * No locking considerations required.
44681 +kdbgetularg(const char *arg, unsigned long *value)
44684 + unsigned long val;
44686 + val = simple_strtoul(arg, &endp, 0);
44688 + if (endp == arg) {
44690 + * Try base 16, for us folks too lazy to type the
44693 + val = simple_strtoul(arg, &endp, 16);
44695 + return KDB_BADINT;
44706 + * This function implements the 'set' command. Alter an existing
44707 + * environment variable or create a new one.
44710 + * argc argument count
44711 + * argv argument vector
44715 + * zero for success, a kdb diagnostic if error
44722 +kdb_set(int argc, const char **argv)
44726 + size_t varlen, vallen;
44729 + * we can be invoked two ways:
44730 + * set var=value argv[1]="var", argv[2]="value"
44731 + * set var = value argv[1]="var", argv[2]="=", argv[3]="value"
44732 + * - if the latter, shift 'em down.
44735 + argv[2] = argv[3];
44740 + return KDB_ARGCOUNT;
44743 + * Check for internal variables
44745 + if (strcmp(argv[1], "KDBDEBUG") == 0) {
44746 + unsigned int debugflags;
44749 + debugflags = simple_strtoul(argv[2], &cp, 0);
44750 + if (cp == argv[2] || debugflags & ~KDB_DEBUG_FLAG_MASK) {
44751 + kdb_printf("kdb: illegal debug flags '%s'\n",
44755 + kdb_flags = (kdb_flags & ~(KDB_DEBUG_FLAG_MASK << KDB_DEBUG_FLAG_SHIFT))
44756 + | (debugflags << KDB_DEBUG_FLAG_SHIFT);
44762 + * Tokenizer squashed the '=' sign. argv[1] is variable
44763 + * name, argv[2] = value.
44765 + varlen = strlen(argv[1]);
44766 + vallen = strlen(argv[2]);
44767 + ep = kdballocenv(varlen + vallen + 2);
44768 + if (ep == (char *)0)
44769 + return KDB_ENVBUFFULL;
44771 + sprintf(ep, "%s=%s", argv[1], argv[2]);
44773 + ep[varlen+vallen+1]='\0';
44775 + for(i=0; i<__nenv; i++) {
44777 + && ((strncmp(__env[i], argv[1], varlen)==0)
44778 + && ((__env[i][varlen] == '\0')
44779 + || (__env[i][varlen] == '=')))) {
44786 + * Wasn't existing variable. Fit into slot.
44788 + for(i=0; i<__nenv-1; i++) {
44789 + if (__env[i] == (char *)0) {
44795 + return KDB_ENVFULL;
44799 +kdb_check_regs(void)
44801 + if (!kdb_current_regs) {
44802 + kdb_printf("No current kdb registers."
44803 + " You may need to select another task\n");
44804 + return KDB_BADREG;
44812 + * This function is responsible for parsing an
44813 + * address-expression and returning the value of
44814 + * the expression, symbol name, and offset to the caller.
44816 + * The argument may consist of a numeric value (decimal or
44817 + * hexidecimal), a symbol name, a register name (preceeded
44818 + * by the percent sign), an environment variable with a numeric
44819 + * value (preceeded by a dollar sign) or a simple arithmetic
44820 + * expression consisting of a symbol name, +/-, and a numeric
44821 + * constant value (offset).
44824 + * argc - count of arguments in argv
44825 + * argv - argument vector
44826 + * *nextarg - index to next unparsed argument in argv[]
44827 + * regs - Register state at time of KDB entry
44829 + * *value - receives the value of the address-expression
44830 + * *offset - receives the offset specified, if any
44831 + * *name - receives the symbol name, if any
44832 + * *nextarg - index to next unparsed argument in argv[]
44835 + * zero is returned on success, a kdb diagnostic code is
44836 + * returned on error.
44839 + * No locking requirements.
44846 +kdbgetaddrarg(int argc, const char **argv, int *nextarg,
44847 + kdb_machreg_t *value, long *offset,
44850 + kdb_machreg_t addr;
44851 + unsigned long off = 0;
44856 + char symbol = '\0';
44858 + kdb_symtab_t symtab;
44861 + * Process arguments which follow the following syntax:
44863 + * symbol | numeric-address [+/- numeric-offset]
44865 + * $environment-variable
44868 + if (*nextarg > argc) {
44869 + return KDB_ARGCOUNT;
44872 + symname = (char *)argv[*nextarg];
44875 + * If there is no whitespace between the symbol
44876 + * or address and the '+' or '-' symbols, we
44877 + * remember the character and replace it with a
44878 + * null so the symbol/value can be properly parsed
44880 + if ((cp = strpbrk(symname, "+-")) != NULL) {
44885 + if (symname[0] == '$') {
44886 + diag = kdbgetulenv(&symname[1], &addr);
44889 + } else if (symname[0] == '%') {
44890 + if ((diag = kdb_check_regs()))
44892 + diag = kdba_getregcontents(&symname[1], kdb_current_regs, &addr);
44896 + found = kdbgetsymval(symname, &symtab);
44898 + addr = symtab.sym_start;
44900 + diag = kdbgetularg(argv[*nextarg], &addr);
44907 + found = kdbnearsym(addr, &symtab);
44915 + if (offset && name && *name)
44916 + *offset = addr - symtab.sym_start;
44918 + if ((*nextarg > argc)
44919 + && (symbol == '\0'))
44923 + * check for +/- and offset
44926 + if (symbol == '\0') {
44927 + if ((argv[*nextarg][0] != '+')
44928 + && (argv[*nextarg][0] != '-')) {
44930 + * Not our argument. Return.
44934 + positive = (argv[*nextarg][0] == '+');
44938 + positive = (symbol == '+');
44941 + * Now there must be an offset!
44943 + if ((*nextarg > argc)
44944 + && (symbol == '\0')) {
44945 + return KDB_INVADDRFMT;
44949 + cp = (char *)argv[*nextarg];
44953 + diag = kdbgetularg(cp, &off);
44970 +kdb_cmderror(int diag)
44975 + kdb_printf("no error detected\n");
44979 + for(i=0; i<__nkdb_err; i++) {
44980 + if (kdbmsgs[i].km_diag == diag) {
44981 + kdb_printf("diag: %d: %s\n", diag, kdbmsgs[i].km_msg);
44986 + kdb_printf("Unknown diag %d\n", -diag);
44990 + * kdb_defcmd, kdb_defcmd2
44992 + * This function implements the 'defcmd' command which defines one
44993 + * command as a set of other commands, terminated by endefcmd.
44994 + * kdb_defcmd processes the initial 'defcmd' command, kdb_defcmd2
44995 + * is invoked from kdb_parse for the following commands until
44999 + * argc argument count
45000 + * argv argument vector
45004 + * zero for success, a kdb diagnostic if error
45010 +struct defcmd_set {
45018 +static struct defcmd_set *defcmd_set;
45019 +static int defcmd_set_count;
45020 +static int defcmd_in_progress;
45022 +/* Forward references */
45023 +static int kdb_exec_defcmd(int argc, const char **argv);
45026 +kdb_defcmd2(const char *cmdstr, const char *argv0)
45028 + struct defcmd_set *s = defcmd_set + defcmd_set_count - 1;
45029 + char **save_command = s->command;
45030 + if (strcmp(argv0, "endefcmd") == 0) {
45031 + defcmd_in_progress = 0;
45035 + kdb_register(s->name, kdb_exec_defcmd, s->usage, s->help, 0);
45039 + return KDB_NOTIMP;
45040 + s->command = kmalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
45041 + if (!s->command) {
45042 + kdb_printf("Could not allocate new kdb_defcmd table for %s\n", cmdstr);
45044 + return KDB_NOTIMP;
45046 + memcpy(s->command, save_command, s->count * sizeof(*(s->command)));
45047 + s->command[s->count++] = kdb_strdup(cmdstr, GFP_KDB);
45048 + kfree(save_command);
45053 +kdb_defcmd(int argc, const char **argv)
45055 + struct defcmd_set *save_defcmd_set = defcmd_set, *s;
45056 + if (defcmd_in_progress) {
45057 + kdb_printf("kdb: nested defcmd detected, assuming missing endefcmd\n");
45058 + kdb_defcmd2("endefcmd", "endefcmd");
45062 + for (s = defcmd_set; s < defcmd_set + defcmd_set_count; ++s) {
45063 + kdb_printf("defcmd %s \"%s\" \"%s\"\n", s->name, s->usage, s->help);
45064 + for (i = 0; i < s->count; ++i)
45065 + kdb_printf("%s", s->command[i]);
45066 + kdb_printf("endefcmd\n");
45071 + return KDB_ARGCOUNT;
45072 + defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set), GFP_KDB);
45073 + if (!defcmd_set) {
45074 + kdb_printf("Could not allocate new defcmd_set entry for %s\n", argv[1]);
45075 + defcmd_set = save_defcmd_set;
45076 + return KDB_NOTIMP;
45078 + memcpy(defcmd_set, save_defcmd_set, defcmd_set_count * sizeof(*defcmd_set));
45079 + kfree(save_defcmd_set);
45080 + s = defcmd_set + defcmd_set_count;
45081 + memset(s, 0, sizeof(*s));
45083 + s->name = kdb_strdup(argv[1], GFP_KDB);
45084 + s->usage = kdb_strdup(argv[2], GFP_KDB);
45085 + s->help = kdb_strdup(argv[3], GFP_KDB);
45086 + if (s->usage[0] == '"') {
45087 + strcpy(s->usage, s->usage+1);
45088 + s->usage[strlen(s->usage)-1] = '\0';
45090 + if (s->help[0] == '"') {
45091 + strcpy(s->help, s->help+1);
45092 + s->help[strlen(s->help)-1] = '\0';
45094 + ++defcmd_set_count;
45095 + defcmd_in_progress = 1;
45100 + * kdb_exec_defcmd
45102 + * Execute the set of commands associated with this defcmd name.
45105 + * argc argument count
45106 + * argv argument vector
45110 + * zero for success, a kdb diagnostic if error
45117 +kdb_exec_defcmd(int argc, const char **argv)
45120 + struct defcmd_set *s;
45122 + return KDB_ARGCOUNT;
45123 + for (s = defcmd_set, i = 0; i < defcmd_set_count; ++i, ++s) {
45124 + if (strcmp(s->name, argv[0]) == 0)
45127 + if (i == defcmd_set_count) {
45128 + kdb_printf("kdb_exec_defcmd: could not find commands for %s\n", argv[0]);
45129 + return KDB_NOTIMP;
45131 + for (i = 0; i < s->count; ++i) {
45132 + /* Recursive use of kdb_parse, do not use argv after this point */
45134 + kdb_printf("[%s]kdb> %s\n", s->name, s->command[i]);
45135 + if ((ret = kdb_parse(s->command[i])))
45141 +/* Command history */
45142 +#define KDB_CMD_HISTORY_COUNT 32
45143 +#define CMD_BUFLEN 200 /* kdb_printf: max printline size == 256 */
45144 +static unsigned int cmd_head=0, cmd_tail=0;
45145 +static unsigned int cmdptr;
45146 +static char cmd_hist[KDB_CMD_HISTORY_COUNT][CMD_BUFLEN];
45147 +static char cmd_cur[CMD_BUFLEN];
45152 + * Parse the command line, search the command table for a
45153 + * matching command and invoke the command function.
45154 + * This function may be called recursively, if it is, the second call
45155 + * will overwrite argv and cbuf. It is the caller's responsibility to
45156 + * save their argv if they recursively call kdb_parse().
45159 + * cmdstr The input command line to be parsed.
45160 + * regs The registers at the time kdb was entered.
45164 + * Zero for success, a kdb diagnostic if failure.
45168 + * Limited to 20 tokens.
45170 + * Real rudimentary tokenization. Basically only whitespace
45171 + * is considered a token delimeter (but special consideration
45172 + * is taken of the '=' sign as used by the 'set' command).
45174 + * The algorithm used to tokenize the input string relies on
45175 + * there being at least one whitespace (or otherwise useless)
45176 + * character between tokens as the character immediately following
45177 + * the token is altered in-place to a null-byte to terminate the
45181 +#define MAXARGC 20
45184 +kdb_parse(const char *cmdstr)
45186 + static char *argv[MAXARGC];
45187 + static int argc = 0;
45188 + static char cbuf[CMD_BUFLEN+2];
45190 + char *cpp, quoted;
45192 + int i, escaped, ignore_errors = 0;
45195 + * First tokenize the command string.
45199 + if (KDB_FLAG(CMD_INTERRUPT)) {
45200 + /* Previous command was interrupted, newline must not repeat the command */
45201 + KDB_FLAG_CLEAR(CMD_INTERRUPT);
45202 + argc = 0; /* no repeat */
45205 + if (*cp != '\n' && *cp != '\0') {
45209 + /* skip whitespace */
45210 + while (isspace(*cp)) cp++;
45211 + if ((*cp == '\0') || (*cp == '\n') || (*cp == '#' && !defcmd_in_progress))
45213 + if (cpp >= cbuf + CMD_BUFLEN) {
45214 + kdb_printf("kdb_parse: command buffer overflow, command ignored\n%s\n", cmdstr);
45215 + return KDB_NOTFOUND;
45217 + if (argc >= MAXARGC - 1) {
45218 + kdb_printf("kdb_parse: too many arguments, command ignored\n%s\n", cmdstr);
45219 + return KDB_NOTFOUND;
45221 + argv[argc++] = cpp;
45224 + /* Copy to next unquoted and unescaped whitespace or '=' */
45225 + while (*cp && *cp != '\n' && (escaped || quoted || !isspace(*cp))) {
45226 + if (cpp >= cbuf + CMD_BUFLEN)
45233 + if (*cp == '\\') {
45238 + if (*cp == quoted) {
45240 + } else if (*cp == '\'' || *cp == '"') {
45243 + if ((*cpp = *cp++) == '=' && !quoted)
45247 + *cpp++ = '\0'; /* Squash a ws or '=' character */
45252 + if (defcmd_in_progress) {
45253 + int result = kdb_defcmd2(cmdstr, argv[0]);
45254 + if (!defcmd_in_progress) {
45255 + argc = 0; /* avoid repeat on endefcmd */
45256 + *(argv[0]) = '\0';
45260 + if (argv[0][0] == '-' && argv[0][1] && (argv[0][1] < '0' || argv[0][1] > '9')) {
45261 + ignore_errors = 1;
45265 + for(tp=kdb_commands, i=0; i < kdb_max_commands; i++,tp++) {
45266 + if (tp->cmd_name) {
45268 + * If this command is allowed to be abbreviated,
45269 + * check to see if this is it.
45272 + if (tp->cmd_minlen
45273 + && (strlen(argv[0]) <= tp->cmd_minlen)) {
45274 + if (strncmp(argv[0],
45276 + tp->cmd_minlen) == 0) {
45281 + if (strcmp(argv[0], tp->cmd_name)==0) {
45288 + * If we don't find a command by this name, see if the first
45289 + * few characters of this match any of the known commands.
45290 + * e.g., md1c20 should match md.
45292 + if (i == kdb_max_commands) {
45293 + for(tp=kdb_commands, i=0; i < kdb_max_commands; i++,tp++) {
45294 + if (tp->cmd_name) {
45295 + if (strncmp(argv[0],
45297 + strlen(tp->cmd_name))==0) {
45304 + if (i < kdb_max_commands) {
45306 + KDB_STATE_SET(CMD);
45307 + result = (*tp->cmd_func)(argc-1,
45308 + (const char**)argv);
45309 + if (result && ignore_errors && result > KDB_CMD_GO)
45311 + KDB_STATE_CLEAR(CMD);
45312 + switch (tp->cmd_repeat) {
45313 + case KDB_REPEAT_NONE:
45316 + *(argv[0]) = '\0';
45318 + case KDB_REPEAT_NO_ARGS:
45321 + *(argv[1]) = '\0';
45323 + case KDB_REPEAT_WITH_ARGS:
45330 + * If the input with which we were presented does not
45331 + * map to an existing command, attempt to parse it as an
45332 + * address argument and display the result. Useful for
45333 + * obtaining the address of a variable, or the nearest symbol
45334 + * to an address contained in a register.
45337 + kdb_machreg_t value;
45338 + char *name = NULL;
45342 + if (kdbgetaddrarg(0, (const char **)argv, &nextarg,
45343 + &value, &offset, &name)) {
45344 + return KDB_NOTFOUND;
45347 + kdb_printf("%s = ", argv[0]);
45348 + kdb_symbol_print(value, NULL, KDB_SP_DEFAULT);
45349 + kdb_printf("\n");
45356 +handle_ctrl_cmd(char *cmd)
45361 + /* initial situation */
45362 + if (cmd_head == cmd_tail) return 0;
45366 + if (cmdptr != cmd_tail)
45367 + cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT;
45368 + strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
45371 + if (cmdptr != cmd_head)
45372 + cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT;
45373 + strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
45382 + * Call the dump() function if the kernel is configured for LKCD.
45388 + * None. dump() may or may not return.
45397 +#if defined(CONFIG_LKCD_DUMP) || defined(CONFIG_LKCD_DUMP_MODULE)
45398 + kdb_printf("Forcing dump (if configured)\n");
45399 + console_loglevel = 8; /* to see the dump messages */
45400 + dump("kdb_do_dump");
45407 + * This function implements the 'reboot' command. Reboot the system
45411 + * argc argument count
45412 + * argv argument vector
45416 + * zero for success, a kdb diagnostic if error
45420 + * Shouldn't return from this function.
45424 +kdb_reboot(int argc, const char **argv)
45426 + emergency_restart();
45427 + kdb_printf("Hmm, kdb_reboot did not reboot, spinning here\n");
45434 +kdb_quiet(int reason)
45436 + return (reason == KDB_REASON_CPU_UP || reason == KDB_REASON_SILENT);
45442 + * The main code for kdb. This routine is invoked on a specific
45443 + * processor, it is not global. The main kdb() routine ensures
45444 + * that only one processor at a time is in this routine. This
45445 + * code is called with the real reason code on the first entry
45446 + * to a kdb session, thereafter it is called with reason SWITCH,
45447 + * even if the user goes back to the original cpu.
45450 + * reason The reason KDB was invoked
45451 + * error The hardware-defined error code
45452 + * regs The exception frame at time of fault/breakpoint. NULL
45453 + * for reason SILENT or CPU_UP, otherwise valid.
45454 + * db_result Result code from the break or debug point.
45456 + * 0 KDB was invoked for an event which it wasn't responsible
45457 + * 1 KDB handled the event for which it was invoked.
45458 + * KDB_CMD_GO User typed 'go'.
45459 + * KDB_CMD_CPU User switched to another cpu.
45460 + * KDB_CMD_SS Single step.
45461 + * KDB_CMD_SSB Single step until branch.
45469 +kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, kdb_dbtrap_t db_result)
45473 + struct task_struct *kdb_current = kdb_curr_task(smp_processor_id());
45475 + /* If kdb has been entered for an event which has been/will be
45476 + * recovered then silently return. We have to get this far into kdb in
45477 + * order to synchronize all the cpus, typically only one cpu (monarch)
45478 + * knows that the event is recoverable but the other cpus (slaves) may
45479 + * also be driven into kdb before that decision is made by the monarch.
45481 + * To pause in kdb even for recoverable events, 'set RECOVERY_PAUSE 1'
45483 + KDB_DEBUG_STATE("kdb_local 1", reason);
45484 + if (reason == KDB_REASON_ENTER
45485 + && KDB_FLAG(RECOVERY)
45486 + && !KDB_FLAG(CATASTROPHIC)) {
45487 + int recovery_pause = 0;
45488 + kdbgetintenv("RECOVERY_PAUSE", &recovery_pause);
45489 + if (recovery_pause == 0)
45490 + reason = KDB_REASON_SILENT;
45492 + kdb_printf("%s: Recoverable error detected but"
45493 + " RECOVERY_PAUSE is set, staying in KDB\n",
45497 + KDB_DEBUG_STATE("kdb_local 2", reason);
45498 + kdb_go_count = 0;
45499 + if (kdb_quiet(reason)) {
45501 + } else if (reason == KDB_REASON_DEBUG) {
45502 + /* special case below */
45504 + kdb_printf("\nEntering kdb (current=0x%p, pid %d) ", kdb_current, kdb_current->pid);
45505 +#if defined(CONFIG_SMP)
45506 + kdb_printf("on processor %d ", smp_processor_id());
45510 + switch (reason) {
45511 + case KDB_REASON_DEBUG:
45514 + * If re-entering kdb after a single step
45515 + * command, don't print the message.
45517 + switch(db_result) {
45519 + kdb_printf("\nEntering kdb (0x%p, pid %d) ", kdb_current, kdb_current->pid);
45520 +#if defined(CONFIG_SMP)
45521 + kdb_printf("on processor %d ", smp_processor_id());
45523 + kdb_printf("due to Debug @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
45527 + * In the midst of ssb command. Just return.
45529 + KDB_DEBUG_STATE("kdb_local 3", reason);
45530 + return KDB_CMD_SSB; /* Continue with SSB command */
45535 + case KDB_DB_SSBPT:
45536 + KDB_DEBUG_STATE("kdb_local 4", reason);
45537 + return 1; /* kdba_db_trap did the work */
45539 + kdb_printf("kdb: Bad result from kdba_db_trap: %d\n",
45546 + case KDB_REASON_ENTER:
45547 + if (KDB_STATE(KEYBOARD))
45548 + kdb_printf("due to Keyboard Entry\n");
45550 + kdb_printf("due to KDB_ENTER()\n");
45552 + case KDB_REASON_KEYBOARD:
45553 + KDB_STATE_SET(KEYBOARD);
45554 + kdb_printf("due to Keyboard Entry\n");
45556 + case KDB_REASON_ENTER_SLAVE: /* drop through, slaves only get released via cpu switch */
45557 + case KDB_REASON_SWITCH:
45558 + kdb_printf("due to cpu switch\n");
45559 + if (KDB_STATE(GO_SWITCH)) {
45560 + KDB_STATE_CLEAR(GO_SWITCH);
45561 + KDB_DEBUG_STATE("kdb_local 5", reason);
45562 + return KDB_CMD_GO;
45565 + case KDB_REASON_OOPS:
45566 + kdb_printf("Oops: %s\n", kdb_diemsg);
45567 + kdb_printf("due to oops @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
45568 + kdba_dumpregs(regs, NULL, NULL);
45570 + case KDB_REASON_NMI:
45571 + kdb_printf("due to NonMaskable Interrupt @ " kdb_machreg_fmt "\n",
45572 + kdba_getpc(regs));
45573 + kdba_dumpregs(regs, NULL, NULL);
45575 + case KDB_REASON_BREAK:
45576 + kdb_printf("due to Breakpoint @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
45578 + * Determine if this breakpoint is one that we
45579 + * are interested in.
45581 + if (db_result != KDB_DB_BPT) {
45582 + kdb_printf("kdb: error return from kdba_bp_trap: %d\n", db_result);
45583 + KDB_DEBUG_STATE("kdb_local 6", reason);
45584 + return 0; /* Not for us, dismiss it */
45587 + case KDB_REASON_RECURSE:
45588 + kdb_printf("due to Recursion @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
45590 + case KDB_REASON_CPU_UP:
45591 + case KDB_REASON_SILENT:
45592 + KDB_DEBUG_STATE("kdb_local 7", reason);
45593 + if (reason == KDB_REASON_CPU_UP)
45595 + return KDB_CMD_GO; /* Silent entry, silent exit */
45598 + kdb_printf("kdb: unexpected reason code: %d\n", reason);
45599 + KDB_DEBUG_STATE("kdb_local 8", reason);
45600 + return 0; /* Not for us, dismiss it */
45603 + kdba_local_arch_setup();
45605 + kdba_set_current_task(kdb_current);
45609 + * Initialize pager context.
45611 + kdb_nextline = 1;
45612 + KDB_STATE_CLEAR(SUPPRESS);
45613 +#ifdef kdba_setjmp
45615 + * Use kdba_setjmp/kdba_longjmp to break out of
45616 + * the pager early and to attempt to recover from kdb errors.
45618 + KDB_STATE_CLEAR(LONGJMP);
45620 + if (kdba_setjmp(&kdbjmpbuf[smp_processor_id()])) {
45621 + /* Command aborted (usually in pager) */
45625 + KDB_STATE_SET(LONGJMP);
45627 +#endif /* kdba_setjmp */
45629 + cmdbuf = cmd_cur;
45631 + *(cmd_hist[cmd_head])='\0';
45633 + if (KDB_FLAG(ONLY_DO_DUMP)) {
45634 + /* kdb is off but a catastrophic error requires a dump.
45635 + * Take the dump and reboot.
45636 + * Turn on logging so the kdb output appears in the log
45637 + * buffer in the dump.
45639 + const char *setargs[] = { "set", "LOGGING", "1" };
45640 + kdb_set(2, setargs);
45642 + kdb_reboot(0, NULL);
45647 +#if defined(CONFIG_SMP)
45648 + snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"), smp_processor_id());
45650 + snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"));
45652 + if (defcmd_in_progress)
45653 + strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
45656 + * Fetch command from keyboard
45658 + cmdbuf = kdb_getstr(cmdbuf, CMD_BUFLEN, kdb_prompt_str);
45659 + if (*cmdbuf != '\n') {
45660 + if (*cmdbuf < 32) {
45661 + if(cmdptr == cmd_head) {
45662 + strncpy(cmd_hist[cmd_head], cmd_cur, CMD_BUFLEN);
45663 + *(cmd_hist[cmd_head]+strlen(cmd_hist[cmd_head])-1) = '\0';
45665 + if(!handle_ctrl_cmd(cmdbuf))
45666 + *(cmd_cur+strlen(cmd_cur)-1) = '\0';
45667 + cmdbuf = cmd_cur;
45668 + goto do_full_getstr;
45671 + strncpy(cmd_hist[cmd_head], cmd_cur, CMD_BUFLEN);
45673 + cmd_head = (cmd_head+1) % KDB_CMD_HISTORY_COUNT;
45674 + if (cmd_head == cmd_tail) cmd_tail = (cmd_tail+1) % KDB_CMD_HISTORY_COUNT;
45678 + cmdptr = cmd_head;
45679 + diag = kdb_parse(cmdbuf);
45680 + if (diag == KDB_NOTFOUND) {
45681 + kdb_printf("Unknown kdb command: '%s'\n", cmdbuf);
45684 + if (diag == KDB_CMD_GO
45685 + || diag == KDB_CMD_CPU
45686 + || diag == KDB_CMD_SS
45687 + || diag == KDB_CMD_SSB)
45691 + kdb_cmderror(diag);
45694 + kdba_local_arch_cleanup();
45696 + KDB_DEBUG_STATE("kdb_local 9", diag);
45702 + * kdb_print_state
45704 + * Print the state data for the current processor for debugging.
45707 + * text Identifies the debug point
45708 + * value Any integer value to be printed, e.g. reason code.
45717 +void kdb_print_state(const char *text, int value)
45719 + kdb_printf("state: %s cpu %d value %d initial %d state %x\n",
45720 + text, smp_processor_id(), value, kdb_initial_cpu, kdb_state[smp_processor_id()]);
45724 + * kdb_previous_event
45726 + * Return a count of cpus that are leaving kdb, i.e. the number
45727 + * of processors that are still handling the previous kdb event.
45732 + * Count of cpus in previous event.
45740 +kdb_previous_event(void)
45742 + int i, leaving = 0;
45743 + for (i = 0; i < NR_CPUS; ++i) {
45744 + if (KDB_STATE_CPU(LEAVING, i))
45751 + * kdb_wait_for_cpus
45753 + * Invoked once at the start of a kdb event, from the controlling cpu. Wait a
45754 + * short period for the other cpus to enter kdb state.
45766 +int kdb_wait_for_cpus_secs;
45769 +kdb_wait_for_cpus(void)
45772 + int online = 0, kdb_data = 0, prev_kdb_data = 0, c, time;
45774 + for (time = 0; time < kdb_wait_for_cpus_secs; ++time) {
45777 + for_each_online_cpu(c) {
45779 + if (kdb_running_process[c].seqno >= kdb_seqno - 1)
45782 + if (online == kdb_data)
45784 + if (prev_kdb_data != kdb_data) {
45785 + kdb_nextline = 0; /* no prompt yet */
45786 + kdb_printf(" %d out of %d cpus in kdb, waiting for the rest, timeout in %d second(s)\n",
45787 + kdb_data, online, kdb_wait_for_cpus_secs - time);
45788 + prev_kdb_data = kdb_data;
45790 + touch_nmi_watchdog();
45792 + /* Architectures may want to send a more forceful interrupt */
45793 + if (time == min(kdb_wait_for_cpus_secs / 2, 5))
45794 + kdba_wait_for_cpus();
45795 + if (time % 4 == 0)
45799 + int wait = online - kdb_data;
45801 + kdb_printf("All cpus are now in kdb\n");
45803 + kdb_printf("%d cpu%s not in kdb, %s state is unknown\n",
45805 + wait == 1 ? " is" : "s are",
45806 + wait == 1 ? "its" : "their");
45808 +#endif /* CONFIG_SMP */
45814 + * The main kdb loop. After initial setup and assignment of the controlling
45815 + * cpu, all cpus are in this loop. One cpu is in control and will issue the kdb
45816 + * prompt, the others will spin until 'go' or cpu switch.
45818 + * To get a consistent view of the kernel stacks for all processes, this routine
45819 + * is invoked from the main kdb code via an architecture specific routine.
45820 + * kdba_main_loop is responsible for making the kernel stacks consistent for all
45821 + * processes, there should be no difference between a blocked process and a
45822 + * running process as far as kdb is concerned.
45825 + * reason The reason KDB was invoked
45826 + * error The hardware-defined error code
45827 + * reason2 kdb's current reason code. Initially error but can change
45828 + * acording to kdb state.
45829 + * db_result Result code from break or debug point.
45830 + * regs The exception frame at time of fault/breakpoint. If reason
45831 + * is SILENT or CPU_UP then regs is NULL, otherwise it
45832 + * should always be valid.
45834 + * 0 KDB was invoked for an event which it wasn't responsible
45835 + * 1 KDB handled the event for which it was invoked.
45843 +kdb_main_loop(kdb_reason_t reason, kdb_reason_t reason2, int error,
45844 + kdb_dbtrap_t db_result, struct pt_regs *regs)
45847 + /* Stay in kdb() until 'go', 'ss[b]' or an error */
45850 + * All processors except the one that is in control
45851 + * will spin here.
45853 + KDB_DEBUG_STATE("kdb_main_loop 1", reason);
45854 + while (KDB_STATE(HOLD_CPU)) {
45855 + /* state KDB is turned off by kdb_cpu to see if the
45856 + * other cpus are still live, each cpu in this loop
45857 + * turns it back on.
45859 + if (!KDB_STATE(KDB)) {
45860 + KDB_STATE_SET(KDB);
45863 + KDB_STATE_CLEAR(SUPPRESS);
45864 + KDB_DEBUG_STATE("kdb_main_loop 2", reason);
45865 + if (KDB_STATE(LEAVING))
45866 + break; /* Another cpu said 'go' */
45868 + if (!kdb_quiet(reason))
45869 + kdb_wait_for_cpus();
45870 + /* Still using kdb, this processor is in control */
45871 + result = kdb_local(reason2, error, regs, db_result);
45872 + KDB_DEBUG_STATE("kdb_main_loop 3", result);
45874 + if (result == KDB_CMD_CPU) {
45875 + /* Cpu switch, hold the current cpu, release the target one. */
45876 + reason2 = KDB_REASON_SWITCH;
45877 + KDB_STATE_SET(HOLD_CPU);
45878 + KDB_STATE_CLEAR_CPU(HOLD_CPU, kdb_new_cpu);
45882 + if (result == KDB_CMD_SS) {
45883 + KDB_STATE_SET(DOING_SS);
45887 + if (result == KDB_CMD_SSB) {
45888 + KDB_STATE_SET(DOING_SS);
45889 + KDB_STATE_SET(DOING_SSB);
45893 + if (result && result != 1 && result != KDB_CMD_GO)
45894 + kdb_printf("\nUnexpected kdb_local return code %d\n", result);
45896 + KDB_DEBUG_STATE("kdb_main_loop 4", reason);
45899 + if (KDB_STATE(DOING_SS))
45900 + KDB_STATE_CLEAR(SSBPT);
45904 +/* iapc_boot_arch was defined in ACPI 2.0, FADT revision 3 onwards. For any
45905 + * FADT prior to revision 3, we have to assume that we have an i8042 I/O
45906 + * device. ACPI initialises after KDB initialises but before using KDB, so
45907 + * check iapc_boot_arch on each entry to KDB.
45910 +kdb_check_i8042(void)
45912 + KDB_FLAG_CLEAR(NO_I8042);
45913 +#ifdef CONFIG_ACPI
45914 + if (acpi_gbl_FADT.header.revision >= 3 &&
45915 + (acpi_gbl_FADT.boot_flags & BAF_8042_KEYBOARD_CONTROLLER) == 0)
45916 + KDB_FLAG_SET(NO_I8042);
45917 +#endif /* CONFIG_ACPI */
45923 + * This function is the entry point for the kernel debugger. It
45924 + * provides a command parser and associated support functions to
45925 + * allow examination and control of an active kernel.
45927 + * The breakpoint trap code should invoke this function with
45928 + * one of KDB_REASON_BREAK (int 03) or KDB_REASON_DEBUG (debug register)
45930 + * the die_if_kernel function should invoke this function with
45931 + * KDB_REASON_OOPS.
45933 + * In single step mode, one cpu is released to run without
45934 + * breakpoints. Interrupts and NMI are reset to their original values,
45935 + * the cpu is allowed to do one instruction which causes a trap
45936 + * into kdb with KDB_REASON_DEBUG.
45939 + * reason The reason KDB was invoked
45940 + * error The hardware-defined error code
45941 + * regs The exception frame at time of fault/breakpoint. If reason
45942 + * is SILENT or CPU_UP then regs is NULL, otherwise it
45943 + * should always be valid.
45945 + * 0 KDB was invoked for an event which it wasn't responsible
45946 + * 1 KDB handled the event for which it was invoked.
45950 + * No assumptions of system state. This function may be invoked
45951 + * with arbitrary locks held. It will stop all other processors
45952 + * in an SMP environment, disable all interrupts and does not use
45953 + * the operating systems keyboard driver.
45955 + * This code is reentrant but only for cpu switch. Any other
45956 + * reentrancy is an error, although kdb will attempt to recover.
45958 + * At the start of a kdb session the initial processor is running
45959 + * kdb() and the other processors can be doing anything. When the
45960 + * initial processor calls smp_kdb_stop() the other processors are
45961 + * driven through kdb_ipi which calls kdb() with reason SWITCH.
45962 + * That brings all processors into this routine, one with a "real"
45963 + * reason code, the other with SWITCH.
45965 + * Because the other processors are driven via smp_kdb_stop(),
45966 + * they enter here from the NMI handler. Until the other
45967 + * processors exit from here and exit from kdb_ipi, they will not
45968 + * take any more NMI requests. The initial cpu will still take NMI.
45970 + * Multiple race and reentrancy conditions, each with different
45971 + * advoidance mechanisms.
45973 + * Two cpus hit debug points at the same time.
45975 + * kdb_lock and kdb_initial_cpu ensure that only one cpu gets
45976 + * control of kdb. The others spin on kdb_initial_cpu until
45977 + * they are driven through NMI into kdb_ipi. When the initial
45978 + * cpu releases the others from NMI, they resume trying to get
45979 + * kdb_initial_cpu to start a new event.
45981 + * A cpu is released from kdb and starts a new event before the
45982 + * original event has completely ended.
45984 + * kdb_previous_event() prevents any cpu from entering
45985 + * kdb_initial_cpu state until the previous event has completely
45986 + * ended on all cpus.
45988 + * An exception occurs inside kdb.
45990 + * kdb_initial_cpu detects recursive entry to kdb and attempts
45991 + * to recover. The recovery uses longjmp() which means that
45992 + * recursive calls to kdb never return. Beware of assumptions
45999 + * If the kdb call is recursive then longjmp takes over and
46000 + * --depth is never executed.
46004 + * NMI handling is tricky. The initial cpu is invoked by some kdb event,
46005 + * this event could be NMI driven but usually is not. The other cpus are
46006 + * driven into kdb() via kdb_ipi which uses NMI so at the start the other
46007 + * cpus will not accept NMI. Some operations such as SS release one cpu
46008 + * but hold all the others. Releasing a cpu means it drops back to
46009 + * whatever it was doing before the kdb event, this means it drops out of
46010 + * kdb_ipi and hence out of NMI status. But the software watchdog uses
46011 + * NMI and we do not want spurious watchdog calls into kdb. kdba_read()
46012 + * resets the watchdog counters in its input polling loop, when a kdb
46013 + * command is running it is subject to NMI watchdog events.
46015 + * Another problem with NMI handling is the NMI used to drive the other
46016 + * cpus into kdb cannot be distinguished from the watchdog NMI. State
46017 + * flag WAIT_IPI indicates that a cpu is waiting for NMI via kdb_ipi,
46018 + * if not set then software NMI is ignored by kdb_ipi.
46022 + * All cpus are in kdb (or they should be), all but one are
46023 + * spinning on KDB_STATE(HOLD_CPU). Only one cpu is not in
46024 + * HOLD_CPU state, only that cpu can handle commands.
46026 + * Go command entered.
46028 + * If necessary, go will switch to the initial cpu first. If the event
46029 + * was caused by a software breakpoint (assumed to be global) that
46030 + * requires single-step to get over the breakpoint then only release the
46031 + * initial cpu, after the initial cpu has single-stepped the breakpoint
46032 + * then release the rest of the cpus. If SSBPT is not required then
46033 + * release all the cpus at once.
46037 +kdb(kdb_reason_t reason, int error, struct pt_regs *regs)
46039 + kdb_intstate_t int_state; /* Interrupt state */
46040 + kdb_reason_t reason2 = reason;
46041 + int result = 0; /* Default is kdb did not handle it */
46042 + int ss_event, old_regs_saved = 0;
46043 + struct pt_regs *old_regs = NULL;
46044 + kdb_dbtrap_t db_result=KDB_DB_NOBPT;
46045 + preempt_disable();
46046 + atomic_inc(&kdb_event);
46049 + case KDB_REASON_OOPS:
46050 + case KDB_REASON_NMI:
46051 + KDB_FLAG_SET(CATASTROPHIC); /* kernel state is dubious now */
46057 + case KDB_REASON_ENTER:
46058 + case KDB_REASON_ENTER_SLAVE:
46059 + case KDB_REASON_BREAK:
46060 + case KDB_REASON_DEBUG:
46061 + case KDB_REASON_OOPS:
46062 + case KDB_REASON_SWITCH:
46063 + case KDB_REASON_KEYBOARD:
46064 + case KDB_REASON_NMI:
46065 + if (regs && regs != get_irq_regs()) {
46066 + old_regs = set_irq_regs(regs);
46067 + old_regs_saved = 1;
46073 + if (kdb_continue_catastrophic > 2) {
46074 + kdb_printf("kdb_continue_catastrophic is out of range, setting to 2\n");
46075 + kdb_continue_catastrophic = 2;
46077 + if (!kdb_on && KDB_FLAG(CATASTROPHIC) && kdb_continue_catastrophic == 2) {
46078 + KDB_FLAG_SET(ONLY_DO_DUMP);
46080 + if (!kdb_on && !KDB_FLAG(ONLY_DO_DUMP))
46083 + KDB_DEBUG_STATE("kdb 1", reason);
46084 + KDB_STATE_CLEAR(SUPPRESS);
46086 + /* Filter out userspace breakpoints first, no point in doing all
46087 + * the kdb smp fiddling when it is really a gdb trap.
46088 + * Save the single step status first, kdba_db_trap clears ss status.
46089 + * kdba_b[dp]_trap sets SSBPT if required.
46091 + ss_event = KDB_STATE(DOING_SS) || KDB_STATE(SSBPT);
46092 +#ifdef CONFIG_CPU_XSCALE
46093 + if ( KDB_STATE(A_XSC_ICH) ) {
46094 + /* restore changed I_BIT */
46095 + KDB_STATE_CLEAR(A_XSC_ICH);
46096 + kdba_restore_retirq(regs, KDB_STATE(A_XSC_IRQ));
46097 + if ( !ss_event ) {
46098 + kdb_printf("Stranger!!! Why IRQ bit is changed====\n");
46102 + if (reason == KDB_REASON_BREAK) {
46103 + db_result = kdba_bp_trap(regs, error); /* Only call this once */
46105 + if (reason == KDB_REASON_DEBUG) {
46106 + db_result = kdba_db_trap(regs, error); /* Only call this once */
46109 + if ((reason == KDB_REASON_BREAK || reason == KDB_REASON_DEBUG)
46110 + && db_result == KDB_DB_NOBPT) {
46111 + KDB_DEBUG_STATE("kdb 2", reason);
46112 + goto out; /* Not one of mine */
46115 + /* Turn off single step if it was being used */
46117 + kdba_clearsinglestep(regs);
46118 + /* Single step after a breakpoint removes the need for a delayed reinstall */
46119 + if (reason == KDB_REASON_BREAK || reason == KDB_REASON_DEBUG)
46120 + KDB_STATE_CLEAR(SSBPT);
46123 + /* kdb can validly reenter but only for certain well defined conditions */
46124 + if (reason == KDB_REASON_DEBUG
46125 + && !KDB_STATE(HOLD_CPU)
46127 + KDB_STATE_SET(REENTRY);
46129 + KDB_STATE_CLEAR(REENTRY);
46131 + /* Wait for previous kdb event to completely exit before starting
46134 + while (kdb_previous_event())
46136 + KDB_DEBUG_STATE("kdb 3", reason);
46139 + * If kdb is already active, print a message and try to recover.
46140 + * If recovery is not possible and recursion is allowed or
46141 + * forced recursion without recovery is set then try to recurse
46142 + * in kdb. Not guaranteed to work but it makes an attempt at
46143 + * debugging the debugger.
46145 + if (reason != KDB_REASON_SWITCH &&
46146 + reason != KDB_REASON_ENTER_SLAVE) {
46147 + if (KDB_IS_RUNNING() && !KDB_STATE(REENTRY)) {
46149 + unsigned long recurse = 0;
46150 + kdb_printf("kdb: Debugger re-entered on cpu %d, new reason = %d\n",
46151 + smp_processor_id(), reason);
46152 + /* Should only re-enter from released cpu */
46154 + if (KDB_STATE(HOLD_CPU)) {
46155 + kdb_printf(" Strange, cpu %d should not be running\n", smp_processor_id());
46158 + if (!KDB_STATE(CMD)) {
46159 + kdb_printf(" Not executing a kdb command\n");
46162 + if (!KDB_STATE(LONGJMP)) {
46163 + kdb_printf(" No longjmp available for recovery\n");
46166 + kdbgetulenv("RECURSE", &recurse);
46167 + if (recurse > 1) {
46168 + kdb_printf(" Forced recursion is set\n");
46172 + kdb_printf(" Attempting to abort command and recover\n");
46173 +#ifdef kdba_setjmp
46174 + kdba_longjmp(&kdbjmpbuf[smp_processor_id()], 0);
46175 +#endif /* kdba_setjmp */
46178 + if (KDB_STATE(RECURSE)) {
46179 + kdb_printf(" Already in recursive mode\n");
46181 + kdb_printf(" Attempting recursive mode\n");
46182 + KDB_STATE_SET(RECURSE);
46183 + KDB_STATE_SET(REENTRY);
46184 + reason2 = KDB_REASON_RECURSE;
46189 + kdb_printf(" Cannot recover, allowing event to proceed\n");
46191 + while (KDB_IS_RUNNING())
46196 + } else if (reason == KDB_REASON_SWITCH && !KDB_IS_RUNNING()) {
46197 + kdb_printf("kdb: CPU switch without kdb running, I'm confused\n");
46202 + * Disable interrupts, breakpoints etc. on this processor
46203 + * during kdb command processing
46205 + KDB_STATE_SET(KDB);
46206 + kdba_disableint(&int_state);
46207 + if (!KDB_STATE(KDB_CONTROL)) {
46208 + kdb_bp_remove_local();
46209 + KDB_STATE_SET(KDB_CONTROL);
46213 + * If not entering the debugger due to CPU switch or single step
46214 + * reentry, serialize access here.
46215 + * The processors may race getting to this point - if,
46216 + * for example, more than one processor hits a breakpoint
46217 + * at the same time. We'll serialize access to kdb here -
46218 + * other processors will loop here, and the NMI from the stop
46219 + * IPI will take them into kdb as switch candidates. Once
46220 + * the initial processor releases the debugger, the rest of
46221 + * the processors will race for it.
46223 + * The above describes the normal state of affairs, where two or more
46224 + * cpus that are entering kdb at the "same" time are assumed to be for
46225 + * separate events. However some processes such as ia64 MCA/INIT will
46226 + * drive all the cpus into error processing at the same time. For that
46227 + * case, all of the cpus entering kdb at the "same" time are really a
46230 + * That case is handled by the use of KDB_ENTER by one cpu (the
46231 + * monarch) and KDB_ENTER_SLAVE on the other cpus (the slaves).
46232 + * KDB_ENTER_SLAVE maps to KDB_REASON_ENTER_SLAVE. The slave events
46233 + * will be treated as if they had just responded to the kdb IPI, i.e.
46234 + * as if they were KDB_REASON_SWITCH.
46236 + * Because of races across multiple cpus, ENTER_SLAVE can occur before
46237 + * the main ENTER. Hold up ENTER_SLAVE here until the main ENTER
46241 + if (reason == KDB_REASON_ENTER_SLAVE) {
46242 + spin_lock(&kdb_lock);
46243 + while (!KDB_IS_RUNNING()) {
46244 + spin_unlock(&kdb_lock);
46245 + while (!KDB_IS_RUNNING())
46247 + spin_lock(&kdb_lock);
46249 + reason = KDB_REASON_SWITCH;
46250 + KDB_STATE_SET(HOLD_CPU);
46251 + spin_unlock(&kdb_lock);
46254 + if (reason == KDB_REASON_SWITCH || KDB_STATE(REENTRY))
46255 + ; /* drop through */
46257 + KDB_DEBUG_STATE("kdb 4", reason);
46258 + spin_lock(&kdb_lock);
46259 + while (KDB_IS_RUNNING() || kdb_previous_event()) {
46260 + spin_unlock(&kdb_lock);
46261 + while (KDB_IS_RUNNING() || kdb_previous_event())
46263 + spin_lock(&kdb_lock);
46265 + KDB_DEBUG_STATE("kdb 5", reason);
46267 + kdb_initial_cpu = smp_processor_id();
46269 + spin_unlock(&kdb_lock);
46270 + if (!kdb_quiet(reason))
46271 + notify_die(DIE_KDEBUG_ENTER, "KDEBUG ENTER", regs, error, 0, 0);
46274 + if (smp_processor_id() == kdb_initial_cpu
46275 + && !KDB_STATE(REENTRY)) {
46276 + KDB_STATE_CLEAR(HOLD_CPU);
46277 + KDB_STATE_CLEAR(WAIT_IPI);
46278 + kdb_check_i8042();
46280 + * Remove the global breakpoints. This is only done
46281 + * once from the initial processor on initial entry.
46283 + if (!kdb_quiet(reason) || smp_processor_id() == 0)
46284 + kdb_bp_remove_global();
46287 + * If SMP, stop other processors. The other processors
46288 + * will enter kdb() with KDB_REASON_SWITCH and spin in
46289 + * kdb_main_loop().
46291 + KDB_DEBUG_STATE("kdb 6", reason);
46292 + if (NR_CPUS > 1 && !kdb_quiet(reason)) {
46294 + for (i = 0; i < NR_CPUS; ++i) {
46295 + if (!cpu_online(i))
46297 + if (i != kdb_initial_cpu) {
46298 + KDB_STATE_SET_CPU(HOLD_CPU, i);
46299 + KDB_STATE_SET_CPU(WAIT_IPI, i);
46302 + KDB_DEBUG_STATE("kdb 7", reason);
46304 + KDB_DEBUG_STATE("kdb 8", reason);
46308 + if (KDB_STATE(GO1)) {
46309 + kdb_bp_remove_global(); /* They were set for single-step purposes */
46310 + KDB_STATE_CLEAR(GO1);
46311 + reason = KDB_REASON_SILENT; /* Now silently go */
46314 + /* Set up a consistent set of process stacks before talking to the user */
46315 + KDB_DEBUG_STATE("kdb 9", result);
46316 + result = kdba_main_loop(reason, reason2, error, db_result, regs);
46318 + KDB_DEBUG_STATE("kdb 10", result);
46319 + kdba_adjust_ip(reason2, error, regs);
46320 + KDB_STATE_CLEAR(LONGJMP);
46321 + KDB_DEBUG_STATE("kdb 11", result);
46322 + /* go which requires single-step over a breakpoint must only release
46325 + if (result == KDB_CMD_GO && KDB_STATE(SSBPT))
46326 + KDB_STATE_SET(GO1);
46328 + if (smp_processor_id() == kdb_initial_cpu &&
46329 + !KDB_STATE(DOING_SS) &&
46330 + !KDB_STATE(RECURSE)) {
46332 + * (Re)install the global breakpoints and cleanup the cached
46333 + * symbol table. This is only done once from the initial
46334 + * processor on go.
46336 + KDB_DEBUG_STATE("kdb 12", reason);
46337 + if (!kdb_quiet(reason) || smp_processor_id() == 0) {
46338 + kdb_bp_install_global(regs);
46339 + kdbnearsym_cleanup();
46342 + if (!KDB_STATE(GO1)) {
46344 + * Release all other cpus which will see KDB_STATE(LEAVING) is set.
46347 + for (i = 0; i < NR_CPUS; ++i) {
46348 + if (KDB_STATE_CPU(KDB, i))
46349 + KDB_STATE_SET_CPU(LEAVING, i);
46350 + KDB_STATE_CLEAR_CPU(WAIT_IPI, i);
46351 + KDB_STATE_CLEAR_CPU(HOLD_CPU, i);
46353 + /* Wait until all the other processors leave kdb */
46354 + while (kdb_previous_event() != 1)
46356 + if (!kdb_quiet(reason))
46357 + notify_die(DIE_KDEBUG_LEAVE, "KDEBUG LEAVE", regs, error, 0, 0);
46358 + kdb_initial_cpu = -1; /* release kdb control */
46359 + KDB_DEBUG_STATE("kdb 13", reason);
46363 + KDB_DEBUG_STATE("kdb 14", result);
46364 + kdba_restoreint(&int_state);
46365 +#ifdef CONFIG_CPU_XSCALE
46366 + if ( smp_processor_id() == kdb_initial_cpu &&
46367 + ( KDB_STATE(SSBPT) | KDB_STATE(DOING_SS) )
46369 + kdba_setsinglestep(regs);
46370 + // disable IRQ in stack frame
46371 + KDB_STATE_SET(A_XSC_ICH);
46372 + if ( kdba_disable_retirq(regs) ) {
46373 + KDB_STATE_SET(A_XSC_IRQ);
46376 + KDB_STATE_CLEAR(A_XSC_IRQ);
46381 + /* Only do this work if we are really leaving kdb */
46382 + if (!(KDB_STATE(DOING_SS) || KDB_STATE(SSBPT) || KDB_STATE(RECURSE))) {
46383 + KDB_DEBUG_STATE("kdb 15", result);
46384 + kdb_bp_install_local(regs);
46385 + if (old_regs_saved)
46386 + set_irq_regs(old_regs);
46387 + KDB_STATE_CLEAR(KDB_CONTROL);
46390 + KDB_DEBUG_STATE("kdb 16", result);
46391 + KDB_FLAG_CLEAR(CATASTROPHIC);
46392 + KDB_STATE_CLEAR(IP_ADJUSTED); /* Re-adjust ip next time in */
46393 + KDB_STATE_CLEAR(KEYBOARD);
46394 + KDB_STATE_CLEAR(KDB); /* Main kdb state has been cleared */
46395 + KDB_STATE_CLEAR(RECURSE);
46396 + KDB_STATE_CLEAR(LEAVING); /* No more kdb work after this */
46397 + KDB_DEBUG_STATE("kdb 17", reason);
46399 + atomic_dec(&kdb_event);
46400 + preempt_enable();
46401 + return result != 0;
46407 + * This function implements the guts of the 'mdr' command.
46409 + * mdr <addr arg>,<byte count>
46412 + * addr Start address
46413 + * count Number of bytes
46417 + * Always 0. Any errors are detected and printed by kdb_getarea.
46424 +kdb_mdr(kdb_machreg_t addr, unsigned int count)
46427 + while (count--) {
46428 + if (kdb_getarea(c, addr))
46430 + kdb_printf("%02x", c);
46433 + kdb_printf("\n");
46440 + * This function implements the 'md', 'md1', 'md2', 'md4', 'md8'
46441 + * 'mdr' and 'mds' commands.
46443 + * md|mds [<addr arg> [<line count> [<radix>]]]
46444 + * mdWcN [<addr arg> [<line count> [<radix>]]]
46445 + * where W = is the width (1, 2, 4 or 8) and N is the count.
46446 + * for eg., md1c20 reads 20 bytes, 1 at a time.
46447 + * mdr <addr arg>,<byte count>
46450 + * argc argument count
46451 + * argv argument vector
46455 + * zero for success, a kdb diagnostic if error
46462 +kdb_md_line(const char *fmtstr, kdb_machreg_t addr,
46463 + int symbolic, int nosect, int bytesperword,
46464 + int num, int repeat, int phys)
46466 + /* print just one line of data */
46467 + kdb_symtab_t symtab;
46471 + unsigned long word;
46473 + memset(cbuf, '\0', sizeof(cbuf));
46475 + kdb_printf("phys " kdb_machreg_fmt0 " ", addr);
46477 + kdb_printf(kdb_machreg_fmt0 " ", addr);
46479 + for (i = 0; i < num && repeat--; i++) {
46481 + if (kdb_getphysword(&word, addr, bytesperword))
46483 + } else if (kdb_getword(&word, addr, bytesperword))
46485 + kdb_printf(fmtstr, word);
46487 + kdbnearsym(word, &symtab);
46489 + memset(&symtab, 0, sizeof(symtab));
46490 + if (symtab.sym_name) {
46491 + kdb_symbol_print(word, &symtab, 0);
46493 + kdb_printf("\n");
46494 + kdb_printf(" %s %s "
46495 + kdb_machreg_fmt " " kdb_machreg_fmt " " kdb_machreg_fmt,
46498 + symtab.sec_start,
46499 + symtab.sym_start,
46502 + addr += bytesperword;
46506 + unsigned char c[8];
46508 + unsigned char *cp;
46509 +#ifdef __BIG_ENDIAN
46510 + cp = wc.c + 8 - bytesperword;
46515 +#define printable_char(c) ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.';})
46516 + switch (bytesperword) {
46518 + *c++ = printable_char(*cp++);
46519 + *c++ = printable_char(*cp++);
46520 + *c++ = printable_char(*cp++);
46521 + *c++ = printable_char(*cp++);
46524 + *c++ = printable_char(*cp++);
46525 + *c++ = printable_char(*cp++);
46528 + *c++ = printable_char(*cp++);
46531 + *c++ = printable_char(*cp++);
46535 +#undef printable_char
46538 + kdb_printf("%*s %s\n", (int)((num-i)*(2*bytesperword + 1)+1), " ", cbuf);
46542 +kdb_md(int argc, const char **argv)
46544 + static kdb_machreg_t last_addr;
46545 + static int last_radix, last_bytesperword, last_repeat;
46546 + int radix = 16, mdcount = 8, bytesperword = KDB_WORD_SIZE, repeat;
46548 + char fmtchar, fmtstr[64];
46549 + kdb_machreg_t addr;
46550 + unsigned long word;
46552 + int symbolic = 0;
46556 + kdbgetintenv("MDCOUNT", &mdcount);
46557 + kdbgetintenv("RADIX", &radix);
46558 + kdbgetintenv("BYTESPERWORD", &bytesperword);
46560 + /* Assume 'md <addr>' and start with environment values */
46561 + repeat = mdcount * 16 / bytesperword;
46563 + if (strcmp(argv[0], "mdr") == 0) {
46565 + return KDB_ARGCOUNT;
46567 + } else if (isdigit(argv[0][2])) {
46568 + bytesperword = (int)(argv[0][2] - '0');
46569 + if (bytesperword == 0) {
46570 + bytesperword = last_bytesperword;
46571 + if (bytesperword == 0) {
46572 + bytesperword = 4;
46575 + last_bytesperword = bytesperword;
46576 + repeat = mdcount * 16 / bytesperword;
46579 + else if (argv[0][3] == 'c' && argv[0][4]) {
46581 + repeat = simple_strtoul(argv[0]+4, &p, 10);
46582 + mdcount = ((repeat * bytesperword) + 15) / 16;
46585 + last_repeat = repeat;
46586 + } else if (strcmp(argv[0], "md") == 0)
46588 + else if (strcmp(argv[0], "mds") == 0)
46590 + else if (strcmp(argv[0], "mdp") == 0) {
46591 + phys = valid = 1;
46594 + return KDB_NOTFOUND;
46597 + if (last_addr == 0)
46598 + return KDB_ARGCOUNT;
46599 + addr = last_addr;
46600 + radix = last_radix;
46601 + bytesperword = last_bytesperword;
46602 + repeat = last_repeat;
46603 + mdcount = ((repeat * bytesperword) + 15) / 16;
46607 + kdb_machreg_t val;
46608 + int diag, nextarg = 1;
46609 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
46612 + if (argc > nextarg+2)
46613 + return KDB_ARGCOUNT;
46615 + if (argc >= nextarg) {
46616 + diag = kdbgetularg(argv[nextarg], &val);
46618 + mdcount = (int) val;
46619 + repeat = mdcount * 16 / bytesperword;
46622 + if (argc >= nextarg+1) {
46623 + diag = kdbgetularg(argv[nextarg+1], &val);
46625 + radix = (int) val;
46629 + if (strcmp(argv[0], "mdr") == 0) {
46630 + return kdb_mdr(addr, mdcount);
46644 + return KDB_BADRADIX;
46647 + last_radix = radix;
46649 + if (bytesperword > KDB_WORD_SIZE)
46650 + return KDB_BADWIDTH;
46652 + switch (bytesperword) {
46654 + sprintf(fmtstr, "%%16.16l%c ", fmtchar);
46657 + sprintf(fmtstr, "%%8.8l%c ", fmtchar);
46660 + sprintf(fmtstr, "%%4.4l%c ", fmtchar);
46663 + sprintf(fmtstr, "%%2.2l%c ", fmtchar);
46666 + return KDB_BADWIDTH;
46669 + last_repeat = repeat;
46670 + last_bytesperword = bytesperword;
46672 + if (strcmp(argv[0], "mds") == 0) {
46674 + /* Do not save these changes as last_*, they are temporary mds
46677 + bytesperword = KDB_WORD_SIZE;
46678 + repeat = mdcount;
46679 + kdbgetintenv("NOSECT", &nosect);
46682 + /* Round address down modulo BYTESPERWORD */
46684 + addr &= ~(bytesperword-1);
46686 + while (repeat > 0) {
46688 + int n, z, num = (symbolic ? 1 : (16 / bytesperword));
46690 + for (a = addr, z = 0; z < repeat; a += bytesperword, ++z) {
46692 + if (kdb_getphysword(&word, a, bytesperword)
46695 + } else if (kdb_getword(&word, a, bytesperword) || word)
46698 + n = min(num, repeat);
46699 + kdb_md_line(fmtstr, addr, symbolic, nosect, bytesperword, num, repeat, phys);
46700 + addr += bytesperword * n;
46702 + z = (z + num - 1) / num;
46704 + int s = num * (z-2);
46705 + kdb_printf(kdb_machreg_fmt0 "-" kdb_machreg_fmt0 " zero suppressed\n",
46706 + addr, addr + bytesperword * s - 1);
46707 + addr += bytesperword * s;
46711 + last_addr = addr;
46719 + * This function implements the 'mm' command.
46721 + * mm address-expression new-value
46724 + * argc argument count
46725 + * argv argument vector
46729 + * zero for success, a kdb diagnostic if error
46733 + * mm works on machine words, mmW works on bytes.
46737 +kdb_mm(int argc, const char **argv)
46740 + kdb_machreg_t addr;
46742 + unsigned long contents;
46746 + if (argv[0][2] && !isdigit(argv[0][2]))
46747 + return KDB_NOTFOUND;
46750 + return KDB_ARGCOUNT;
46754 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
46757 + if (nextarg > argc)
46758 + return KDB_ARGCOUNT;
46760 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &contents, NULL, NULL)))
46763 + if (nextarg != argc + 1)
46764 + return KDB_ARGCOUNT;
46766 + width = argv[0][2] ? (argv[0][2] - '0') : (KDB_WORD_SIZE);
46767 + if ((diag = kdb_putword(addr, contents, width)))
46770 + kdb_printf(kdb_machreg_fmt " = " kdb_machreg_fmt "\n", addr, contents);
46778 + * This function implements the 'go' command.
46780 + * go [address-expression]
46783 + * argc argument count
46784 + * argv argument vector
46788 + * KDB_CMD_GO for success, a kdb diagnostic if error
46795 +kdb_go(int argc, const char **argv)
46797 + kdb_machreg_t addr;
46801 + struct pt_regs *regs = get_irq_regs();
46804 + if (smp_processor_id() != kdb_initial_cpu) {
46805 + kdb_printf("go <address> must be issued from the initial cpu, do cpu %d first\n", kdb_initial_cpu);
46806 + return KDB_ARGCOUNT;
46809 + diag = kdbgetaddrarg(argc, argv, &nextarg,
46810 + &addr, &offset, NULL);
46814 + kdba_setpc(regs, addr);
46816 + return KDB_ARGCOUNT;
46818 + diag = KDB_CMD_GO;
46819 + if (KDB_FLAG(CATASTROPHIC)) {
46820 + kdb_printf("Catastrophic error detected\n");
46821 + kdb_printf("kdb_continue_catastrophic=%d, ",
46822 + kdb_continue_catastrophic);
46823 + if (kdb_continue_catastrophic == 0 && kdb_go_count++ == 0) {
46824 + kdb_printf("type go a second time if you really want to continue\n");
46827 + if (kdb_continue_catastrophic == 2) {
46829 + kdb_printf("forcing reboot\n");
46830 + kdb_reboot(0, NULL);
46832 + kdb_printf("attempting to continue\n");
46834 + if (smp_processor_id() != kdb_initial_cpu) {
46836 + kdb_printf("go was not issued from initial cpu, switching back to cpu %d\n", kdb_initial_cpu);
46837 + sprintf(buf, "cpu %d\n", kdb_initial_cpu);
46838 + /* Recursive use of kdb_parse, do not use argv after this point */
46840 + diag = kdb_parse(buf);
46841 + if (diag == KDB_CMD_CPU)
46842 + KDB_STATE_SET_CPU(GO_SWITCH, kdb_initial_cpu);
46850 + * This function implements the 'rd' command.
46852 + * rd display all general registers.
46853 + * rd c display all control registers.
46854 + * rd d display all debug registers.
46857 + * argc argument count
46858 + * argv argument vector
46862 + * zero for success, a kdb diagnostic if error
46869 +kdb_rd(int argc, const char **argv)
46873 + if ((diag = kdb_check_regs()))
46875 + return kdba_dumpregs(kdb_current_regs, NULL, NULL);
46879 + return KDB_ARGCOUNT;
46882 + if ((diag = kdb_check_regs()))
46884 + return kdba_dumpregs(kdb_current_regs, argv[1], argc==2 ? argv[2]: NULL);
46890 + * This function implements the 'rm' (register modify) command.
46892 + * rm register-name new-contents
46895 + * argc argument count
46896 + * argv argument vector
46900 + * zero for success, a kdb diagnostic if error
46904 + * Currently doesn't allow modification of control or
46905 + * debug registers.
46909 +kdb_rm(int argc, const char **argv)
46913 + kdb_machreg_t contents;
46916 + return KDB_ARGCOUNT;
46920 + * Allow presence or absence of leading '%' symbol.
46923 + if (argv[1][0] == '%')
46926 + diag = kdbgetularg(argv[2], &contents);
46930 + if ((diag = kdb_check_regs()))
46932 + diag = kdba_setregcontents(&argv[1][ind], kdb_current_regs, contents);
46939 +#if defined(CONFIG_MAGIC_SYSRQ)
46943 + * This function implements the 'sr' (SYSRQ key) command which
46944 + * interfaces to the soi-disant MAGIC SYSRQ functionality.
46946 + * sr <magic-sysrq-code>
46949 + * argc argument count
46950 + * argv argument vector
46954 + * zero for success, a kdb diagnostic if error
46961 +kdb_sr(int argc, const char **argv)
46963 + extern int __sysrq_enabled;
46965 + return KDB_ARGCOUNT;
46967 + if (!__sysrq_enabled) {
46968 + kdb_printf("Auto activating sysrq\n");
46969 + __sysrq_enabled = 1;
46972 + handle_sysrq(*argv[1], NULL);
46976 +#endif /* CONFIG_MAGIC_SYSRQ */
46981 + * This function implements the 'regs' (display exception frame)
46982 + * command. This command takes an address and expects to find
46983 + * an exception frame at that address, formats and prints it.
46985 + * regs address-expression
46988 + * argc argument count
46989 + * argv argument vector
46993 + * zero for success, a kdb diagnostic if error
47001 +kdb_ef(int argc, const char **argv)
47004 + kdb_machreg_t addr;
47010 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
47014 + return kdba_dumpregs((struct pt_regs *)addr, NULL, NULL);
47017 + return KDB_ARGCOUNT;
47020 +#if defined(CONFIG_MODULES)
47021 +extern struct list_head *kdb_modules;
47022 +extern void free_module(struct module *);
47024 +/* modules using other modules */
47027 + struct list_head list;
47028 + struct module *module_which_uses;
47034 + * This function implements the 'lsmod' command. Lists currently
47035 + * loaded kernel modules.
47037 + * Mostly taken from userland lsmod.
47040 + * argc argument count
47041 + * argv argument vector
47045 + * zero for success, a kdb diagnostic if error
47053 +kdb_lsmod(int argc, const char **argv)
47055 + struct module *mod;
47058 + return KDB_ARGCOUNT;
47060 + kdb_printf("Module Size modstruct Used by\n");
47061 + list_for_each_entry(mod, kdb_modules, list) {
47063 + kdb_printf("%-20s%8lu 0x%p ", mod->name,
47064 + mod->core_size, (void *)mod);
47065 +#ifdef CONFIG_MODULE_UNLOAD
47066 + kdb_printf("%4d ", module_refcount(mod));
47068 + if (mod->state == MODULE_STATE_GOING)
47069 + kdb_printf(" (Unloading)");
47070 + else if (mod->state == MODULE_STATE_COMING)
47071 + kdb_printf(" (Loading)");
47073 + kdb_printf(" (Live)");
47075 +#ifdef CONFIG_MODULE_UNLOAD
47077 + struct module_use *use;
47078 + kdb_printf(" [ ");
47079 + list_for_each_entry(use, &mod->modules_which_use_me, list)
47080 + kdb_printf("%s ", use->module_which_uses->name);
47081 + kdb_printf("]\n");
47089 +#endif /* CONFIG_MODULES */
47094 + * This function implements the 'env' command. Display the current
47095 + * environment variables.
47098 + * argc argument count
47099 + * argv argument vector
47103 + * zero for success, a kdb diagnostic if error
47110 +kdb_env(int argc, const char **argv)
47114 + for(i=0; i<__nenv; i++) {
47116 + kdb_printf("%s\n", __env[i]);
47120 + if (KDB_DEBUG(MASK))
47121 + kdb_printf("KDBFLAGS=0x%x\n", kdb_flags);
47129 + * This function implements the 'dmesg' command to display the contents
47130 + * of the syslog buffer.
47132 + * dmesg [lines] [adjust]
47135 + * argc argument count
47136 + * argv argument vector
47140 + * zero for success, a kdb diagnostic if error
47148 +kdb_dmesg(int argc, const char **argv)
47150 + char *syslog_data[4], *start, *end, c = '\0', *p;
47151 + int diag, logging, logsize, lines = 0, adjust = 0, n;
47154 + return KDB_ARGCOUNT;
47157 + lines = simple_strtol(argv[1], &cp, 0);
47161 + adjust = simple_strtoul(argv[2], &cp, 0);
47162 + if (*cp || adjust < 0)
47167 + /* disable LOGGING if set */
47168 + diag = kdbgetintenv("LOGGING", &logging);
47169 + if (!diag && logging) {
47170 + const char *setargs[] = { "set", "LOGGING", "0" };
47171 + kdb_set(2, setargs);
47174 + /* syslog_data[0,1] physical start, end+1. syslog_data[2,3] logical start, end+1. */
47175 + kdb_syslog_data(syslog_data);
47176 + if (syslog_data[2] == syslog_data[3])
47178 + logsize = syslog_data[1] - syslog_data[0];
47179 + start = syslog_data[2];
47180 + end = syslog_data[3];
47181 +#define KDB_WRAP(p) (((p - syslog_data[0]) % logsize) + syslog_data[0])
47182 + for (n = 0, p = start; p < end; ++p) {
47183 + if ((c = *KDB_WRAP(p)) == '\n')
47190 + kdb_printf("buffer only contains %d lines, nothing printed\n", n);
47191 + else if (adjust - lines >= n)
47192 + kdb_printf("buffer only contains %d lines, last %d lines printed\n",
47195 + for (; start < end && adjust; ++start) {
47196 + if (*KDB_WRAP(start) == '\n')
47202 + for (p = start; p < end && lines; ++p) {
47203 + if (*KDB_WRAP(p) == '\n')
47207 + } else if (lines > 0) {
47208 + int skip = n - (adjust + lines);
47209 + if (adjust >= n) {
47210 + kdb_printf("buffer only contains %d lines, nothing printed\n", n);
47212 + } else if (skip < 0) {
47215 + kdb_printf("buffer only contains %d lines, first %d lines printed\n",
47218 + for (; start < end && skip; ++start) {
47219 + if (*KDB_WRAP(start) == '\n')
47222 + for (p = start; p < end && lines; ++p) {
47223 + if (*KDB_WRAP(p) == '\n')
47228 + /* Do a line at a time (max 200 chars) to reduce protocol overhead */
47230 + while (start != end) {
47233 + while (start < end && (c = *KDB_WRAP(start)) && (p - buf) < sizeof(buf)-1) {
47240 + kdb_printf("%s", buf);
47243 + kdb_printf("\n");
47251 + * This function implements the 'cpu' command.
47256 + * argc argument count
47257 + * argv argument vector
47261 + * KDB_CMD_CPU for success, a kdb diagnostic if error
47265 + * All cpu's should be spinning in kdb(). However just in case
47266 + * a cpu did not take the smp_kdb_stop NMI, check that a cpu
47267 + * entered kdb() before passing control to it.
47271 +kdb_cpu_status(void)
47273 + int i, start_cpu, first_print = 1;
47274 + char state, prev_state = '?';
47276 + kdb_printf("Currently on cpu %d\n", smp_processor_id());
47277 + kdb_printf("Available cpus: ");
47278 + for (start_cpu = -1, i = 0; i < NR_CPUS; i++) {
47279 + if (!cpu_online(i))
47280 + state = 'F'; /* cpu is offline */
47282 + struct kdb_running_process *krp = kdb_running_process+i;
47283 + if (KDB_STATE_CPU(KDB, i)) {
47284 + state = ' '; /* cpu is responding to kdb */
47285 + if (kdb_task_state_char(krp->p) == 'I')
47286 + state = 'I'; /* running the idle task */
47287 + } else if (krp->seqno && krp->p && krp->seqno >= kdb_seqno - 1)
47288 + state = '+'; /* some kdb data, but not responding */
47290 + state = '*'; /* no kdb data */
47292 + if (state != prev_state) {
47293 + if (prev_state != '?') {
47294 + if (!first_print)
47295 + kdb_printf(", ");
47297 + kdb_printf("%d", start_cpu);
47298 + if (start_cpu < i-1)
47299 + kdb_printf("-%d", i-1);
47300 + if (prev_state != ' ')
47301 + kdb_printf("(%c)", prev_state);
47303 + prev_state = state;
47307 + /* print the trailing cpus, ignoring them if they are all offline */
47308 + if (prev_state != 'F') {
47309 + if (!first_print)
47310 + kdb_printf(", ");
47311 + kdb_printf("%d", start_cpu);
47312 + if (start_cpu < i-1)
47313 + kdb_printf("-%d", i-1);
47314 + if (prev_state != ' ')
47315 + kdb_printf("(%c)", prev_state);
47317 + kdb_printf("\n");
47321 +kdb_cpu(int argc, const char **argv)
47323 + unsigned long cpunum;
47326 + /* ask the other cpus if they are still active */
47327 + for (i=0; i<NR_CPUS; i++) {
47328 + if (cpu_online(i))
47329 + KDB_STATE_CLEAR_CPU(KDB, i);
47331 + KDB_STATE_SET(KDB);
47333 + /* wait for the other cpus to notice and set state KDB again,
47334 + * see kdb_main_loop
47339 + kdb_cpu_status();
47344 + return KDB_ARGCOUNT;
47346 + diag = kdbgetularg(argv[1], &cpunum);
47351 + * Validate cpunum
47353 + if ((cpunum > NR_CPUS)
47354 + || !cpu_online(cpunum)
47355 + || !KDB_STATE_CPU(KDB, cpunum))
47356 + return KDB_BADCPUNUM;
47358 + kdb_new_cpu = cpunum;
47361 + * Switch to other cpu
47363 + return KDB_CMD_CPU;
47366 +/* The user may not realize that ps/bta with no parameters does not print idle
47367 + * or sleeping system daemon processes, so tell them how many were suppressed.
47370 +kdb_ps_suppressed(void)
47372 + int idle = 0, daemon = 0;
47373 + unsigned long mask_I = kdb_task_state_string("I"),
47374 + mask_M = kdb_task_state_string("M");
47375 + unsigned long cpu;
47376 + const struct task_struct *p, *g;
47377 + for (cpu = 0; cpu < NR_CPUS; ++cpu) {
47378 + if (!cpu_online(cpu))
47380 + p = kdb_curr_task(cpu);
47381 + if (kdb_task_state(p, mask_I))
47384 + kdb_do_each_thread(g, p) {
47385 + if (kdb_task_state(p, mask_M))
47387 + } kdb_while_each_thread(g, p);
47388 + if (idle || daemon) {
47390 + kdb_printf("%d idle process%s (state I)%s",
47391 + idle, idle == 1 ? "" : "es",
47392 + daemon ? " and " : "");
47394 + kdb_printf("%d sleeping system daemon (state M) process%s",
47395 + daemon, daemon == 1 ? "" : "es");
47396 + kdb_printf(" suppressed\n");
47403 + * This function implements the 'ps' command which shows
47404 + * a list of the active processes.
47406 + * ps [DRSTCZEUIMA] All processes, optionally filtered by state
47409 + * argc argument count
47410 + * argv argument vector
47414 + * zero for success, a kdb diagnostic if error
47421 +kdb_ps1(const struct task_struct *p)
47423 + struct kdb_running_process *krp = kdb_running_process + kdb_process_cpu(p);
47424 + kdb_printf("0x%p %8d %8d %d %4d %c 0x%p %c%s\n",
47425 + (void *)p, p->pid, p->parent->pid,
47426 + kdb_task_has_cpu(p), kdb_process_cpu(p),
47427 + kdb_task_state_char(p),
47428 + (void *)(&p->thread),
47429 + p == kdb_curr_task(smp_processor_id()) ? '*': ' ',
47431 + if (kdb_task_has_cpu(p)) {
47432 + if (!krp->seqno || !krp->p)
47433 + kdb_printf(" Error: no saved data for this cpu\n");
47435 + if (krp->seqno < kdb_seqno - 1)
47436 + kdb_printf(" Warning: process state is stale\n");
47438 + kdb_printf(" Error: does not match running process table (0x%p)\n", krp->p);
47444 +kdb_ps(int argc, const char **argv)
47446 + struct task_struct *g, *p;
47447 + unsigned long mask, cpu;
47450 + kdb_ps_suppressed();
47451 + kdb_printf("%-*s Pid Parent [*] cpu State %-*s Command\n",
47452 + (int)(2*sizeof(void *))+2, "Task Addr",
47453 + (int)(2*sizeof(void *))+2, "Thread");
47454 + mask = kdb_task_state_string(argc ? argv[1] : NULL);
47455 + /* Run the active tasks first */
47456 + for (cpu = 0; cpu < NR_CPUS; ++cpu) {
47457 + if (!cpu_online(cpu))
47459 + p = kdb_curr_task(cpu);
47460 + if (kdb_task_state(p, mask))
47463 + kdb_printf("\n");
47464 + /* Now the real tasks */
47465 + kdb_do_each_thread(g, p) {
47466 + if (kdb_task_state(p, mask))
47468 + } kdb_while_each_thread(g, p);
47476 + * This function implements the 'pid' command which switches
47477 + * the currently active process.
47479 + * pid [<pid> | R]
47482 + * argc argument count
47483 + * argv argument vector
47487 + * zero for success, a kdb diagnostic if error
47495 +kdb_pid(int argc, const char **argv)
47497 + struct task_struct *p;
47498 + unsigned long val;
47502 + return KDB_ARGCOUNT;
47505 + if (strcmp(argv[1], "R") == 0) {
47506 + p = KDB_RUNNING_PROCESS_ORIGINAL[kdb_initial_cpu].p;
47508 + diag = kdbgetularg(argv[1], &val);
47510 + return KDB_BADINT;
47512 + p = find_task_by_pid((pid_t)val);
47514 + kdb_printf("No task with pid=%d\n", (pid_t)val);
47519 + kdba_set_current_task(p);
47522 + kdb_printf("KDB current process is %s(pid=%d)\n", kdb_current_task->comm,
47523 + kdb_current_task->pid);
47531 + * This function implements the 'll' command which follows a linked
47532 + * list and executes an arbitrary command for each element.
47535 + * argc argument count
47536 + * argv argument vector
47540 + * zero for success, a kdb diagnostic if error
47547 +kdb_ll(int argc, const char **argv)
47550 + kdb_machreg_t addr;
47552 + kdb_machreg_t va;
47553 + unsigned long linkoffset;
47555 + const char *command;
47558 + return KDB_ARGCOUNT;
47562 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
47566 + diag = kdbgetularg(argv[2], &linkoffset);
47571 + * Using the starting address as
47572 + * the first element in the list, and assuming that
47573 + * the list ends with a null pointer.
47577 + if (!(command = kdb_strdup(argv[3], GFP_KDB))) {
47578 + kdb_printf("%s: cannot duplicate command\n", __FUNCTION__);
47581 + /* Recursive use of kdb_parse, do not use argv after this point */
47587 + sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va);
47588 + diag = kdb_parse(buf);
47592 + addr = va + linkoffset;
47593 + if (kdb_getword(&va, addr, sizeof(va)))
47604 + * This function implements the 'help' and '?' commands.
47607 + * argc argument count
47608 + * argv argument vector
47612 + * zero for success, a kdb diagnostic if error
47619 +kdb_help(int argc, const char **argv)
47624 + kdb_printf("%-15.15s %-20.20s %s\n", "Command", "Usage", "Description");
47625 + kdb_printf("----------------------------------------------------------\n");
47626 + for(i=0, kt=kdb_commands; i<kdb_max_commands; i++, kt++) {
47627 + if (kt->cmd_name)
47628 + kdb_printf("%-15.15s %-20.20s %s\n", kt->cmd_name,
47629 + kt->cmd_usage, kt->cmd_help);
47634 +extern int kdb_wake_up_process(struct task_struct * p);
47639 + * This function implements the 'kill' commands.
47642 + * argc argument count
47643 + * argv argument vector
47647 + * zero for success, a kdb diagnostic if error
47654 +kdb_kill(int argc, const char **argv)
47658 + struct task_struct *p;
47659 + struct siginfo info;
47662 + return KDB_ARGCOUNT;
47664 + sig = simple_strtol(argv[1], &endp, 0);
47666 + return KDB_BADINT;
47668 + kdb_printf("Invalid signal parameter.<-signal>\n");
47673 + pid = simple_strtol(argv[2], &endp, 0);
47675 + return KDB_BADINT;
47677 + kdb_printf("Process ID must be large than 0.\n");
47681 + /* Find the process. */
47682 + if (!(p = find_task_by_pid(pid))) {
47683 + kdb_printf("The specified process isn't found.\n");
47686 + p = p->group_leader;
47687 + info.si_signo = sig;
47688 + info.si_errno = 0;
47689 + info.si_code = SI_USER;
47690 + info.si_pid = pid; /* use same capabilities as process being signalled */
47691 + info.si_uid = 0; /* kdb has root authority */
47692 + kdb_send_sig_info(p, &info, kdb_seqno);
47697 + int tm_sec; /* seconds */
47698 + int tm_min; /* minutes */
47699 + int tm_hour; /* hours */
47700 + int tm_mday; /* day of the month */
47701 + int tm_mon; /* month */
47702 + int tm_year; /* year */
47706 +kdb_gmtime(struct timespec *tv, struct kdb_tm *tm)
47708 + /* This will work from 1970-2099, 2100 is not a leap year */
47709 + static int mon_day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
47710 + memset(tm, 0, sizeof(*tm));
47711 + tm->tm_sec = tv->tv_sec % (24 * 60 * 60);
47712 + tm->tm_mday = tv->tv_sec / (24 * 60 * 60) + (2 * 365 + 1); /* shift base from 1970 to 1968 */
47713 + tm->tm_min = tm->tm_sec / 60 % 60;
47714 + tm->tm_hour = tm->tm_sec / 60 / 60;
47715 + tm->tm_sec = tm->tm_sec % 60;
47716 + tm->tm_year = 68 + 4*(tm->tm_mday / (4*365+1));
47717 + tm->tm_mday %= (4*365+1);
47719 + while (tm->tm_mday >= mon_day[tm->tm_mon]) {
47720 + tm->tm_mday -= mon_day[tm->tm_mon];
47721 + if (++tm->tm_mon == 12) {
47731 + * Most of this code has been lifted from kernel/timer.c::sys_sysinfo().
47732 + * I cannot call that code directly from kdb, it has an unconditional
47733 + * cli()/sti() and calls routines that take locks which can stop the debugger.
47737 +kdb_sysinfo(struct sysinfo *val)
47739 + struct timespec uptime;
47740 + do_posix_clock_monotonic_gettime(&uptime);
47741 + memset(val, 0, sizeof(*val));
47742 + val->uptime = uptime.tv_sec;
47743 + val->loads[0] = avenrun[0];
47744 + val->loads[1] = avenrun[1];
47745 + val->loads[2] = avenrun[2];
47746 + val->procs = nr_threads-1;
47748 + kdb_si_swapinfo(val);
47756 + * This function implements the 'summary' command.
47759 + * argc argument count
47760 + * argv argument vector
47764 + * zero for success, a kdb diagnostic if error
47771 +kdb_summary(int argc, const char **argv)
47773 + extern struct timespec xtime;
47774 + extern struct timezone sys_tz;
47775 + struct kdb_tm tm;
47776 + struct sysinfo val;
47779 + return KDB_ARGCOUNT;
47781 + kdb_printf("sysname %s\n", init_uts_ns.name.sysname);
47782 + kdb_printf("release %s\n", init_uts_ns.name.release);
47783 + kdb_printf("version %s\n", init_uts_ns.name.version);
47784 + kdb_printf("machine %s\n", init_uts_ns.name.machine);
47785 + kdb_printf("nodename %s\n", init_uts_ns.name.nodename);
47786 + kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
47788 + kdb_gmtime(&xtime, &tm);
47789 + kdb_printf("date %04d-%02d-%02d %02d:%02d:%02d tz_minuteswest %d\n",
47790 + 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
47791 + tm.tm_hour, tm.tm_min, tm.tm_sec,
47792 + sys_tz.tz_minuteswest);
47794 + kdb_sysinfo(&val);
47795 + kdb_printf("uptime ");
47796 + if (val.uptime > (24*60*60)) {
47797 + int days = val.uptime / (24*60*60);
47798 + val.uptime %= (24*60*60);
47799 + kdb_printf("%d day%s ", days, days == 1 ? "" : "s");
47801 + kdb_printf("%02ld:%02ld\n", val.uptime/(60*60), (val.uptime/60)%60);
47803 + /* lifted from fs/proc/proc_misc.c::loadavg_read_proc() */
47805 +#define LOAD_INT(x) ((x) >> FSHIFT)
47806 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
47807 + kdb_printf("load avg %ld.%02ld %ld.%02ld %ld.%02ld\n",
47808 + LOAD_INT(val.loads[0]), LOAD_FRAC(val.loads[0]),
47809 + LOAD_INT(val.loads[1]), LOAD_FRAC(val.loads[1]),
47810 + LOAD_INT(val.loads[2]), LOAD_FRAC(val.loads[2]));
47811 + kdb_printf("\n");
47815 + kdb_meminfo_read_proc(); /* in fs/proc/proc_misc.c */
47823 + * This function implements the 'per_cpu' command.
47826 + * argc argument count
47827 + * argv argument vector
47831 + * zero for success, a kdb diagnostic if error
47838 +kdb_per_cpu(int argc, const char **argv)
47840 + char buf[256], fmtstr[64];
47841 + kdb_symtab_t symtab;
47842 + cpumask_t suppress = CPU_MASK_NONE;
47844 + unsigned long addr, val, bytesperword = 0, whichcpu = ~0UL;
47846 + if (argc < 1 || argc > 3)
47847 + return KDB_ARGCOUNT;
47849 + snprintf(buf, sizeof(buf), "per_cpu__%s", argv[1]);
47850 + if (!kdbgetsymval(buf, &symtab)) {
47851 + kdb_printf("%s is not a per_cpu variable\n", argv[1]);
47852 + return KDB_BADADDR;
47854 + if (argc >=2 && (diag = kdbgetularg(argv[2], &bytesperword)))
47856 + if (!bytesperword)
47857 + bytesperword = KDB_WORD_SIZE;
47858 + else if (bytesperword > KDB_WORD_SIZE)
47859 + return KDB_BADWIDTH;
47860 + sprintf(fmtstr, "%%0%dlx ", (int)(2*bytesperword));
47862 + if ((diag = kdbgetularg(argv[3], &whichcpu)))
47864 + if (!cpu_online(whichcpu)) {
47865 + kdb_printf("cpu %ld is not online\n", whichcpu);
47866 + return KDB_BADCPUNUM;
47870 + /* Most architectures use __per_cpu_offset[cpu], some use
47871 + * __per_cpu_offset(cpu), smp has no __per_cpu_offset.
47873 +#ifdef __per_cpu_offset
47874 +#define KDB_PCU(cpu) __per_cpu_offset(cpu)
47877 +#define KDB_PCU(cpu) __per_cpu_offset[cpu]
47879 +#define KDB_PCU(cpu) 0
47883 + for_each_online_cpu(cpu) {
47884 + if (whichcpu != ~0UL && whichcpu != cpu)
47886 + addr = symtab.sym_start + KDB_PCU(cpu);
47887 + if ((diag = kdb_getword(&val, addr, bytesperword))) {
47888 + kdb_printf("%5d " kdb_bfd_vma_fmt0 " - unable to read, diag=%d\n",
47889 + cpu, addr, diag);
47894 + cpu_set(cpu, suppress);
47897 +#endif /* CONFIG_SMP */
47898 + kdb_printf("%5d ", cpu);
47899 + kdb_md_line(fmtstr, addr,
47900 + bytesperword == KDB_WORD_SIZE,
47901 + 1, bytesperword, 1, 1, 0);
47903 + if (cpus_weight(suppress) == 0)
47905 + kdb_printf("Zero suppressed cpu(s):");
47906 + for (cpu = first_cpu(suppress); cpu < NR_CPUS; cpu = next_cpu(cpu, suppress)) {
47907 + kdb_printf(" %d", cpu);
47908 + if (cpu == NR_CPUS-1 || next_cpu(cpu, suppress) != cpu + 1)
47910 + while (cpu < NR_CPUS && next_cpu(cpu, suppress) == cpu + 1)
47912 + kdb_printf("-%d", cpu);
47914 + kdb_printf("\n");
47923 + * kdb_register_repeat
47925 + * This function is used to register a kernel debugger command.
47928 + * cmd Command name
47929 + * func Function to execute the command
47930 + * usage A simple usage string showing arguments
47931 + * help A simple help string describing command
47932 + * repeat Does the command auto repeat on enter?
47936 + * zero for success, one if a duplicate command.
47943 +#define kdb_command_extend 50 /* arbitrary */
47945 +kdb_register_repeat(char *cmd,
47950 + kdb_repeat_t repeat)
47956 + * Brute force method to determine duplicates
47958 + for (i=0, kp=kdb_commands; i<kdb_max_commands; i++, kp++) {
47959 + if (kp->cmd_name && (strcmp(kp->cmd_name, cmd)==0)) {
47960 + kdb_printf("Duplicate kdb command registered: '%s'\n",
47967 + * Insert command into first available location in table
47969 + for (i=0, kp=kdb_commands; i<kdb_max_commands; i++, kp++) {
47970 + if (kp->cmd_name == NULL) {
47975 + if (i >= kdb_max_commands) {
47976 + kdbtab_t *new = kmalloc((kdb_max_commands + kdb_command_extend) * sizeof(*new), GFP_KDB);
47978 + kdb_printf("Could not allocate new kdb_command table\n");
47981 + if (kdb_commands) {
47982 + memcpy(new, kdb_commands, kdb_max_commands * sizeof(*new));
47983 + kfree(kdb_commands);
47985 + memset(new + kdb_max_commands, 0, kdb_command_extend * sizeof(*new));
47986 + kdb_commands = new;
47987 + kp = kdb_commands + kdb_max_commands;
47988 + kdb_max_commands += kdb_command_extend;
47991 + kp->cmd_name = cmd;
47992 + kp->cmd_func = func;
47993 + kp->cmd_usage = usage;
47994 + kp->cmd_help = help;
47995 + kp->cmd_flags = 0;
47996 + kp->cmd_minlen = minlen;
47997 + kp->cmd_repeat = repeat;
48005 + * Compatibility register function for commands that do not need to
48006 + * specify a repeat state. Equivalent to kdb_register_repeat with
48007 + * KDB_REPEAT_NONE.
48010 + * cmd Command name
48011 + * func Function to execute the command
48012 + * usage A simple usage string showing arguments
48013 + * help A simple help string describing command
48017 + * zero for success, one if a duplicate command.
48025 +kdb_register(char *cmd,
48031 + return kdb_register_repeat(cmd, func, usage, help, minlen, KDB_REPEAT_NONE);
48037 + * This function is used to unregister a kernel debugger command.
48038 + * It is generally called when a module which implements kdb
48039 + * commands is unloaded.
48042 + * cmd Command name
48046 + * zero for success, one command not registered.
48054 +kdb_unregister(char *cmd)
48060 + * find the command.
48062 + for (i=0, kp=kdb_commands; i<kdb_max_commands; i++, kp++) {
48063 + if (kp->cmd_name && (strcmp(kp->cmd_name, cmd)==0)) {
48064 + kp->cmd_name = NULL;
48070 + * Couldn't find it.
48078 + * This function is called by the kdb_init function to initialize
48079 + * the kdb command table. It must be called prior to any other
48080 + * call to kdb_register_repeat.
48094 +static void __init
48100 + for(i=0, kp=kdb_commands; i < kdb_max_commands; i++,kp++) {
48101 + kp->cmd_name = NULL;
48104 + kdb_register_repeat("md", kdb_md, "<vaddr>", "Display Memory Contents, also mdWcN, e.g. md8c1", 1, KDB_REPEAT_NO_ARGS);
48105 + kdb_register_repeat("mdr", kdb_md, "<vaddr> <bytes>", "Display Raw Memory", 0, KDB_REPEAT_NO_ARGS);
48106 + kdb_register_repeat("mdp", kdb_md, "<paddr> <bytes>", "Display Physical Memory", 0, KDB_REPEAT_NO_ARGS);
48107 + kdb_register_repeat("mds", kdb_md, "<vaddr>", "Display Memory Symbolically", 0, KDB_REPEAT_NO_ARGS);
48108 + kdb_register_repeat("mm", kdb_mm, "<vaddr> <contents>", "Modify Memory Contents", 0, KDB_REPEAT_NO_ARGS);
48109 + kdb_register_repeat("id", kdb_id, "<vaddr>", "Display Instructions", 1, KDB_REPEAT_NO_ARGS);
48110 + kdb_register_repeat("go", kdb_go, "[<vaddr>]", "Continue Execution", 1, KDB_REPEAT_NONE);
48111 + kdb_register_repeat("rd", kdb_rd, "", "Display Registers", 1, KDB_REPEAT_NONE);
48112 + kdb_register_repeat("rm", kdb_rm, "<reg> <contents>", "Modify Registers", 0, KDB_REPEAT_NONE);
48113 + kdb_register_repeat("ef", kdb_ef, "<vaddr>", "Display exception frame", 0, KDB_REPEAT_NONE);
48114 + kdb_register_repeat("bt", kdb_bt, "[<vaddr>]", "Stack traceback", 1, KDB_REPEAT_NONE);
48115 + kdb_register_repeat("btp", kdb_bt, "<pid>", "Display stack for process <pid>", 0, KDB_REPEAT_NONE);
48116 + kdb_register_repeat("bta", kdb_bt, "[DRSTCZEUIMA]", "Display stack all processes", 0, KDB_REPEAT_NONE);
48117 + kdb_register_repeat("btc", kdb_bt, "", "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE);
48118 + kdb_register_repeat("btt", kdb_bt, "<vaddr>", "Backtrace process given its struct task address", 0, KDB_REPEAT_NONE);
48119 + kdb_register_repeat("ll", kdb_ll, "<first-element> <linkoffset> <cmd>", "Execute cmd for each element in linked list", 0, KDB_REPEAT_NONE);
48120 + kdb_register_repeat("env", kdb_env, "", "Show environment variables", 0, KDB_REPEAT_NONE);
48121 + kdb_register_repeat("set", kdb_set, "", "Set environment variables", 0, KDB_REPEAT_NONE);
48122 + kdb_register_repeat("help", kdb_help, "", "Display Help Message", 1, KDB_REPEAT_NONE);
48123 + kdb_register_repeat("?", kdb_help, "", "Display Help Message", 0, KDB_REPEAT_NONE);
48124 + kdb_register_repeat("cpu", kdb_cpu, "<cpunum>","Switch to new cpu", 0, KDB_REPEAT_NONE);
48125 + kdb_register_repeat("ps", kdb_ps, "", "Display active task list", 0, KDB_REPEAT_NONE);
48126 + kdb_register_repeat("pid", kdb_pid, "<pidnum>", "Switch to another task", 0, KDB_REPEAT_NONE);
48127 + kdb_register_repeat("reboot", kdb_reboot, "", "Reboot the machine immediately", 0, KDB_REPEAT_NONE);
48128 +#if defined(CONFIG_MODULES)
48129 + kdb_register_repeat("lsmod", kdb_lsmod, "", "List loaded kernel modules", 0, KDB_REPEAT_NONE);
48131 +#if defined(CONFIG_MAGIC_SYSRQ)
48132 + kdb_register_repeat("sr", kdb_sr, "<key>", "Magic SysRq key", 0, KDB_REPEAT_NONE);
48134 + kdb_register_repeat("dmesg", kdb_dmesg, "[lines]", "Display syslog buffer", 0, KDB_REPEAT_NONE);
48135 + kdb_register_repeat("defcmd", kdb_defcmd, "name \"usage\" \"help\"", "Define a set of commands, down to endefcmd", 0, KDB_REPEAT_NONE);
48136 + kdb_register_repeat("kill", kdb_kill, "<-signal> <pid>", "Send a signal to a process", 0, KDB_REPEAT_NONE);
48137 + kdb_register_repeat("summary", kdb_summary, "", "Summarize the system", 4, KDB_REPEAT_NONE);
48138 + kdb_register_repeat("per_cpu", kdb_per_cpu, "", "Display per_cpu variables", 3, KDB_REPEAT_NONE);
48144 + * This function is called by the kdb_init function to execute any
48145 + * commands defined in kdb_cmds.
48148 + * Commands in *kdb_cmds[];
48159 +static void __init
48160 +kdb_cmd_init(void)
48163 + for (i = 0; kdb_cmds[i]; ++i) {
48164 + if (!defcmd_in_progress)
48165 + kdb_printf("kdb_cmd[%d]: %s", i, kdb_cmds[i]);
48166 + diag = kdb_parse(kdb_cmds[i]);
48168 + kdb_printf("command failed, kdb diag %d\n", diag);
48170 + if (defcmd_in_progress) {
48171 + kdb_printf("Incomplete 'defcmd' set, forcing endefcmd\n");
48172 + kdb_parse("endefcmd");
48179 + * Invoked via the panic_notifier_list.
48190 + * When this function is called from panic(), the other cpus have already
48196 +kdb_panic(struct notifier_block *self, unsigned long command, void *ptr)
48198 + KDB_FLAG_SET(CATASTROPHIC); /* kernel state is dubious now */
48203 +static struct notifier_block kdb_block = { kdb_panic, NULL, 0 };
48205 +#ifdef CONFIG_SYSCTL
48206 +static int proc_do_kdb(ctl_table *table, int write, struct file *filp,
48207 + void __user *buffer, size_t *lenp, loff_t *ppos)
48209 + if (KDB_FLAG(NO_CONSOLE) && write) {
48210 + printk(KERN_ERR "kdb has no working console and has switched itself off\n");
48213 + return proc_dointvec(table, write, filp, buffer, lenp, ppos);
48216 +static ctl_table kdb_kern_table[] = {
48218 + .ctl_name = KERN_KDB,
48219 + .procname = "kdb",
48221 + .maxlen = sizeof(int),
48223 + .proc_handler = &proc_do_kdb,
48228 +static ctl_table kdb_root_table[] = {
48230 + .ctl_name = CTL_KERN,
48231 + .procname = "kernel",
48233 + .child = kdb_kern_table,
48237 +#endif /* CONFIG_SYSCTL */
48240 +kdb_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
48242 + if (action == CPU_ONLINE) {
48243 + int cpu =(unsigned long)hcpu;
48244 + cpumask_t save_cpus_allowed = current->cpus_allowed;
48245 + cpumask_t new_cpus_allowed = cpumask_of_cpu(cpu);
48246 + set_cpus_allowed(current, new_cpus_allowed);
48247 + kdb(KDB_REASON_CPU_UP, 0, NULL); /* do kdb setup on this cpu */
48248 + set_cpus_allowed(current, save_cpus_allowed);
48250 + return NOTIFY_OK;
48253 +static struct notifier_block kdb_cpu_nfb = {
48254 + .notifier_call = kdb_cpu_callback
48260 + * Initialize the kernel debugger environment.
48275 + kdb_initial_cpu = smp_processor_id();
48277 + * This must be called before any calls to kdb_printf.
48281 + kdb_inittab(); /* Initialize Command Table */
48282 + kdb_initbptab(); /* Initialize Breakpoint Table */
48283 + kdb_id_init(); /* Initialize Disassembler */
48284 + kdba_init(); /* Architecture Dependent Initialization */
48287 + * Use printk() to get message in log_buf[];
48289 + printk("kdb version %d.%d%s by Keith Owens, Scott Lurndal. "\
48290 + "Copyright SGI, All Rights Reserved\n",
48291 + KDB_MAJOR_VERSION, KDB_MINOR_VERSION, KDB_TEST_VERSION);
48293 + kdb_cmd_init(); /* Preset commands from kdb_cmds */
48294 + kdb_initial_cpu = -1; /* Avoid recursion problems */
48295 + kdb(KDB_REASON_CPU_UP, 0, NULL); /* do kdb setup on boot cpu */
48296 + kdb_initial_cpu = smp_processor_id();
48297 + atomic_notifier_chain_register(&panic_notifier_list, &kdb_block);
48298 + register_cpu_notifier(&kdb_cpu_nfb);
48300 +#ifdef kdba_setjmp
48301 + kdbjmpbuf = vmalloc(NR_CPUS * sizeof(*kdbjmpbuf));
48303 + printk(KERN_ERR "Cannot allocate kdbjmpbuf, no kdb recovery will be possible\n");
48304 +#endif /* kdba_setjmp */
48306 + kdb_initial_cpu = -1;
48307 + kdb_wait_for_cpus_secs = max(10, 2*num_online_cpus());
48310 +#ifdef CONFIG_SYSCTL
48312 +kdb_late_init(void)
48314 + register_sysctl_table(kdb_root_table);
48318 +__initcall(kdb_late_init);
48321 +EXPORT_SYMBOL(kdb_register);
48322 +EXPORT_SYMBOL(kdb_register_repeat);
48323 +EXPORT_SYMBOL(kdb_unregister);
48324 +EXPORT_SYMBOL(kdb_getarea_size);
48325 +EXPORT_SYMBOL(kdb_putarea_size);
48326 +EXPORT_SYMBOL(kdb_getuserarea_size);
48327 +EXPORT_SYMBOL(kdb_putuserarea_size);
48328 +EXPORT_SYMBOL(kdbgetularg);
48329 +EXPORT_SYMBOL(kdbgetenv);
48330 +EXPORT_SYMBOL(kdbgetintenv);
48331 +EXPORT_SYMBOL(kdbgetaddrarg);
48332 +EXPORT_SYMBOL(kdb);
48333 +EXPORT_SYMBOL(kdb_on);
48334 +EXPORT_SYMBOL(kdb_seqno);
48335 +EXPORT_SYMBOL(kdb_initial_cpu);
48336 +EXPORT_SYMBOL(kdbnearsym);
48337 +EXPORT_SYMBOL(kdb_printf);
48338 +EXPORT_SYMBOL(kdb_symbol_print);
48339 +EXPORT_SYMBOL(kdb_running_process);
48340 diff -Nurp linux-2.6.22-590/kdb/kdbsupport.c linux-2.6.22-600/kdb/kdbsupport.c
48341 --- linux-2.6.22-590/kdb/kdbsupport.c 1970-01-01 01:00:00.000000000 +0100
48342 +++ linux-2.6.22-600/kdb/kdbsupport.c 2008-04-09 18:14:28.000000000 +0200
48345 + * Kernel Debugger Architecture Independent Support Functions
48347 + * This file is subject to the terms and conditions of the GNU General Public
48348 + * License. See the file "COPYING" in the main directory of this archive
48349 + * for more details.
48351 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
48352 + * 03/02/13 added new 2.5 kallsyms <xavier.bru@bull.net>
48355 +#include <stdarg.h>
48356 +#include <linux/types.h>
48357 +#include <linux/sched.h>
48358 +#include <linux/mm.h>
48359 +#include <linux/kallsyms.h>
48360 +#include <linux/stddef.h>
48361 +#include <linux/vmalloc.h>
48362 +#include <linux/ptrace.h>
48363 +#include <linux/module.h>
48364 +#include <linux/highmem.h>
48365 +#include <linux/hardirq.h>
48366 +#include <linux/delay.h>
48368 +#include <asm/uaccess.h>
48370 +#include <linux/kdb.h>
48371 +#include <linux/kdbprivate.h>
48374 + * Symbol table functions.
48380 + * Return the address of the given symbol.
48383 + * symname Character string containing symbol name
48384 + * symtab Structure to receive results
48387 + * 0 Symbol not found, symtab zero filled
48388 + * 1 Symbol mapped to module/symbol/section, data in symtab
48395 +kdbgetsymval(const char *symname, kdb_symtab_t *symtab)
48397 + if (KDB_DEBUG(AR))
48398 + kdb_printf("kdbgetsymval: symname=%s, symtab=%p\n", symname, symtab);
48399 + memset(symtab, 0, sizeof(*symtab));
48401 + if ((symtab->sym_start = kallsyms_lookup_name(symname))) {
48402 + if (KDB_DEBUG(AR))
48403 + kdb_printf("kdbgetsymval: returns 1, symtab->sym_start=0x%lx\n", symtab->sym_start);
48406 + if (KDB_DEBUG(AR))
48407 + kdb_printf("kdbgetsymval: returns 0\n");
48414 + * Return the name of the symbol with the nearest address
48415 + * less than 'addr'.
48418 + * addr Address to check for symbol near
48419 + * symtab Structure to receive results
48422 + * 0 No sections contain this address, symtab zero filled
48423 + * 1 Address mapped to module/symbol/section, data in symtab
48427 + * 2.6 kallsyms has a "feature" where it unpacks the name into a string.
48428 + * If that string is reused before the caller expects it then the caller
48429 + * sees its string change without warning. To avoid cluttering up the
48430 + * main kdb code with lots of kdb_strdup, tests and kfree calls, kdbnearsym
48431 + * maintains an LRU list of the last few unique strings. The list is sized
48432 + * large enough to hold active strings, no kdb caller of kdbnearsym makes
48433 + * more than ~20 later calls before using a saved value.
48436 +static char *kdb_name_table[100]; /* arbitrary size */
48439 +kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
48442 + unsigned long symbolsize;
48443 + unsigned long offset;
48444 +#define knt1_size 128 /* must be >= kallsyms table size */
48445 + char *knt1 = NULL;
48447 + if (KDB_DEBUG(AR))
48448 + kdb_printf("kdbnearsym: addr=0x%lx, symtab=%p\n", addr, symtab);
48449 + memset(symtab, 0, sizeof(*symtab));
48453 + knt1 = debug_kmalloc(knt1_size, GFP_ATOMIC);
48455 + kdb_printf("kdbnearsym: addr=0x%lx cannot kmalloc knt1\n", addr);
48458 + symtab->sym_name = kallsyms_lookup(addr, &symbolsize , &offset, (char **)(&symtab->mod_name), knt1);
48459 + if (offset > 8*1024*1024) {
48460 + symtab->sym_name = NULL;
48461 + addr = offset = symbolsize = 0;
48463 + symtab->sym_start = addr - offset;
48464 + symtab->sym_end = symtab->sym_start + symbolsize;
48465 + ret = symtab->sym_name != NULL && *(symtab->sym_name) != '\0';
48469 + /* Another 2.6 kallsyms "feature". Sometimes the sym_name is
48470 + * set but the buffer passed into kallsyms_lookup is not used,
48471 + * so it contains garbage. The caller has to work out which
48472 + * buffer needs to be saved.
48474 + * What was Rusty smoking when he wrote that code?
48476 + if (symtab->sym_name != knt1) {
48477 + strncpy(knt1, symtab->sym_name, knt1_size);
48478 + knt1[knt1_size-1] = '\0';
48480 + for (i = 0; i < ARRAY_SIZE(kdb_name_table); ++i) {
48481 + if (kdb_name_table[i] && strcmp(kdb_name_table[i], knt1) == 0)
48484 + if (i >= ARRAY_SIZE(kdb_name_table)) {
48485 + debug_kfree(kdb_name_table[0]);
48486 + memcpy(kdb_name_table, kdb_name_table+1,
48487 + sizeof(kdb_name_table[0])*(ARRAY_SIZE(kdb_name_table)-1));
48489 + debug_kfree(knt1);
48490 + knt1 = kdb_name_table[i];
48491 + memcpy(kdb_name_table+i, kdb_name_table+i+1,
48492 + sizeof(kdb_name_table[0])*(ARRAY_SIZE(kdb_name_table)-i-1));
48494 + i = ARRAY_SIZE(kdb_name_table) - 1;
48495 + kdb_name_table[i] = knt1;
48496 + symtab->sym_name = kdb_name_table[i];
48500 + if (symtab->mod_name == NULL)
48501 + symtab->mod_name = "kernel";
48502 + if (KDB_DEBUG(AR))
48503 + kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, symtab->mod_name=%p, symtab->sym_name=%p (%s)\n", ret, symtab->sym_start, symtab->mod_name, symtab->sym_name, symtab->sym_name);
48506 + debug_kfree(knt1);
48511 +kdbnearsym_cleanup(void)
48514 + for (i = 0; i < ARRAY_SIZE(kdb_name_table); ++i) {
48515 + if (kdb_name_table[i]) {
48516 + debug_kfree(kdb_name_table[i]);
48517 + kdb_name_table[i] = NULL;
48523 + * kallsyms_symbol_complete
48526 + * prefix_name prefix of a symbol name to lookup
48527 + * max_len maximum length that can be returned
48529 + * Number of symbols which match the given prefix.
48531 + * prefix_name is changed to contain the longest unique prefix that
48532 + * starts with this prefix (tab completion).
48535 +static char ks_namebuf[KSYM_NAME_LEN+1], ks_namebuf_prev[KSYM_NAME_LEN+1];
48537 +int kallsyms_symbol_complete(char *prefix_name, int max_len)
48540 + int prefix_len = strlen(prefix_name), prev_len = 0;
48541 + int i, number = 0;
48542 + const char *name;
48544 + while ((name = kdb_walk_kallsyms(&pos))) {
48545 + if (strncmp(name, prefix_name, prefix_len) == 0) {
48546 + strcpy(ks_namebuf, name);
48547 + /* Work out the longest name that matches the prefix */
48548 + if (++number == 1) {
48549 + prev_len = min_t(int, max_len-1, strlen(ks_namebuf));
48550 + memcpy(ks_namebuf_prev, ks_namebuf, prev_len);
48551 + ks_namebuf_prev[prev_len] = '\0';
48552 + } else for (i = 0; i < prev_len; ++i) {
48553 + if (ks_namebuf[i] != ks_namebuf_prev[i]) {
48555 + ks_namebuf_prev[i] = '\0';
48561 + if (prev_len > prefix_len)
48562 + memcpy(prefix_name, ks_namebuf_prev, prev_len+1);
48567 + * kallsyms_symbol_next
48570 + * prefix_name prefix of a symbol name to lookup
48571 + * flag 0 means search from the head, 1 means continue search.
48573 + * 1 if a symbol matches the given prefix.
48574 + * 0 if no string found
48577 +int kallsyms_symbol_next(char *prefix_name, int flag)
48579 + int prefix_len = strlen(prefix_name);
48580 + static loff_t pos;
48581 + const char *name;
48586 + while ((name = kdb_walk_kallsyms(&pos))) {
48587 + if (strncmp(name, prefix_name, prefix_len) == 0) {
48588 + strncpy(prefix_name, name, strlen(name)+1);
48595 +#if defined(CONFIG_SMP)
48599 + * This function is called from the non-maskable interrupt
48600 + * handler to handle a kdb IPI instruction.
48603 + * regs = Exception frame pointer
48607 + * 0 - Did not handle NMI
48608 + * 1 - Handled NMI
48612 + * Initially one processor is invoked in the kdb() code. That
48613 + * processor sends an ipi which drives this routine on the other
48614 + * processors. All this does is call kdb() with reason SWITCH.
48615 + * This puts all processors into the kdb() routine and all the
48616 + * code for breakpoints etc. is in one place.
48617 + * One problem with the way the kdb NMI is sent, the NMI has no
48618 + * identification that says it came from kdb. If the cpu's kdb state is
48619 + * marked as "waiting for kdb_ipi" then the NMI is treated as coming from
48620 + * kdb, otherwise it is assumed to be for another reason and is ignored.
48624 +kdb_ipi(struct pt_regs *regs, void (*ack_interrupt)(void))
48626 + /* Do not print before checking and clearing WAIT_IPI, IPIs are
48627 + * going all the time.
48629 + if (KDB_STATE(WAIT_IPI)) {
48631 + * Stopping other processors via smp_kdb_stop().
48633 + if (ack_interrupt)
48634 + (*ack_interrupt)(); /* Acknowledge the interrupt */
48635 + KDB_STATE_CLEAR(WAIT_IPI);
48636 + KDB_DEBUG_STATE("kdb_ipi 1", 0);
48637 + kdb(KDB_REASON_SWITCH, 0, regs); /* Spin in kdb() */
48638 + KDB_DEBUG_STATE("kdb_ipi 2", 0);
48643 +#endif /* CONFIG_SMP */
48646 + * kdb_symbol_print
48648 + * Standard method for printing a symbol name and offset.
48650 + * addr Address to be printed.
48651 + * symtab Address of symbol data, if NULL this routine does its
48653 + * punc Punctuation for string, bit field.
48661 + * The string and its punctuation is only printed if the address
48662 + * is inside the kernel, except that the value is always printed
48663 + * when requested.
48667 +kdb_symbol_print(kdb_machreg_t addr, const kdb_symtab_t *symtab_p, unsigned int punc)
48669 + kdb_symtab_t symtab, *symtab_p2;
48671 + symtab_p2 = (kdb_symtab_t *)symtab_p;
48674 + symtab_p2 = &symtab;
48675 + kdbnearsym(addr, symtab_p2);
48677 + if (symtab_p2->sym_name || (punc & KDB_SP_VALUE)) {
48678 + ; /* drop through */
48683 + if (punc & KDB_SP_SPACEB) {
48686 + if (punc & KDB_SP_VALUE) {
48687 + kdb_printf(kdb_machreg_fmt0, addr);
48689 + if (symtab_p2->sym_name) {
48690 + if (punc & KDB_SP_VALUE) {
48693 + if (punc & KDB_SP_PAREN) {
48696 + if (strcmp(symtab_p2->mod_name, "kernel")) {
48697 + kdb_printf("[%s]", symtab_p2->mod_name);
48699 + kdb_printf("%s", symtab_p2->sym_name);
48700 + if (addr != symtab_p2->sym_start) {
48701 + kdb_printf("+0x%lx", addr - symtab_p2->sym_start);
48703 + if (punc & KDB_SP_SYMSIZE) {
48704 + kdb_printf("/0x%lx", symtab_p2->sym_end - symtab_p2->sym_start);
48706 + if (punc & KDB_SP_PAREN) {
48710 + if (punc & KDB_SP_SPACEA) {
48713 + if (punc & KDB_SP_NEWLINE) {
48714 + kdb_printf("\n");
48721 + * kdb equivalent of strdup, for disasm code.
48723 + * str The string to duplicate.
48724 + * type Flags to kmalloc for the new string.
48728 + * Address of the new string, NULL if storage could not be allocated.
48732 + * This is not in lib/string.c because it uses kmalloc which is not
48733 + * available when string.o is used in boot loaders.
48736 +char *kdb_strdup(const char *str, gfp_t type)
48738 + int n = strlen(str)+1;
48739 + char *s = kmalloc(n, type);
48740 + if (!s) return NULL;
48741 + return strcpy(s, str);
48745 + * kdb_getarea_size
48747 + * Read an area of data. The kdb equivalent of copy_from_user, with
48748 + * kdb messages for invalid addresses.
48750 + * res Pointer to the area to receive the result.
48751 + * addr Address of the area to copy.
48752 + * size Size of the area.
48756 + * 0 for success, < 0 for error.
48761 +int kdb_getarea_size(void *res, unsigned long addr, size_t size)
48763 + int ret = kdba_getarea_size(res, addr, size);
48765 + if (!KDB_STATE(SUPPRESS)) {
48766 + kdb_printf("kdb_getarea: Bad address 0x%lx\n", addr);
48767 + KDB_STATE_SET(SUPPRESS);
48769 + ret = KDB_BADADDR;
48772 + KDB_STATE_CLEAR(SUPPRESS);
48778 + * kdb_putarea_size
48780 + * Write an area of data. The kdb equivalent of copy_to_user, with
48781 + * kdb messages for invalid addresses.
48783 + * addr Address of the area to write to.
48784 + * res Pointer to the area holding the data.
48785 + * size Size of the area.
48789 + * 0 for success, < 0 for error.
48794 +int kdb_putarea_size(unsigned long addr, void *res, size_t size)
48796 + int ret = kdba_putarea_size(addr, res, size);
48798 + if (!KDB_STATE(SUPPRESS)) {
48799 + kdb_printf("kdb_putarea: Bad address 0x%lx\n", addr);
48800 + KDB_STATE_SET(SUPPRESS);
48802 + ret = KDB_BADADDR;
48805 + KDB_STATE_CLEAR(SUPPRESS);
48813 + * Read data from a physical address. Validate the address is in range,
48814 + * use kmap_atomic() to get data
48816 + * Similar to kdb_getarea() - but for phys addresses
48819 + * res Pointer to the word to receive the result
48820 + * addr Physical address of the area to copy
48821 + * size Size of the area
48825 + * 0 for success, < 0 for error.
48829 +static int kdb_getphys(void *res, unsigned long addr, size_t size)
48831 + unsigned long pfn;
48833 + struct page *page;
48835 + pfn = (addr >> PAGE_SHIFT);
48836 + if (!pfn_valid(pfn))
48838 + page = pfn_to_page(pfn);
48839 + vaddr = kmap_atomic(page, KM_KDB);
48840 + memcpy(res, vaddr + (addr & (PAGE_SIZE -1)), size);
48841 + kunmap_atomic(vaddr, KM_KDB);
48847 + * kdb_getphysword
48850 + * word Pointer to the word to receive the result.
48851 + * addr Address of the area to copy.
48852 + * size Size of the area.
48856 + * 0 for success, < 0 for error.
48860 +int kdb_getphysword(unsigned long *word, unsigned long addr, size_t size)
48867 + *word = 0; /* Default value if addr or size is invalid */
48871 + if (!(diag = kdb_getphys(&w1, addr, sizeof(w1))))
48875 + if (!(diag = kdb_getphys(&w2, addr, sizeof(w2))))
48879 + if (!(diag = kdb_getphys(&w4, addr, sizeof(w4))))
48883 + if (size <= sizeof(*word)) {
48884 + if (!(diag = kdb_getphys(&w8, addr, sizeof(w8))))
48888 + /* drop through */
48890 + diag = KDB_BADWIDTH;
48891 + kdb_printf("kdb_getphysword: bad width %ld\n", (long) size);
48899 + * Read a binary value. Unlike kdb_getarea, this treats data as numbers.
48901 + * word Pointer to the word to receive the result.
48902 + * addr Address of the area to copy.
48903 + * size Size of the area.
48907 + * 0 for success, < 0 for error.
48912 +int kdb_getword(unsigned long *word, unsigned long addr, size_t size)
48919 + *word = 0; /* Default value if addr or size is invalid */
48922 + if (!(diag = kdb_getarea(w1, addr)))
48926 + if (!(diag = kdb_getarea(w2, addr)))
48930 + if (!(diag = kdb_getarea(w4, addr)))
48934 + if (size <= sizeof(*word)) {
48935 + if (!(diag = kdb_getarea(w8, addr)))
48939 + /* drop through */
48941 + diag = KDB_BADWIDTH;
48942 + kdb_printf("kdb_getword: bad width %ld\n", (long) size);
48950 + * Write a binary value. Unlike kdb_putarea, this treats data as numbers.
48952 + * addr Address of the area to write to..
48953 + * word The value to set.
48954 + * size Size of the area.
48958 + * 0 for success, < 0 for error.
48963 +int kdb_putword(unsigned long addr, unsigned long word, size_t size)
48973 + diag = kdb_putarea(addr, w1);
48977 + diag = kdb_putarea(addr, w2);
48981 + diag = kdb_putarea(addr, w4);
48984 + if (size <= sizeof(word)) {
48986 + diag = kdb_putarea(addr, w8);
48989 + /* drop through */
48991 + diag = KDB_BADWIDTH;
48992 + kdb_printf("kdb_putword: bad width %ld\n", (long) size);
48998 + * kdb_task_state_string
49000 + * Convert a string containing any of the letters DRSTCZEUIMA to a mask
49001 + * for the process state field and return the value. If no argument is
49002 + * supplied, return the mask that corresponds to environment variable PS,
49003 + * DRSTCZEU by default.
49005 + * s String to convert
49009 + * Mask for process state.
49013 + * The mask folds data from several sources into a single long value, so
49014 + * be carefull not to overlap the bits. TASK_* bits are in the LSB,
49015 + * special cases like UNRUNNABLE are in the MSB. As of 2.6.10-rc1 there
49016 + * is no overlap between TASK_* and EXIT_* but that may not always be
49017 + * true, so EXIT_* bits are shifted left 16 bits before being stored in
49021 +#define UNRUNNABLE (1UL << (8*sizeof(unsigned long) - 1)) /* unrunnable is < 0 */
49022 +#define RUNNING (1UL << (8*sizeof(unsigned long) - 2))
49023 +#define IDLE (1UL << (8*sizeof(unsigned long) - 3))
49024 +#define DAEMON (1UL << (8*sizeof(unsigned long) - 4))
49027 +kdb_task_state_string(const char *s)
49030 + if (!s && !(s = kdbgetenv("PS"))) {
49031 + s = "DRSTCZEU"; /* default value for ps */
49035 + case 'D': res |= TASK_UNINTERRUPTIBLE; break;
49036 + case 'R': res |= RUNNING; break;
49037 + case 'S': res |= TASK_INTERRUPTIBLE; break;
49038 + case 'T': res |= TASK_STOPPED; break;
49039 + case 'C': res |= TASK_TRACED; break;
49040 + case 'Z': res |= EXIT_ZOMBIE << 16; break;
49041 + case 'E': res |= EXIT_DEAD << 16; break;
49042 + case 'U': res |= UNRUNNABLE; break;
49043 + case 'I': res |= IDLE; break;
49044 + case 'M': res |= DAEMON; break;
49045 + case 'A': res = ~0UL; break;
49047 + kdb_printf("%s: unknown flag '%c' ignored\n", __FUNCTION__, *s);
49056 + * kdb_task_state_char
49058 + * Return the character that represents the task state.
49060 + * p struct task for the process
49064 + * One character to represent the task state.
49070 +kdb_task_state_char (const struct task_struct *p)
49072 + int cpu = kdb_process_cpu(p);
49073 + struct kdb_running_process *krp = kdb_running_process + cpu;
49074 + char state = (p->state == 0) ? 'R' :
49075 + (p->state < 0) ? 'U' :
49076 + (p->state & TASK_UNINTERRUPTIBLE) ? 'D' :
49077 + (p->state & TASK_STOPPED) ? 'T' :
49078 + (p->state & TASK_TRACED) ? 'C' :
49079 + (p->exit_state & EXIT_ZOMBIE) ? 'Z' :
49080 + (p->exit_state & EXIT_DEAD) ? 'E' :
49081 + (p->state & TASK_INTERRUPTIBLE) ? 'S' : '?';
49082 + if (p->pid == 0) {
49083 + /* Idle task. Is it really idle, apart from the kdb interrupt? */
49084 + if (!kdb_task_has_cpu(p) || krp->irq_depth == 1) {
49085 + /* There is a corner case when the idle task takes an
49086 + * interrupt and dies in the interrupt code. It has an
49087 + * interrupt count of 1 but that did not come from kdb.
49088 + * This corner case can only occur on the initial cpu,
49089 + * all the others were entered via the kdb IPI.
49091 + if (cpu != kdb_initial_cpu || KDB_STATE_CPU(KEYBOARD, cpu))
49092 + state = 'I'; /* idle task */
49095 + else if (!p->mm && state == 'S') {
49096 + state = 'M'; /* sleeping system daemon */
49104 + * Return true if a process has the desired state given by the mask.
49106 + * p struct task for the process
49107 + * mask mask from kdb_task_state_string to select processes
49111 + * True if the process matches at least one criteria defined by the mask.
49117 +kdb_task_state(const struct task_struct *p, unsigned long mask)
49119 + char state[] = { kdb_task_state_char(p), '\0' };
49120 + return (mask & kdb_task_state_string(state)) != 0;
49123 +struct kdb_running_process kdb_running_process[NR_CPUS];
49126 + * kdb_save_running
49128 + * Save the state of a running process. This is invoked on the current
49129 + * process on each cpu (assuming the cpu is responding).
49131 + * regs struct pt_regs for the process
49133 + * Updates kdb_running_process[] for this cpu.
49141 +kdb_save_running(struct pt_regs *regs)
49143 + struct kdb_running_process *krp = kdb_running_process + smp_processor_id();
49144 + krp->p = current;
49145 + krp->regs = regs;
49146 + krp->seqno = kdb_seqno;
49147 + krp->irq_depth = hardirq_count() >> HARDIRQ_SHIFT;
49148 + kdba_save_running(&(krp->arch), regs);
49152 + * kdb_unsave_running
49154 + * Reverse the effect of kdb_save_running.
49156 + * regs struct pt_regs for the process
49158 + * Updates kdb_running_process[] for this cpu.
49166 +kdb_unsave_running(struct pt_regs *regs)
49168 + struct kdb_running_process *krp = kdb_running_process + smp_processor_id();
49169 + kdba_unsave_running(&(krp->arch), regs);
49175 + * kdb_print_nameval
49177 + * Print a name and its value, converting the value to a symbol lookup
49180 + * name field name to print
49181 + * val value of field
49191 +kdb_print_nameval(const char *name, unsigned long val)
49193 + kdb_symtab_t symtab;
49194 + kdb_printf(" %-11.11s ", name);
49195 + if (kdbnearsym(val, &symtab))
49196 + kdb_symbol_print(val, &symtab, KDB_SP_VALUE|KDB_SP_SYMSIZE|KDB_SP_NEWLINE);
49198 + kdb_printf("0x%lx\n", val);
49201 +static struct page * kdb_get_one_user_page(const struct task_struct *tsk, unsigned long start,
49202 + int len, int write)
49204 + struct mm_struct *mm = tsk->mm;
49205 + unsigned int flags;
49206 + struct vm_area_struct * vma;
49208 + /* shouldn't cross a page boundary. */
49209 + if ((start & PAGE_MASK) != ((start+len) & PAGE_MASK))
49212 + /* we need to align start address to the current page boundy, PAGE_ALIGN
49213 + * aligns to next page boundry.
49214 + * FIXME: What about hugetlb?
49216 + start = start & PAGE_MASK;
49217 + flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
49219 + vma = find_extend_vma(mm, start);
49221 + /* may be we can allow access to VM_IO pages inside KDB? */
49222 + if (!vma || (vma->vm_flags & VM_IO) || !(flags & vma->vm_flags))
49225 + return follow_page(vma, start, write ? FOLL_WRITE : 0);
49228 +int kdb_getuserarea_size(void *to, unsigned long from, size_t size)
49230 + struct page *page;
49233 + page = kdb_get_one_user_page(kdb_current_task, from, size, 0);
49237 + vaddr = kmap_atomic(page, KM_KDB);
49238 + memcpy(to, vaddr+ (from & (PAGE_SIZE - 1)), size);
49239 + kunmap_atomic(vaddr, KM_KDB);
49244 +int kdb_putuserarea_size(unsigned long to, void *from, size_t size)
49246 + struct page *page;
49249 + page = kdb_get_one_user_page(kdb_current_task, to, size, 1);
49253 + vaddr = kmap_atomic(page, KM_KDB);
49254 + memcpy(vaddr+ (to & (PAGE_SIZE - 1)), from, size);
49255 + kunmap_atomic(vaddr, KM_KDB);
49260 +/* Last ditch allocator for debugging, so we can still debug even when the
49261 + * GFP_ATOMIC pool has been exhausted. The algorithms are tuned for space
49262 + * usage, not for speed. One smallish memory pool, the free chain is always in
49263 + * ascending address order to allow coalescing, allocations are done in brute
49264 + * force best fit.
49267 +struct debug_alloc_header {
49268 + u32 next; /* offset of next header from start of pool */
49273 +/* The memory returned by this allocator must be aligned, which means so must
49274 + * the header size. Do not assume that sizeof(struct debug_alloc_header) is a
49275 + * multiple of the alignment, explicitly calculate the overhead of this header,
49276 + * including the alignment. The rest of this code must not use sizeof() on any
49277 + * header or pointer to a header.
49279 +#define dah_align 8
49280 +#define dah_overhead ALIGN(sizeof(struct debug_alloc_header), dah_align)
49282 +static u64 debug_alloc_pool_aligned[128*1024/dah_align]; /* 128K pool */
49283 +static char *debug_alloc_pool = (char *)debug_alloc_pool_aligned;
49284 +static u32 dah_first, dah_first_call = 1, dah_used = 0, dah_used_max = 0;
49286 +/* Locking is awkward. The debug code is called from all contexts, including
49287 + * non maskable interrupts. A normal spinlock is not safe in NMI context. Try
49288 + * to get the debug allocator lock, if it cannot be obtained after a second
49289 + * then give up. If the lock could not be previously obtained on this cpu then
49292 + * sparse has no annotation for "this function _sometimes_ acquires a lock", so
49293 + * fudge the acquire/release notation.
49295 +static DEFINE_SPINLOCK(dap_lock);
49297 +get_dap_lock(void)
49298 + __acquires(dap_lock)
49300 + static int dap_locked = -1;
49302 + if (dap_locked == smp_processor_id())
49307 + if (spin_trylock(&dap_lock)) {
49315 + dap_locked = smp_processor_id();
49316 + __acquire(dap_lock);
49321 +*debug_kmalloc(size_t size, gfp_t flags)
49323 + unsigned int rem, h_offset;
49324 + struct debug_alloc_header *best, *bestprev, *prev, *h;
49326 + if (!get_dap_lock()) {
49327 + __release(dap_lock); /* we never actually got it */
49330 + h = (struct debug_alloc_header *)(debug_alloc_pool + dah_first);
49331 + if (dah_first_call) {
49332 + h->size = sizeof(debug_alloc_pool_aligned) - dah_overhead;
49333 + dah_first_call = 0;
49335 + size = ALIGN(size, dah_align);
49336 + prev = best = bestprev = NULL;
49338 + if (h->size >= size && (!best || h->size < best->size)) {
49341 + if (h->size == size)
49347 + h = (struct debug_alloc_header *)(debug_alloc_pool + h->next);
49351 + rem = best->size - size;
49352 + /* The pool must always contain at least one header */
49353 + if (best->next == 0 && bestprev == NULL && rem < dah_overhead)
49355 + if (rem >= dah_overhead) {
49356 + best->size = size;
49357 + h_offset = ((char *)best - debug_alloc_pool) +
49358 + dah_overhead + best->size;
49359 + h = (struct debug_alloc_header *)(debug_alloc_pool + h_offset);
49360 + h->size = rem - dah_overhead;
49361 + h->next = best->next;
49363 + h_offset = best->next;
49364 + best->caller = __builtin_return_address(0);
49365 + dah_used += best->size;
49366 + dah_used_max = max(dah_used, dah_used_max);
49368 + bestprev->next = h_offset;
49370 + dah_first = h_offset;
49371 + p = (char *)best + dah_overhead;
49372 + memset(p, POISON_INUSE, best->size - 1);
49373 + *((char *)p + best->size - 1) = POISON_END;
49375 + spin_unlock(&dap_lock);
49380 +debug_kfree(void *p)
49382 + struct debug_alloc_header *h;
49383 + unsigned int h_offset;
49386 + if ((char *)p < debug_alloc_pool ||
49387 + (char *)p >= debug_alloc_pool + sizeof(debug_alloc_pool_aligned)) {
49391 + if (!get_dap_lock()) {
49392 + __release(dap_lock); /* we never actually got it */
49393 + return; /* memory leak, cannot be helped */
49395 + h = (struct debug_alloc_header *)((char *)p - dah_overhead);
49396 + memset(p, POISON_FREE, h->size - 1);
49397 + *((char *)p + h->size - 1) = POISON_END;
49398 + h->caller = NULL;
49399 + dah_used -= h->size;
49400 + h_offset = (char *)h - debug_alloc_pool;
49401 + if (h_offset < dah_first) {
49402 + h->next = dah_first;
49403 + dah_first = h_offset;
49405 + struct debug_alloc_header *prev;
49406 + unsigned int prev_offset;
49407 + prev = (struct debug_alloc_header *)(debug_alloc_pool + dah_first);
49409 + if (!prev->next || prev->next > h_offset)
49411 + prev = (struct debug_alloc_header *)
49412 + (debug_alloc_pool + prev->next);
49414 + prev_offset = (char *)prev - debug_alloc_pool;
49415 + if (prev_offset + dah_overhead + prev->size == h_offset) {
49416 + prev->size += dah_overhead + h->size;
49417 + memset(h, POISON_FREE, dah_overhead - 1);
49418 + *((char *)h + dah_overhead - 1) = POISON_END;
49420 + h_offset = prev_offset;
49422 + h->next = prev->next;
49423 + prev->next = h_offset;
49426 + if (h_offset + dah_overhead + h->size == h->next) {
49427 + struct debug_alloc_header *next;
49428 + next = (struct debug_alloc_header *)
49429 + (debug_alloc_pool + h->next);
49430 + h->size += dah_overhead + next->size;
49431 + h->next = next->next;
49432 + memset(next, POISON_FREE, dah_overhead - 1);
49433 + *((char *)next + dah_overhead - 1) = POISON_END;
49435 + spin_unlock(&dap_lock);
49439 +debug_kusage(void)
49441 + struct debug_alloc_header *h_free, *h_used;
49442 +#ifdef CONFIG_IA64
49443 + /* FIXME: using dah for ia64 unwind always results in a memory leak.
49444 + * Fix that memory leak first, then set debug_kusage_one_time = 1 for
49445 + * all architectures.
49447 + static int debug_kusage_one_time = 0;
49449 + static int debug_kusage_one_time = 1;
49451 + if (!get_dap_lock()) {
49452 + __release(dap_lock); /* we never actually got it */
49455 + h_free = (struct debug_alloc_header *)(debug_alloc_pool + dah_first);
49456 + if (dah_first == 0 &&
49457 + (h_free->size == sizeof(debug_alloc_pool_aligned) - dah_overhead ||
49460 + if (!debug_kusage_one_time)
49462 + debug_kusage_one_time = 0;
49463 + kdb_printf("%s: debug_kmalloc memory leak dah_first %d\n",
49464 + __FUNCTION__, dah_first);
49466 + h_used = (struct debug_alloc_header *)debug_alloc_pool;
49467 + kdb_printf("%s: h_used %p size %d\n", __FUNCTION__, h_used, h_used->size);
49470 + h_used = (struct debug_alloc_header *)
49471 + ((char *)h_free + dah_overhead + h_free->size);
49472 + kdb_printf("%s: h_used %p size %d caller %p\n",
49473 + __FUNCTION__, h_used, h_used->size, h_used->caller);
49474 + h_free = (struct debug_alloc_header *)
49475 + (debug_alloc_pool + h_free->next);
49476 + } while (h_free->next);
49477 + h_used = (struct debug_alloc_header *)
49478 + ((char *)h_free + dah_overhead + h_free->size);
49479 + if ((char *)h_used - debug_alloc_pool !=
49480 + sizeof(debug_alloc_pool_aligned))
49481 + kdb_printf("%s: h_used %p size %d caller %p\n",
49482 + __FUNCTION__, h_used, h_used->size, h_used->caller);
49484 + spin_unlock(&dap_lock);
49487 +/* Maintain a small stack of kdb_flags to allow recursion without disturbing
49488 + * the global kdb state.
49491 +static int kdb_flags_stack[4], kdb_flags_index;
49494 +kdb_save_flags(void)
49496 + BUG_ON(kdb_flags_index >= ARRAY_SIZE(kdb_flags_stack));
49497 + kdb_flags_stack[kdb_flags_index++] = kdb_flags;
49501 +kdb_restore_flags(void)
49503 + BUG_ON(kdb_flags_index <= 0);
49504 + kdb_flags = kdb_flags_stack[--kdb_flags_index];
49506 diff -Nurp linux-2.6.22-590/kdb/Makefile linux-2.6.22-600/kdb/Makefile
49507 --- linux-2.6.22-590/kdb/Makefile 1970-01-01 01:00:00.000000000 +0100
49508 +++ linux-2.6.22-600/kdb/Makefile 2008-04-09 18:14:28.000000000 +0200
49511 +# This file is subject to the terms and conditions of the GNU General Public
49512 +# License. See the file "COPYING" in the main directory of this archive
49513 +# for more details.
49515 +# Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
49518 +obj-y := kdb_bt.o kdb_bp.o kdb_id.o kdbsupport.o gen-kdb_cmds.o kdbmain.o kdb_io.o
49520 +# The i386 and x86_64 backtrace commands are handled by common code.
49522 + obj-y += kdba_bt_x86.o
49523 + ifneq (,$(findstring -fno-optimize-sibling-calls,$(CFLAGS)))
49524 + CFLAGS_kdba_bt_x86.o += -DNO_SIBLINGS
49526 + REGPARM := $(subst -mregparm=,,$(filter -mregparm=%,$(CFLAGS)))
49527 + ifeq (,$(REGPARM))
49528 + ifdef CONFIG_X86_64
49534 + CFLAGS_kdba_bt_x86.o += -DREGPARM=$(REGPARM)
49537 +subdir-$(CONFIG_KDB_MODULES) := modules
49538 +obj-y += $(addsuffix /built-in.o, $(subdir-y))
49540 +clean-files := gen-kdb_cmds.c
49542 +override CFLAGS := $(CFLAGS:%-pg=% )
49544 +quiet_cmd_gen-kdb = GENKDB $@
49545 + cmd_gen-kdb = $(AWK) 'BEGIN {print "\#include <linux/stddef.h>"; print "\#include <linux/init.h>"} \
49547 + /^[ \t]*$$/{next} \
49548 + {gsub(/"/, "\\\"", $$0); \
49549 + print "static __initdata char kdb_cmd" cmds++ "[] = \"" $$0 "\\n\";"} \
49550 + END {print "extern char *kdb_cmds[]; char __initdata *kdb_cmds[] = {"; for (i = 0; i < cmds; ++i) {print " kdb_cmd" i ","}; print(" NULL\n};");}' \
49551 + $(filter-out %/Makefile,$^) > $@
49553 +$(obj)/gen-kdb_cmds.c: $(src)/kdb_cmds $(wildcard $(TOPDIR)/arch/$(ARCH)/kdb/kdb_cmds) $(src)/Makefile
49554 + $(call cmd,gen-kdb)
49555 diff -Nurp linux-2.6.22-590/kdb/modules/kdbm_pg.c linux-2.6.22-600/kdb/modules/kdbm_pg.c
49556 --- linux-2.6.22-590/kdb/modules/kdbm_pg.c 1970-01-01 01:00:00.000000000 +0100
49557 +++ linux-2.6.22-600/kdb/modules/kdbm_pg.c 2008-04-09 18:14:28.000000000 +0200
49560 + * This file is subject to the terms and conditions of the GNU General Public
49561 + * License. See the file "COPYING" in the main directory of this archive
49562 + * for more details.
49564 + * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
49567 +#include <linux/module.h>
49568 +#include <linux/init.h>
49569 +#include <linux/mm.h>
49570 +#include <linux/pagemap.h>
49571 +#include <linux/fs.h>
49572 +#include <linux/bio.h>
49573 +#include <linux/buffer_head.h>
49574 +#include <linux/kdb.h>
49575 +#include <linux/kdbprivate.h>
49576 +#include <linux/blkdev.h>
49577 +#include <linux/ctype.h>
49579 +MODULE_AUTHOR("SGI");
49580 +MODULE_DESCRIPTION("Debug page information");
49581 +MODULE_LICENSE("GPL");
49583 +/* Standard Linux page stuff */
49585 +#ifndef CONFIG_DISCONTIGMEM
49586 +/* From include/linux/page-flags.h */
49587 +static char *pg_flag_vals[] = {
49588 + "PG_locked", "PG_error", "PG_referenced", "PG_uptodate",
49589 + "PG_dirty", "PG_lru", "PG_active", "PG_slab",
49590 + "PG_checked", "PG_arch_1", "PG_reserved", "PG_private",
49591 + "PG_writeback", "?? 13 ??", "PG_compound", "PG_swapcache",
49592 + "PG_mappedtodisk", "PG_reclaim", "?? 18 ??", "PG_buddy",
49596 +/* From include/linux/buffer_head.h */
49597 +static char *bh_state_vals[] = {
49598 + "Uptodate", "Dirty", "Lock", "Req",
49599 + "Uptodate_Lock", "Mapped", "New", "Async_read",
49600 + "Async_write", "Delay", "Boundary", "Write_EIO",
49601 + "Ordered", "Eopnotsupp", "Unwritten", "Private",
49604 +/* From include/linux/bio.h */
49605 +static char *bio_flag_vals[] = {
49606 + "Uptodate", "RW_block", "EOF", "Seg_valid",
49607 + "Cloned", "Bounced", "User_mapped", "Eopnotsupp",
49610 +/* From include/linux/fs.h */
49611 +static char *inode_flag_vals[] = {
49612 + "I_DIRTY_SYNC", "I_DIRTY_DATASYNC", "I_DIRTY_PAGES", "I_LOCK",
49613 + "I_FREEING", "I_CLEAR", "I_NEW", "I_WILL_FREE",
49616 +static char *map_flags(unsigned long flags, char *mapping[])
49618 + static char buffer[256];
49622 + buffer[0] = '\0';
49624 + for (index = 0; flags && mapping[index]; flags >>= 1, index++) {
49626 + if ((offset + strlen(mapping[index]) + 1) >= 80) {
49627 + strcat(buffer, "\n ");
49629 + } else if (offset > 12) {
49630 + strcat(buffer, " ");
49633 + strcat(buffer, mapping[index]);
49634 + offset += strlen(mapping[index]);
49642 +kdbm_buffers(int argc, const char **argv)
49644 + struct buffer_head bh;
49645 + unsigned long addr;
49651 + return KDB_ARGCOUNT;
49654 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
49655 + (diag = kdb_getarea(bh, addr)))
49658 + kdb_printf("buffer_head at 0x%lx\n", addr);
49659 + kdb_printf(" bno %llu size %llu dev 0x%x\n",
49660 + (unsigned long long)bh.b_blocknr,
49661 + (unsigned long long)bh.b_size,
49662 + bh.b_bdev ? bh.b_bdev->bd_dev : 0);
49663 + kdb_printf(" count %d state 0x%lx [%s]\n",
49664 + bh.b_count.counter, bh.b_state,
49665 + map_flags(bh.b_state, bh_state_vals));
49666 + kdb_printf(" b_data 0x%p\n",
49668 + kdb_printf(" b_page 0x%p b_this_page 0x%p b_private 0x%p\n",
49669 + bh.b_page, bh.b_this_page, bh.b_private);
49670 + kdb_printf(" b_end_io ");
49672 + kdb_symbol_print(kdba_funcptr_value(bh.b_end_io), NULL, KDB_SP_VALUE);
49674 + kdb_printf("(NULL)");
49675 + kdb_printf("\n");
49681 +print_biovec(struct bio_vec *vec, int vcount)
49683 + struct bio_vec bvec;
49684 + unsigned long addr;
49688 + if (vcount < 1 || vcount > BIO_MAX_PAGES) {
49689 + kdb_printf(" [skipped iovecs, vcnt is %d]\n", vcount);
49693 + addr = (unsigned long)vec;
49694 + for (i = 0; i < vcount; i++) {
49695 + if ((diag = kdb_getarea(bvec, addr)))
49697 + addr += sizeof(bvec);
49698 + kdb_printf(" [%d] page 0x%p length=%u offset=%u\n",
49699 + i, bvec.bv_page, bvec.bv_len, bvec.bv_offset);
49705 +kdbm_bio(int argc, const char **argv)
49708 + unsigned long addr;
49714 + return KDB_ARGCOUNT;
49717 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
49718 + (diag = kdb_getarea(bio, addr)))
49721 + kdb_printf("bio at 0x%lx\n", addr);
49722 + kdb_printf(" bno %llu next 0x%p dev 0x%x\n",
49723 + (unsigned long long)bio.bi_sector,
49724 + bio.bi_next, bio.bi_bdev ? bio.bi_bdev->bd_dev : 0);
49725 + kdb_printf(" vcnt %u vec 0x%p rw 0x%lx flags 0x%lx [%s]\n",
49726 + bio.bi_vcnt, bio.bi_io_vec, bio.bi_rw, bio.bi_flags,
49727 + map_flags(bio.bi_flags, bio_flag_vals));
49728 + print_biovec(bio.bi_io_vec, bio.bi_vcnt);
49729 + kdb_printf(" count %d private 0x%p\n",
49730 + atomic_read(&bio.bi_cnt), bio.bi_private);
49731 + kdb_printf(" bi_end_io ");
49732 + if (bio.bi_end_io)
49733 + kdb_symbol_print(kdba_funcptr_value(bio.bi_end_io), NULL, KDB_SP_VALUE);
49735 + kdb_printf("(NULL)");
49736 + kdb_printf("\n");
49741 +#ifndef CONFIG_DISCONTIGMEM
49742 +static char *page_flags(unsigned long flags)
49744 + return(map_flags(flags, pg_flag_vals));
49748 +kdbm_page(int argc, const char **argv)
49750 + struct page page;
49751 + unsigned long addr;
49757 + return KDB_ARGCOUNT;
49760 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
49765 + if (rgn_index(addr) == 0)
49766 + addr = (unsigned long) &mem_map[addr]; /* assume region 0 is a page index, not an address */
49768 + if (addr < PAGE_OFFSET)
49769 + addr = (unsigned long) &mem_map[addr];
49772 + if ((diag = kdb_getarea(page, addr)))
49775 + kdb_printf("struct page at 0x%lx\n", addr);
49776 + kdb_printf(" addr space 0x%p index %lu (offset 0x%llx)\n",
49777 + page.mapping, page.index,
49778 + (unsigned long long)page.index << PAGE_CACHE_SHIFT);
49779 + kdb_printf(" count %d flags %s\n",
49780 + page._count.counter, page_flags(page.flags));
49781 + kdb_printf(" virtual 0x%p\n", page_address((struct page *)addr));
49782 + if (page_has_buffers(&page))
49783 + kdb_printf(" buffers 0x%p\n", page_buffers(&page));
49785 + kdb_printf(" private 0x%lx\n", page_private(&page));
49789 +#endif /* CONFIG_DISCONTIGMEM */
49791 +static unsigned long
49792 +print_request(unsigned long addr)
49794 + struct request rq;
49796 + if (kdb_getarea(rq, addr))
49799 + kdb_printf("struct request at 0x%lx\n", addr);
49800 + kdb_printf(" errors %d sector %llu nr_sectors %lu\n",
49802 + (unsigned long long)rq.sector, rq.nr_sectors);
49804 + kdb_printf(" hsect %llu hnrsect %lu nrseg %u nrhwseg %u currnrsect %u\n",
49805 + (unsigned long long)rq.hard_sector, rq.hard_nr_sectors,
49806 + rq.nr_phys_segments, rq.nr_hw_segments,
49807 + rq.current_nr_sectors);
49809 + return (unsigned long) rq.queuelist.next;
49813 +kdbm_request(int argc, const char **argv)
49816 + unsigned long addr;
49821 + return KDB_ARGCOUNT;
49824 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
49828 + print_request(addr);
49834 +kdbm_rqueue(int argc, const char **argv)
49836 + struct request_queue rq;
49837 + unsigned long addr, head_addr, next;
49843 + return KDB_ARGCOUNT;
49846 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
49847 + (diag = kdb_getarea(rq, addr)))
49850 + kdb_printf("struct request_queue at 0x%lx\n", addr);
49852 + next = (unsigned long)rq.queue_head.next;
49853 + head_addr = addr + offsetof(struct request_queue, queue_head);
49854 + kdb_printf(" request queue: %s\n", next == head_addr ?
49856 + while (next != head_addr) {
49858 + next = print_request(next);
49862 + kdb_printf("%d requests found\n", i);
49869 +do_buffer(unsigned long addr)
49871 + struct buffer_head bh;
49873 + if (kdb_getarea(bh, addr))
49876 + kdb_printf("\tbh 0x%lx bno %8llu [%s]\n", addr,
49877 + (unsigned long long)bh.b_blocknr,
49878 + map_flags(bh.b_state, bh_state_vals));
49882 +kdbm_show_page(struct page *page, int first)
49885 + kdb_printf("page_struct index cnt zone nid flags\n");
49886 + kdb_printf("%p%s %6lu %5d %3d %3d 0x%lx",
49887 + page_address(page), sizeof(void *) == 4 ? " " : "",
49888 + page->index, atomic_read(&(page->_count)),
49889 + page_zonenum(page), page_to_nid(page),
49890 + page->flags & (~0UL >> ZONES_SHIFT));
49891 +#define kdb_page_flags(page, type) if (Page ## type(page)) kdb_printf(" " #type);
49892 + kdb_page_flags(page, Locked);
49893 + kdb_page_flags(page, Error);
49894 + kdb_page_flags(page, Referenced);
49895 + kdb_page_flags(page, Uptodate);
49896 + kdb_page_flags(page, Dirty);
49897 + kdb_page_flags(page, LRU);
49898 + kdb_page_flags(page, Active);
49899 + kdb_page_flags(page, Slab);
49900 + kdb_page_flags(page, Checked);
49901 + if (page->flags & (1UL << PG_arch_1))
49902 + kdb_printf(" arch_1");
49903 + kdb_page_flags(page, Reserved);
49904 + kdb_page_flags(page, Private);
49905 + kdb_page_flags(page, Writeback);
49906 + kdb_page_flags(page, Compound);
49907 + kdb_page_flags(page, SwapCache);
49908 + kdb_page_flags(page, MappedToDisk);
49909 + kdb_page_flags(page, Reclaim);
49910 + kdb_page_flags(page, Buddy);
49912 + /* PageHighMem is not a flag any more, but treat it as one */
49913 + kdb_page_flags(page, HighMem);
49915 + if (page_has_buffers(page)) {
49916 + struct buffer_head *head, *bh;
49917 + kdb_printf("\n");
49918 + head = bh = page_buffers(page);
49920 + do_buffer((unsigned long) bh);
49921 + } while ((bh = bh->b_this_page) != head);
49922 + } else if (page_private(page)) {
49923 + kdb_printf(" private= 0x%lx", page_private(page));
49925 + /* Cannot use page_mapping(page) here, it needs swapper_space which is
49928 + if (page->mapping)
49929 + kdb_printf(" mapping= %p", page->mapping);
49930 + kdb_printf("\n");
49931 +#undef kdb_page_flags
49935 +kdbm_inode_pages(int argc, const char **argv)
49937 + struct inode *inode = NULL;
49938 + struct address_space *ap = NULL;
49939 + unsigned long addr, addr1 = 0;
49943 + pgoff_t next = 0;
49944 + struct page *page;
49948 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
49954 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr1,
49958 + kdb_printf("Looking for page index 0x%lx ... \n", addr1);
49962 + if (!(inode = kmalloc(sizeof(*inode), GFP_ATOMIC))) {
49963 + kdb_printf("kdbm_inode_pages: cannot kmalloc inode\n");
49966 + if (!(ap = kmalloc(sizeof(*ap), GFP_ATOMIC))) {
49967 + kdb_printf("kdbm_inode_pages: cannot kmalloc ap\n");
49970 + if ((diag = kdb_getarea(*inode, addr)))
49972 + if (!inode->i_mapping) {
49973 + kdb_printf("inode has no mapping\n");
49976 + if ((diag = kdb_getarea(*ap, (unsigned long) inode->i_mapping)))
49979 + /* Run the pages in the radix tree, printing the state of each page */
49981 + while (radix_tree_gang_lookup(&ap->page_tree, (void **)&page, next, 1)) {
49982 + kdbm_show_page(page, first);
49986 + next = page->index + 1;
49998 +kdbm_inode(int argc, const char **argv)
50000 + struct inode *inode = NULL;
50001 + unsigned long addr;
50002 + unsigned char *iaddr;
50008 + return KDB_ARGCOUNT;
50011 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
50013 + if (!(inode = kmalloc(sizeof(*inode), GFP_ATOMIC))) {
50014 + kdb_printf("kdbm_inode: cannot kmalloc inode\n");
50017 + if ((diag = kdb_getarea(*inode, addr)))
50020 + kdb_printf("struct inode at 0x%lx\n", addr);
50022 + kdb_printf(" i_ino = %lu i_count = %u i_size %Ld\n",
50023 + inode->i_ino, atomic_read(&inode->i_count),
50026 + kdb_printf(" i_mode = 0%o i_nlink = %d i_rdev = 0x%x\n",
50027 + inode->i_mode, inode->i_nlink,
50030 + kdb_printf(" i_hash.nxt = 0x%p i_hash.pprev = 0x%p\n",
50031 + inode->i_hash.next,
50032 + inode->i_hash.pprev);
50034 + kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
50035 + list_entry(inode->i_list.next, struct inode, i_list),
50036 + list_entry(inode->i_list.prev, struct inode, i_list));
50038 + kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
50039 + list_entry(inode->i_dentry.next, struct dentry, d_alias),
50040 + list_entry(inode->i_dentry.prev, struct dentry, d_alias));
50042 + kdb_printf(" i_sb = 0x%p i_op = 0x%p i_data = 0x%lx nrpages = %lu\n",
50043 + inode->i_sb, inode->i_op,
50044 + addr + offsetof(struct inode, i_data),
50045 + inode->i_data.nrpages);
50046 + kdb_printf(" i_fop= 0x%p i_flock = 0x%p i_mapping = 0x%p\n",
50047 + inode->i_fop, inode->i_flock, inode->i_mapping);
50049 + kdb_printf(" i_flags 0x%x i_state 0x%lx [%s]",
50050 + inode->i_flags, inode->i_state,
50051 + map_flags(inode->i_state, inode_flag_vals));
50053 + iaddr = (char *)addr;
50054 + iaddr += offsetof(struct inode, i_private);
50056 + kdb_printf(" fs specific info @ 0x%p\n", iaddr);
50064 +kdbm_sb(int argc, const char **argv)
50066 + struct super_block *sb = NULL;
50067 + unsigned long addr;
50073 + return KDB_ARGCOUNT;
50076 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
50078 + if (!(sb = kmalloc(sizeof(*sb), GFP_ATOMIC))) {
50079 + kdb_printf("kdbm_sb: cannot kmalloc sb\n");
50082 + if ((diag = kdb_getarea(*sb, addr)))
50085 + kdb_printf("struct super_block at 0x%lx\n", addr);
50086 + kdb_printf(" s_dev 0x%x blocksize 0x%lx\n", sb->s_dev, sb->s_blocksize);
50087 + kdb_printf(" s_flags 0x%lx s_root 0x%p\n", sb->s_flags, sb->s_root);
50088 + kdb_printf(" s_dirt %d s_dirty.next 0x%p s_dirty.prev 0x%p\n",
50089 + sb->s_dirt, sb->s_dirty.next, sb->s_dirty.prev);
50090 + kdb_printf(" s_frozen %d s_id [%s]\n", sb->s_frozen, sb->s_id);
50099 +#if defined(CONFIG_X86) && !defined(CONFIG_X86_64)
50100 +/* According to Steve Lord, this code is ix86 specific. Patches to extend it to
50101 + * other architectures will be greatefully accepted.
50104 +kdbm_memmap(int argc, const char **argv)
50106 + struct page page;
50107 + int i, page_count;
50108 + int slab_count = 0;
50109 + int dirty_count = 0;
50110 + int locked_count = 0;
50111 + int page_counts[9];
50112 + int buffered_count = 0;
50113 +#ifdef buffer_delay
50114 + int delay_count = 0;
50117 + unsigned long addr;
50119 + addr = (unsigned long)mem_map;
50120 + page_count = max_mapnr;
50121 + memset(page_counts, 0, sizeof(page_counts));
50123 + for (i = 0; i < page_count; i++) {
50124 + if ((diag = kdb_getarea(page, addr)))
50126 + addr += sizeof(page);
50128 + if (PageSlab(&page))
50130 + if (PageDirty(&page))
50132 + if (PageLocked(&page))
50134 + if (page._count.counter < 8)
50135 + page_counts[page._count.counter]++;
50137 + page_counts[8]++;
50138 + if (page_has_buffers(&page)) {
50139 + buffered_count++;
50140 +#ifdef buffer_delay
50141 + if (buffer_delay(page.buffers))
50148 + kdb_printf(" Total pages: %6d\n", page_count);
50149 + kdb_printf(" Slab pages: %6d\n", slab_count);
50150 + kdb_printf(" Dirty pages: %6d\n", dirty_count);
50151 + kdb_printf(" Locked pages: %6d\n", locked_count);
50152 + kdb_printf(" Buffer pages: %6d\n", buffered_count);
50153 +#ifdef buffer_delay
50154 + kdb_printf(" Delalloc pages: %6d\n", delay_count);
50156 + for (i = 0; i < 8; i++) {
50157 + kdb_printf(" %d page count: %6d\n",
50158 + i, page_counts[i]);
50160 + kdb_printf(" high page count: %6d\n", page_counts[8]);
50163 +#endif /* CONFIG_X86 && !CONFIG_X86_64 */
50165 +static int __init kdbm_pg_init(void)
50167 +#ifndef CONFIG_DISCONTIGMEM
50168 + kdb_register("page", kdbm_page, "<vaddr>", "Display page", 0);
50170 + kdb_register("inode", kdbm_inode, "<vaddr>", "Display inode", 0);
50171 + kdb_register("sb", kdbm_sb, "<vaddr>", "Display super_block", 0);
50172 + kdb_register("bh", kdbm_buffers, "<buffer head address>", "Display buffer", 0);
50173 + kdb_register("bio", kdbm_bio, "<bio address>", "Display bio", 0);
50174 + kdb_register("inode_pages", kdbm_inode_pages, "<inode *>", "Display pages in an inode", 0);
50175 + kdb_register("req", kdbm_request, "<vaddr>", "dump request struct", 0);
50176 + kdb_register("rqueue", kdbm_rqueue, "<vaddr>", "dump request queue", 0);
50177 +#if defined(CONFIG_X86) && !defined(CONFIG_X86_64)
50178 + kdb_register("memmap", kdbm_memmap, "", "page table summary", 0);
50185 +static void __exit kdbm_pg_exit(void)
50187 +#ifndef CONFIG_DISCONTIGMEM
50188 + kdb_unregister("page");
50190 + kdb_unregister("inode");
50191 + kdb_unregister("sb");
50192 + kdb_unregister("bh");
50193 + kdb_unregister("bio");
50194 + kdb_unregister("inode_pages");
50195 + kdb_unregister("req");
50196 + kdb_unregister("rqueue");
50197 +#if defined(CONFIG_X86) && !defined(CONFIG_X86_64)
50198 + kdb_unregister("memmap");
50202 +module_init(kdbm_pg_init)
50203 +module_exit(kdbm_pg_exit)
50204 diff -Nurp linux-2.6.22-590/kdb/modules/kdbm_sched.c linux-2.6.22-600/kdb/modules/kdbm_sched.c
50205 --- linux-2.6.22-590/kdb/modules/kdbm_sched.c 1970-01-01 01:00:00.000000000 +0100
50206 +++ linux-2.6.22-600/kdb/modules/kdbm_sched.c 2008-04-09 18:14:28.000000000 +0200
50209 + * This file is subject to the terms and conditions of the GNU General Public
50210 + * License. See the file "COPYING" in the main directory of this archive
50211 + * for more details.
50213 + * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
50216 +#include <linux/kdb.h>
50217 +#include <linux/kdbprivate.h>
50218 +#include <linux/module.h>
50219 +#include <linux/init.h>
50220 +#include <linux/sched.h>
50222 +MODULE_AUTHOR("SGI");
50223 +MODULE_DESCRIPTION("Debug scheduler information");
50224 +MODULE_LICENSE("GPL");
50227 +kdbm_runqueues(int argc, const char **argv)
50229 + unsigned long cpu;
50233 + ret = kdbgetularg((char *)argv[1], &cpu);
50235 + if (!cpu_online(cpu)) {
50236 + kdb_printf("Invalid cpu number\n");
50238 + kdb_runqueue(cpu, kdb_printf);
50240 + } else if (argc == 0) {
50241 + for_each_online_cpu(cpu)
50242 + kdb_runqueue(cpu, kdb_printf);
50244 + /* More than one arg */
50245 + kdb_printf("Specify one cpu number\n");
50250 +static int __init kdbm_sched_init(void)
50252 + kdb_register("rq", kdbm_runqueues, "<cpunum>", "Display runqueue for <cpunum>", 0);
50253 + kdb_register("rqa", kdbm_runqueues, "", "Display all runqueues", 0);
50257 +static void __exit kdbm_sched_exit(void)
50259 + kdb_unregister("rq");
50260 + kdb_unregister("rqa");
50263 +module_init(kdbm_sched_init)
50264 +module_exit(kdbm_sched_exit)
50265 diff -Nurp linux-2.6.22-590/kdb/modules/kdbm_task.c linux-2.6.22-600/kdb/modules/kdbm_task.c
50266 --- linux-2.6.22-590/kdb/modules/kdbm_task.c 1970-01-01 01:00:00.000000000 +0100
50267 +++ linux-2.6.22-600/kdb/modules/kdbm_task.c 2008-04-09 18:14:28.000000000 +0200
50270 + * This file is subject to the terms and conditions of the GNU General Public
50271 + * License. See the file "COPYING" in the main directory of this archive
50272 + * for more details.
50274 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
50277 +#include <linux/blkdev.h>
50278 +#include <linux/types.h>
50279 +#include <linux/kdb.h>
50280 +#include <linux/kdbprivate.h>
50281 +#include <linux/module.h>
50282 +#include <linux/init.h>
50283 +#include <linux/mm.h>
50284 +#include <linux/sched.h>
50285 +#include <asm/signal.h>
50287 +MODULE_AUTHOR("SGI");
50288 +MODULE_DESCRIPTION("Debug struct task and sigset information");
50289 +MODULE_LICENSE("GPL");
50292 +kdb_cpus_allowed_string(struct task_struct *tp)
50294 + static char maskbuf[NR_CPUS * 8];
50295 + if (cpus_equal(tp->cpus_allowed, cpu_online_map))
50296 + strcpy(maskbuf, "ALL");
50297 + else if (cpus_full(tp->cpus_allowed))
50298 + strcpy(maskbuf, "ALL(NR_CPUS)");
50299 + else if (cpus_empty(tp->cpus_allowed))
50300 + strcpy(maskbuf, "NONE");
50301 + else if (cpus_weight(tp->cpus_allowed) == 1)
50302 + snprintf(maskbuf, sizeof(maskbuf), "ONLY(%d)", first_cpu(tp->cpus_allowed));
50304 + cpulist_scnprintf(maskbuf, sizeof(maskbuf), tp->cpus_allowed);
50309 +kdbm_task(int argc, const char **argv)
50311 + unsigned long addr;
50315 + struct task_struct *tp = NULL, *tp1;
50318 + return KDB_ARGCOUNT;
50321 + if ((e = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) != 0)
50324 + if (!(tp = kmalloc(sizeof(*tp), GFP_ATOMIC))) {
50325 + kdb_printf("%s: cannot kmalloc tp\n", __FUNCTION__);
50328 + if ((e = kdb_getarea(*tp, addr))) {
50329 + kdb_printf("%s: invalid task address\n", __FUNCTION__);
50333 + tp1 = (struct task_struct *)addr;
50335 + "struct task at 0x%lx, pid=%d flags=0x%x state=%ld comm=\"%s\"\n",
50336 + addr, tp->pid, tp->flags, tp->state, tp->comm);
50338 + kdb_printf(" cpu=%d policy=%u ", kdb_process_cpu(tp), tp->policy);
50340 + "prio=%d static_prio=%d cpus_allowed=",
50341 + tp->prio, tp->static_prio);
50343 + /* The cpus allowed string may be longer than kdb_printf() can
50344 + * handle. Print it in chunks.
50347 + p = kdb_cpus_allowed_string(tp);
50349 + if (strlen(p) < 100) {
50350 + kdb_printf("%s", p);
50355 + kdb_printf("%s", p);
50360 + kdb_printf(" &thread=0x%p\n", &tp1->thread);
50362 + kdb_printf(" need_resched=%d ",
50363 + test_tsk_thread_flag(tp, TIF_NEED_RESCHED));
50365 + "timestamp=%llu time_slice=%u",
50366 + tp->timestamp, tp->time_slice);
50367 + kdb_printf(" lock_depth=%d\n", tp->lock_depth);
50370 + " fs=0x%p files=0x%p mm=0x%p\n",
50371 + tp->fs, tp->files, tp->mm);
50374 + " uid=%d euid=%d suid=%d fsuid=%d gid=%d egid=%d sgid=%d fsgid=%d\n",
50375 + tp->uid, tp->euid, tp->suid, tp->fsuid, tp->gid, tp->egid, tp->sgid, tp->fsgid);
50381 + if (tp->sysvsem.undo_list)
50383 + " sysvsem.sem_undo refcnt %d proc_list=0x%p\n",
50384 + atomic_read(&tp->sysvsem.undo_list->refcnt),
50385 + tp->sysvsem.undo_list->proc_list);
50388 + " signal=0x%p &blocked=0x%p &pending=0x%p\n",
50389 + tp->signal, &tp1->blocked, &tp1->pending);
50392 + " utime=%ld stime=%ld cutime=%ld cstime=%ld\n",
50393 + tp->utime, tp->stime,
50394 + tp->signal ? tp->signal->cutime : 0L,
50395 + tp->signal ? tp->signal->cstime : 0L);
50397 + kdb_printf(" thread_info=0x%p\n", task_thread_info(tp));
50398 + kdb_printf(" ti flags=0x%lx\n", (unsigned long)task_thread_info(tp)->flags);
50407 +kdbm_sigset(int argc, const char **argv)
50409 + sigset_t *sp = NULL;
50410 + unsigned long addr;
50418 + return KDB_ARGCOUNT;
50420 +#ifndef _NSIG_WORDS
50421 + kdb_printf("unavailable on this platform, _NSIG_WORDS not defined.\n");
50424 + if ((e = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) != 0)
50427 + if (!(sp = kmalloc(sizeof(*sp), GFP_ATOMIC))) {
50428 + kdb_printf("%s: cannot kmalloc sp\n", __FUNCTION__);
50431 + if ((e = kdb_getarea(*sp, addr))) {
50432 + kdb_printf("%s: invalid sigset address\n", __FUNCTION__);
50436 + sprintf(fmt, "[%%d]=0x%%0%dlx ", (int)sizeof(sp->sig[0])*2);
50437 + kdb_printf("sigset at 0x%p : ", sp);
50438 + for (i=_NSIG_WORDS-1; i >= 0; i--) {
50439 + if (i == 0 || sp->sig[i]) {
50440 + kdb_printf(fmt, i, sp->sig[i]);
50443 + kdb_printf("\n");
50444 +#endif /* _NSIG_WORDS */
50452 +static int __init kdbm_task_init(void)
50454 + kdb_register("task", kdbm_task, "<vaddr>", "Display task_struct", 0);
50455 + kdb_register("sigset", kdbm_sigset, "<vaddr>", "Display sigset_t", 0);
50460 +static void __exit kdbm_task_exit(void)
50462 + kdb_unregister("task");
50463 + kdb_unregister("sigset");
50466 +module_init(kdbm_task_init)
50467 +module_exit(kdbm_task_exit)
50468 diff -Nurp linux-2.6.22-590/kdb/modules/kdbm_vm.c linux-2.6.22-600/kdb/modules/kdbm_vm.c
50469 --- linux-2.6.22-590/kdb/modules/kdbm_vm.c 1970-01-01 01:00:00.000000000 +0100
50470 +++ linux-2.6.22-600/kdb/modules/kdbm_vm.c 2008-04-09 18:14:28.000000000 +0200
50473 + * This file is subject to the terms and conditions of the GNU General Public
50474 + * License. See the file "COPYING" in the main directory of this archive
50475 + * for more details.
50477 + * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
50480 +#include <linux/blkdev.h>
50481 +#include <linux/types.h>
50482 +#include <linux/kdb.h>
50483 +#include <linux/kdbprivate.h>
50484 +#include <linux/module.h>
50485 +#include <linux/init.h>
50486 +#include <linux/mm.h>
50487 +#include <linux/swap.h>
50488 +#include <linux/swapops.h>
50491 +#include <scsi/scsi_host.h>
50493 +MODULE_AUTHOR("SGI");
50494 +MODULE_DESCRIPTION("Debug VM information");
50495 +MODULE_LICENSE("GPL");
50497 +struct __vmflags {
50498 + unsigned long mask;
50502 +static struct __vmflags vmflags[] = {
50503 + { VM_READ, "VM_READ " },
50504 + { VM_WRITE, "VM_WRITE " },
50505 + { VM_EXEC, "VM_EXEC " },
50506 + { VM_SHARED, "VM_SHARED " },
50507 + { VM_MAYREAD, "VM_MAYREAD " },
50508 + { VM_MAYWRITE, "VM_MAYWRITE " },
50509 + { VM_MAYEXEC, "VM_MAYEXEC " },
50510 + { VM_MAYSHARE, "VM_MAYSHARE " },
50511 + { VM_GROWSDOWN, "VM_GROWSDOWN " },
50512 + { VM_GROWSUP, "VM_GROWSUP " },
50513 + { VM_PFNMAP, "VM_PFNMAP " },
50514 + { VM_DENYWRITE, "VM_DENYWRITE " },
50515 + { VM_EXECUTABLE, "VM_EXECUTABLE " },
50516 + { VM_LOCKED, "VM_LOCKED " },
50517 + { VM_IO, "VM_IO " },
50518 + { VM_SEQ_READ, "VM_SEQ_READ " },
50519 + { VM_RAND_READ, "VM_RAND_READ " },
50520 + { VM_DONTCOPY, "VM_DONTCOPY " },
50521 + { VM_DONTEXPAND, "VM_DONTEXPAND " },
50522 + { VM_RESERVED, "VM_RESERVED " },
50523 + { VM_ACCOUNT, "VM_ACCOUNT " },
50524 + { VM_HUGETLB, "VM_HUGETLB " },
50525 + { VM_NONLINEAR, "VM_NONLINEAR " },
50526 + { VM_MAPPED_COPY, "VM_MAPPED_COPY " },
50527 + { VM_INSERTPAGE, "VM_INSERTPAGE " },
50532 +kdbm_print_vm(struct vm_area_struct *vp, unsigned long addr, int verbose_flg)
50534 + struct __vmflags *tp;
50536 + kdb_printf("struct vm_area_struct at 0x%lx for %d bytes\n",
50537 + addr, (int) sizeof (struct vm_area_struct));
50539 + kdb_printf("vm_start = 0x%p vm_end = 0x%p\n", (void *) vp->vm_start,
50540 + (void *) vp->vm_end);
50541 + kdb_printf("vm_page_prot = 0x%lx\n", pgprot_val(vp->vm_page_prot));
50543 + kdb_printf("vm_flags: ");
50544 + for (tp = vmflags; tp->mask; tp++) {
50545 + if (vp->vm_flags & tp->mask) {
50546 + kdb_printf(" %s", tp->name);
50549 + kdb_printf("\n");
50551 + if (!verbose_flg)
50554 + kdb_printf("vm_mm = 0x%p\n", (void *) vp->vm_mm);
50555 + kdb_printf("vm_next = 0x%p\n", (void *) vp->vm_next);
50556 + kdb_printf("shared.vm_set.list.next = 0x%p\n", (void *) vp->shared.vm_set.list.next);
50557 + kdb_printf("shared.vm_set.list.prev = 0x%p\n", (void *) vp->shared.vm_set.list.prev);
50558 + kdb_printf("shared.vm_set.parent = 0x%p\n", (void *) vp->shared.vm_set.parent);
50559 + kdb_printf("shared.vm_set.head = 0x%p\n", (void *) vp->shared.vm_set.head);
50560 + kdb_printf("anon_vma_node.next = 0x%p\n", (void *) vp->anon_vma_node.next);
50561 + kdb_printf("anon_vma_node.prev = 0x%p\n", (void *) vp->anon_vma_node.prev);
50562 + kdb_printf("vm_ops = 0x%p\n", (void *) vp->vm_ops);
50563 + if (vp->vm_ops != NULL) {
50564 + kdb_printf("vm_ops->open = 0x%p\n", vp->vm_ops->open);
50565 + kdb_printf("vm_ops->close = 0x%p\n", vp->vm_ops->close);
50566 + kdb_printf("vm_ops->nopage = 0x%p\n", vp->vm_ops->nopage);
50567 +#ifdef HAVE_VMOP_MPROTECT
50568 + kdb_printf("vm_ops->mprotect = 0x%p\n", vp->vm_ops->mprotect);
50571 + kdb_printf("vm_pgoff = 0x%lx\n", vp->vm_pgoff);
50572 + kdb_printf("vm_file = 0x%p\n", (void *) vp->vm_file);
50573 + kdb_printf("vm_private_data = 0x%p\n", vp->vm_private_data);
50579 +kdbm_print_vmp(struct vm_area_struct *vp, int verbose_flg)
50581 + struct __vmflags *tp;
50583 + if (verbose_flg) {
50584 + kdb_printf("0x%lx: ", (unsigned long) vp);
50587 + kdb_printf("0x%p 0x%p ", (void *) vp->vm_start, (void *) vp->vm_end);
50589 + for (tp = vmflags; tp->mask; tp++) {
50590 + if (vp->vm_flags & tp->mask) {
50591 + kdb_printf(" %s", tp->name);
50594 + kdb_printf("\n");
50602 + * This function implements the 'vm' command. Print a vm_area_struct.
50604 + * vm [-v] <address> Print vm_area_struct at <address>
50605 + * vmp [-v] <pid> Print all vm_area_structs for <pid>
50609 +kdbm_vm(int argc, const char **argv)
50611 + unsigned long addr;
50615 + int verbose_flg = 0;
50618 + if (strcmp(argv[1], "-v") != 0) {
50619 + return KDB_ARGCOUNT;
50622 + } else if (argc != 1) {
50623 + return KDB_ARGCOUNT;
50626 + if (strcmp(argv[0], "vmp") == 0) {
50627 + struct task_struct *g, *tp;
50628 + struct vm_area_struct *vp;
50631 + if ((diag = kdbgetularg(argv[argc], (unsigned long *) &pid)))
50634 + kdb_do_each_thread(g, tp) {
50635 + if (tp->pid == pid) {
50636 + if (tp->mm != NULL) {
50639 + ("vm_area_struct ");
50641 + ("vm_start vm_end vm_flags\n");
50642 + vp = tp->mm->mmap;
50643 + while (vp != NULL) {
50644 + kdbm_print_vmp(vp, verbose_flg);
50645 + vp = vp->vm_next;
50650 + } kdb_while_each_thread(g, tp);
50652 + kdb_printf("No process with pid == %d found\n", pid);
50655 + struct vm_area_struct v;
50658 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
50660 + || (diag = kdb_getarea(v, addr)))
50663 + kdbm_print_vm(&v, addr, verbose_flg);
50670 +kdbm_print_pte(pte_t * pte)
50672 + kdb_printf("0x%lx (", (unsigned long) pte_val(*pte));
50674 + if (pte_present(*pte)) {
50675 + if (pte_exec(*pte))
50677 + if (pte_write(*pte))
50679 + if (pte_read(*pte))
50681 + if (pte_young(*pte))
50683 + if (pte_dirty(*pte))
50687 + kdb_printf("OFFSET=0x%lx ", swp_offset(pte_to_swp_entry(*pte)));
50688 + kdb_printf("TYPE=0x%ulx", swp_type(pte_to_swp_entry(*pte)));
50693 + /* final newline is output by caller of kdbm_print_pte() */
50701 + * This function implements the 'pte' command. Print all pte_t structures
50702 + * that map to the given virtual address range (<address> through <address>
50703 + * plus <nbytes>) for the given process. The default value for nbytes is
50706 + * pte -m <mm> <address> [<nbytes>] Print all pte_t structures for
50707 + * virtual <address> in address space
50708 + * of <mm> which is a pointer to a
50710 + * pte -p <pid> <address> [<nbytes>] Print all pte_t structures for
50711 + * virtual <address> in address space
50716 +kdbm_pte(int argc, const char **argv)
50718 + unsigned long addr;
50721 + unsigned long nbytes = 1;
50726 + struct task_struct *tp;
50727 + struct mm_struct *mm, copy_of_mm;
50733 + if (argc < 3 || argc > 4) {
50734 + return KDB_ARGCOUNT;
50737 + if (strcmp(argv[1], "-p") == 0) {
50738 + if ((diag = kdbgetularg(argv[2], (unsigned long *) &pid))) {
50743 + for_each_process(tp) {
50744 + if (tp->pid == pid) {
50745 + if (tp->mm != NULL) {
50749 + kdb_printf("task structure's mm field is NULL\n");
50755 + kdb_printf("No process with pid == %d found\n", pid);
50759 + } else if (strcmp(argv[1], "-m") == 0) {
50763 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
50765 + || (diag = kdb_getarea(copy_of_mm, addr)))
50767 + mm = ©_of_mm;
50769 + return KDB_ARGCOUNT;
50772 + if ((diag = kdbgetularg(argv[3], &addr))) {
50777 + if ((diag = kdbgetularg(argv[4], &nbytes))) {
50782 + kdb_printf("vaddr pte\n");
50784 + npgs = ((((addr & ~PAGE_MASK) + nbytes) + ~PAGE_MASK) >> PAGE_SHIFT);
50785 + while (npgs-- > 0) {
50787 + kdb_printf("0x%p ", (void *) (addr & PAGE_MASK));
50789 + pgd = pgd_offset(mm, addr);
50790 + if (pgd_present(*pgd)) {
50791 + pud = pud_offset(pgd, addr);
50792 + if (pud_present(*pud)) {
50793 + pmd = pmd_offset(pud, addr);
50794 + if (pmd_present(*pmd)) {
50795 + pte = pte_offset_map(pmd, addr);
50796 + if (pte_present(*pte)) {
50797 + kdbm_print_pte(pte);
50803 + kdb_printf("\n");
50804 + addr += PAGE_SIZE;
50813 + * This function implements the 'rpte' command. Print all pte_t structures
50814 + * that contain the given physical page range (<pfn> through <pfn>
50815 + * plus <npages>) for the given process. The default value for npages is
50818 + * rpte -m <mm> <pfn> [<npages>] Print all pte_t structures for
50819 + * physical page <pfn> in address space
50820 + * of <mm> which is a pointer to a
50822 + * rpte -p <pid> <pfn> [<npages>] Print all pte_t structures for
50823 + * physical page <pfn> in address space
50828 +kdbm_rpte(int argc, const char **argv)
50830 + unsigned long addr;
50831 + unsigned long pfn;
50834 + unsigned long npages = 1;
50838 + struct task_struct *tp;
50839 + struct mm_struct *mm, copy_of_mm;
50844 + unsigned long g, u, m, t;
50846 + if (argc < 3 || argc > 4) {
50847 + return KDB_ARGCOUNT;
50850 + if (strcmp(argv[1], "-p") == 0) {
50851 + if ((diag = kdbgetularg(argv[2], (unsigned long *) &pid))) {
50856 + for_each_process(tp) {
50857 + if (tp->pid == pid) {
50858 + if (tp->mm != NULL) {
50862 + kdb_printf("task structure's mm field is NULL\n");
50868 + kdb_printf("No process with pid == %d found\n", pid);
50872 + } else if (strcmp(argv[1], "-m") == 0) {
50876 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
50878 + || (diag = kdb_getarea(copy_of_mm, addr)))
50880 + mm = ©_of_mm;
50882 + return KDB_ARGCOUNT;
50885 + if ((diag = kdbgetularg(argv[3], &pfn))) {
50890 + if ((diag = kdbgetularg(argv[4], &npages))) {
50895 + /* spaces after vaddr depends on sizeof(unsigned long) */
50896 + kdb_printf("pfn vaddr%*s pte\n",
50897 + (int)(2*sizeof(unsigned long) + 2 - 5), " ");
50899 + for (g = 0, pgd = pgd_offset(mm, 0UL); g < PTRS_PER_PGD; ++g, ++pgd) {
50900 + if (pgd_none(*pgd) || pgd_bad(*pgd))
50902 + for (u = 0, pud = pud_offset(pgd, 0UL); u < PTRS_PER_PUD; ++u, ++pud) {
50903 + if (pud_none(*pud) || pud_bad(*pud))
50905 + for (m = 0, pmd = pmd_offset(pud, 0UL); m < PTRS_PER_PMD; ++m, ++pmd) {
50906 + if (pmd_none(*pmd) || pmd_bad(*pmd))
50908 + for (t = 0, pte = pte_offset_map(pmd, 0UL); t < PTRS_PER_PTE; ++t, ++pte) {
50909 + if (pte_none(*pte))
50911 + if (pte_pfn(*pte) < pfn || pte_pfn(*pte) >= (pfn + npages))
50913 + addr = g << PGDIR_SHIFT;
50915 + /* IA64 plays tricks with the pgd mapping to save space.
50916 + * This reverses pgd_index().
50919 + unsigned long region = g >> (PAGE_SHIFT - 6);
50920 + unsigned long l1index = g - (region << (PAGE_SHIFT - 6));
50921 + addr = (region << 61) + (l1index << PGDIR_SHIFT);
50924 + addr += (m << PMD_SHIFT) + (t << PAGE_SHIFT);
50925 + kdb_printf("0x%-14lx " kdb_bfd_vma_fmt0 " ",
50926 + pte_pfn(*pte), addr);
50927 + kdbm_print_pte(pte);
50928 + kdb_printf("\n");
50938 +kdbm_print_dentry(unsigned long daddr)
50944 + kdb_printf("Dentry at 0x%lx\n", daddr);
50945 + if ((diag = kdb_getarea(d, (unsigned long)daddr)))
50948 + if ((d.d_name.len > sizeof(buf)) || (diag = kdb_getarea_size(buf, (unsigned long)(d.d_name.name), d.d_name.len)))
50949 + kdb_printf(" d_name.len = %d d_name.name = 0x%p\n",
50950 + d.d_name.len, d.d_name.name);
50952 + kdb_printf(" d_name.len = %d d_name.name = 0x%p <%.*s>\n",
50953 + d.d_name.len, d.d_name.name,
50954 + (int)(d.d_name.len), d.d_name.name);
50956 + kdb_printf(" d_count = %d d_flags = 0x%x d_inode = 0x%p\n",
50957 + atomic_read(&d.d_count), d.d_flags, d.d_inode);
50959 + kdb_printf(" d_parent = 0x%p\n", d.d_parent);
50961 + kdb_printf(" d_hash.nxt = 0x%p d_hash.prv = 0x%p\n",
50962 + d.d_hash.next, d.d_hash.pprev);
50964 + kdb_printf(" d_lru.nxt = 0x%p d_lru.prv = 0x%p\n",
50965 + d.d_lru.next, d.d_lru.prev);
50967 + kdb_printf(" d_child.nxt = 0x%p d_child.prv = 0x%p\n",
50968 + d.d_u.d_child.next, d.d_u.d_child.prev);
50970 + kdb_printf(" d_subdirs.nxt = 0x%p d_subdirs.prv = 0x%p\n",
50971 + d.d_subdirs.next, d.d_subdirs.prev);
50973 + kdb_printf(" d_alias.nxt = 0x%p d_alias.prv = 0x%p\n",
50974 + d.d_alias.next, d.d_alias.prev);
50976 + kdb_printf(" d_op = 0x%p d_sb = 0x%p d_fsdata = 0x%p\n",
50977 + d.d_op, d.d_sb, d.d_fsdata);
50979 + kdb_printf(" d_iname = %s\n",
50984 + kdb_printf("\nInode Entry at 0x%p\n", d.d_inode);
50985 + if ((diag = kdb_getarea(i, (unsigned long)d.d_inode)))
50987 + kdb_printf(" i_mode = 0%o i_nlink = %d i_rdev = 0x%x\n",
50988 + i.i_mode, i.i_nlink, i.i_rdev);
50990 + kdb_printf(" i_ino = %ld i_count = %d\n",
50991 + i.i_ino, atomic_read(&i.i_count));
50993 + kdb_printf(" i_hash.nxt = 0x%p i_hash.prv = 0x%p\n",
50994 + i.i_hash.next, i.i_hash.pprev);
50996 + kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
50997 + i.i_list.next, i.i_list.prev);
50999 + kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
51000 + i.i_dentry.next, i.i_dentry.prev);
51003 + kdb_printf("\n");
51008 +kdbm_filp(int argc, const char **argv)
51012 + unsigned long addr;
51017 + return KDB_ARGCOUNT;
51020 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
51021 + (diag = kdb_getarea(f, addr)))
51024 + kdb_printf("File Pointer at 0x%lx\n", addr);
51026 + kdb_printf(" fu_list.nxt = 0x%p fu_list.prv = 0x%p\n",
51027 + f.f_u.fu_list.next, f.f_u.fu_list.prev);
51029 + kdb_printf(" f_dentry = 0x%p f_vfsmnt = 0x%p f_op = 0x%p\n",
51030 + f.f_dentry, f.f_vfsmnt, f.f_op);
51032 + kdb_printf(" f_count = %d f_flags = 0x%x f_mode = 0x%x\n",
51033 + atomic_read(&f.f_count), f.f_flags, f.f_mode);
51035 + kdb_printf(" f_pos = %Ld\n", f.f_pos);
51036 +#ifdef CONFIG_SECURITY
51037 + kdb_printf(" security = 0x%p\n", f.f_security);
51040 + kdb_printf(" private_data = 0x%p f_mapping = 0x%p\n\n",
51041 + f.private_data, f.f_mapping);
51043 + return kdbm_print_dentry((unsigned long)f.f_dentry);
51047 +kdbm_fl(int argc, const char **argv)
51049 + struct file_lock fl;
51051 + unsigned long addr;
51057 + return KDB_ARGCOUNT;
51060 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
51061 + (diag = kdb_getarea(fl, addr)))
51064 + kdb_printf("File_lock at 0x%lx\n", addr);
51066 + kdb_printf(" fl_next = 0x%p fl_link.nxt = 0x%p fl_link.prv = 0x%p\n",
51067 + fl.fl_next, fl.fl_link.next, fl.fl_link.prev);
51068 + kdb_printf(" fl_block.nxt = 0x%p fl_block.prv = 0x%p\n",
51069 + fl.fl_block.next, fl.fl_block.prev);
51070 + kdb_printf(" fl_owner = 0x%p fl_pid = %d fl_wait = 0x%p\n",
51071 + fl.fl_owner, fl.fl_pid, &fl.fl_wait);
51072 + kdb_printf(" fl_file = 0x%p fl_flags = 0x%x\n",
51073 + fl.fl_file, fl.fl_flags);
51074 + kdb_printf(" fl_type = %d fl_start = 0x%llx fl_end = 0x%llx\n",
51075 + fl.fl_type, fl.fl_start, fl.fl_end);
51077 + kdb_printf(" file_lock_operations");
51079 + kdb_printf("\n fl_insert = 0x%p fl_remove = 0x%p fl_copy_lock = 0x%p fl_release_private = 0x%p\n",
51080 + fl.fl_ops->fl_insert, fl.fl_ops->fl_remove,
51081 + fl.fl_ops->fl_copy_lock, fl.fl_ops->fl_release_private);
51083 + kdb_printf(" empty\n");
51085 + kdb_printf(" lock_manager_operations");
51087 + kdb_printf("\n fl_compare_owner = 0x%p fl_notify = 0x%p\n",
51088 + fl.fl_lmops->fl_compare_owner, fl.fl_lmops->fl_notify);
51090 + kdb_printf(" empty\n");
51092 + kdb_printf(" fl_fasync = 0x%p fl_break 0x%lx\n",
51093 + fl.fl_fasync, fl.fl_break_time);
51100 +kdbm_dentry(int argc, const char **argv)
51103 + unsigned long addr;
51108 + return KDB_ARGCOUNT;
51111 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
51114 + return kdbm_print_dentry(addr);
51118 +kdbm_kobject(int argc, const char **argv)
51120 + struct kobject k;
51122 + unsigned long addr;
51127 + return KDB_ARGCOUNT;
51130 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
51131 + (diag = kdb_getarea(k, addr)))
51135 + kdb_printf("kobject at 0x%lx\n", addr);
51139 + kdb_printf(" k_name 0x%p", k.k_name);
51140 + if (kdb_getarea(c, (unsigned long)k.k_name) == 0)
51141 + kdb_printf(" '%s'", k.k_name);
51142 + kdb_printf("\n");
51145 + if (k.k_name != ((struct kobject *)addr)->name)
51146 + kdb_printf(" name '%." __stringify(KOBJ_NAME_LEN) "s'\n", k.k_name);
51148 + kdb_printf(" kref.refcount %d'\n", atomic_read(&k.kref.refcount));
51150 + kdb_printf(" entry.next = 0x%p entry.prev = 0x%p\n",
51151 + k.entry.next, k.entry.prev);
51153 + kdb_printf(" parent = 0x%p kset = 0x%p ktype = 0x%p dentry = 0x%p\n",
51154 + k.parent, k.kset, k.ktype, k.dentry);
51160 +kdbm_sh(int argc, const char **argv)
51164 + unsigned long addr;
51165 + long offset = 0L;
51166 + struct Scsi_Host sh;
51169 + return KDB_ARGCOUNT;
51172 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
51173 + (diag = kdb_getarea(sh, addr)))
51176 + kdb_printf("Scsi_Host at 0x%lx\n", addr);
51177 + kdb_printf("host_queue = 0x%p\n", sh.__devices.next);
51178 + kdb_printf("ehandler = 0x%p eh_action = 0x%p\n",
51179 + sh.ehandler, sh.eh_action);
51180 + kdb_printf("host_wait = 0x%p hostt = 0x%p\n",
51181 + &sh.host_wait, sh.hostt);
51182 + kdb_printf("host_failed = %d host_no = %d resetting = %d\n",
51183 + sh.host_failed, sh.host_no, sh.resetting);
51184 + kdb_printf("max id/lun/channel = [%d/%d/%d] this_id = %d\n",
51185 + sh.max_id, sh.max_lun, sh.max_channel, sh.this_id);
51186 + kdb_printf("can_queue = %d cmd_per_lun = %d sg_tablesize = %d u_isa_dma = %d\n",
51187 + sh.can_queue, sh.cmd_per_lun, sh.sg_tablesize, sh.unchecked_isa_dma);
51188 + kdb_printf("host_blocked = %d reverse_ordering = %d \n",
51189 + sh.host_blocked, sh.reverse_ordering);
51195 +kdbm_sd(int argc, const char **argv)
51199 + unsigned long addr;
51200 + long offset = 0L;
51201 + struct scsi_device *sd = NULL;
51204 + return KDB_ARGCOUNT;
51207 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
51209 + if (!(sd = kmalloc(sizeof(*sd), GFP_ATOMIC))) {
51210 + kdb_printf("kdbm_sd: cannot kmalloc sd\n");
51213 + if ((diag = kdb_getarea(*sd, addr)))
51216 + kdb_printf("scsi_device at 0x%lx\n", addr);
51217 + kdb_printf("next = 0x%p prev = 0x%p host = 0x%p\n",
51218 + sd->siblings.next, sd->siblings.prev, sd->host);
51219 + kdb_printf("device_busy = %d current_cmnd 0x%p\n",
51220 + sd->device_busy, sd->current_cmnd);
51221 + kdb_printf("id/lun/chan = [%d/%d/%d] single_lun = %d device_blocked = %d\n",
51222 + sd->id, sd->lun, sd->channel, sd->single_lun, sd->device_blocked);
51223 + kdb_printf("queue_depth = %d current_tag = %d scsi_level = %d\n",
51224 + sd->queue_depth, sd->current_tag, sd->scsi_level);
51225 + kdb_printf("%8.8s %16.16s %4.4s\n", sd->vendor, sd->model, sd->rev);
51233 +kdbm_sc(int argc, const char **argv)
51237 + unsigned long addr;
51238 + long offset = 0L;
51239 + struct scsi_cmnd *sc = NULL;
51242 + return KDB_ARGCOUNT;
51245 + if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
51247 + if (!(sc = kmalloc(sizeof(*sc), GFP_ATOMIC))) {
51248 + kdb_printf("kdbm_sc: cannot kmalloc sc\n");
51251 + if ((diag = kdb_getarea(*sc, addr)))
51254 + kdb_printf("scsi_cmnd at 0x%lx\n", addr);
51255 + kdb_printf("device = 0x%p next = 0x%p done = 0x%p\n",
51256 + sc->device, sc->list.next, sc->done);
51257 + kdb_printf("serial_number = %ld retries = %d\n",
51258 + sc->serial_number, sc->retries);
51259 + kdb_printf("cmd_len = %d\n", sc->cmd_len);
51260 + kdb_printf("cmnd = [%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x]\n",
51261 + sc->cmnd[0], sc->cmnd[1], sc->cmnd[2], sc->cmnd[3], sc->cmnd[4],
51262 + sc->cmnd[5], sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9],
51263 + sc->cmnd[10], sc->cmnd[11]);
51264 + kdb_printf("request_buffer = 0x%p request_bufflen = %d\n",
51265 + sc->request_buffer, sc->request_bufflen);
51266 + kdb_printf("use_sg = %d sglist_len = %d\n",
51267 + sc->use_sg, sc->sglist_len);
51268 + kdb_printf("underflow = %d transfersize = %d\n",
51269 + sc->underflow, sc->transfersize);
51270 + kdb_printf("tag = %d pid = %ld\n",
51271 + sc->tag, sc->pid);
51279 +static int __init kdbm_vm_init(void)
51281 + kdb_register("vm", kdbm_vm, "[-v] <vaddr>", "Display vm_area_struct", 0);
51282 + kdb_register("vmp", kdbm_vm, "[-v] <pid>", "Display all vm_area_struct for <pid>", 0);
51283 + kdb_register("pte", kdbm_pte, "( -m <mm> | -p <pid> ) <vaddr> [<nbytes>]", "Display pte_t for mm_struct or pid", 0);
51284 + kdb_register("rpte", kdbm_rpte, "( -m <mm> | -p <pid> ) <pfn> [<npages>]", "Find pte_t containing pfn for mm_struct or pid", 0);
51285 + kdb_register("dentry", kdbm_dentry, "<dentry>", "Display interesting dentry stuff", 0);
51286 + kdb_register("kobject", kdbm_kobject, "<kobject>", "Display interesting kobject stuff", 0);
51287 + kdb_register("filp", kdbm_filp, "<filp>", "Display interesting filp stuff", 0);
51288 + kdb_register("fl", kdbm_fl, "<fl>", "Display interesting file_lock stuff", 0);
51289 + kdb_register("sh", kdbm_sh, "<vaddr>", "Show scsi_host", 0);
51290 + kdb_register("sd", kdbm_sd, "<vaddr>", "Show scsi_device", 0);
51291 + kdb_register("sc", kdbm_sc, "<vaddr>", "Show scsi_cmnd", 0);
51296 +static void __exit kdbm_vm_exit(void)
51298 + kdb_unregister("vm");
51299 + kdb_unregister("vmp");
51300 + kdb_unregister("pte");
51301 + kdb_unregister("rpte");
51302 + kdb_unregister("dentry");
51303 + kdb_unregister("kobject");
51304 + kdb_unregister("filp");
51305 + kdb_unregister("fl");
51306 + kdb_unregister("sh");
51307 + kdb_unregister("sd");
51308 + kdb_unregister("sc");
51311 +module_init(kdbm_vm_init)
51312 +module_exit(kdbm_vm_exit)
51313 diff -Nurp linux-2.6.22-590/kdb/modules/kdbm_x86.c linux-2.6.22-600/kdb/modules/kdbm_x86.c
51314 --- linux-2.6.22-590/kdb/modules/kdbm_x86.c 1970-01-01 01:00:00.000000000 +0100
51315 +++ linux-2.6.22-600/kdb/modules/kdbm_x86.c 2008-04-09 18:14:28.000000000 +0200
51318 + * This file is subject to the terms and conditions of the GNU General Public
51319 + * License. See the file "COPYING" in the main directory of this archive
51320 + * for more details.
51322 + * Author: Vamsi Krishna S. <vamsi_krishna@in.ibm.com>
51323 + * (C) 2003 IBM Corporation.
51324 + * 2006-10-10 Keith Owens
51325 + * Reworked to include x86_64 support
51326 + * Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved.
51329 +#include <linux/interrupt.h>
51330 +#include <linux/types.h>
51331 +#include <linux/kdb.h>
51332 +#include <linux/kdbprivate.h>
51333 +#include <linux/module.h>
51334 +#include <linux/init.h>
51335 +#include <linux/mm.h>
51337 +#include <asm/processor.h>
51338 +#include <asm/uaccess.h>
51339 +#include <asm/desc.h>
51340 +#include <asm/debugreg.h>
51342 +#include <asm/pgtable.h>
51345 +MODULE_AUTHOR("Vamsi Krishna S./IBM");
51346 +MODULE_DESCRIPTION("x86 specific information (gdt/idt/ldt/page tables)");
51347 +MODULE_LICENSE("GPL");
51349 +/* Isolate as many of the i386/x86_64 differences as possible in one spot */
51351 +#ifdef CONFIG_X86_64
51353 +#define KDB_X86_64 1
51354 +#define MOVLQ "movq"
51356 +typedef struct desc_struct kdb_desc_t;
51357 +typedef struct gate_struct kdb_gate_desc_t;
51359 +#define KDB_SYS_DESC_OFFSET(d) ((unsigned long)d->offset_high << 32 | d->offset_middle << 16 | d->offset_low)
51360 +#define KDB_SYS_DESC_CALLG_COUNT(d) 0
51362 +#else /* !CONFIG_X86_64 */
51364 +#define KDB_X86_64 0
51365 +#define desc_ptr Xgt_desc_struct
51366 +#define MOVLQ "movl"
51368 +/* i386 has no detailed mapping for the 8 byte segment descriptor, copy the
51369 + * x86_64 one and merge the l and avl bits.
51374 + unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
51375 + unsigned limit : 4, avl : 2, d : 1, g : 1, base2 : 8;
51376 +} __attribute__((packed));
51377 +typedef struct kdb_desc kdb_desc_t;
51379 +/* i386 has no detailed mapping for the 8 byte gate descriptor, base it on the
51382 +struct kdb_gate_desc {
51385 + unsigned res : 8, type : 4, s : 1, dpl : 2, p : 1;
51386 + u16 offset_middle;
51387 +} __attribute__((packed));
51388 +typedef struct kdb_gate_desc kdb_gate_desc_t;
51390 +#define KDB_SYS_DESC_OFFSET(d) ((unsigned long)(d->offset_middle << 16 | d->offset_low))
51391 +#define KDB_SYS_DESC_CALLG_COUNT(d) ((unsigned int)(d->res & 0x0F))
51393 +#endif /* CONFIG_X86_64 */
51395 +#define KDB_SEL_MAX 0x2000
51396 +#define KDB_IDT_MAX 0x100
51397 +#define KDB_SYS_DESC_TYPE_TSS16 0x01
51398 +#define KDB_SYS_DESC_TYPE_LDT 0x02
51399 +#define KDB_SYS_DESC_TYPE_TSSB16 0x03
51400 +#define KDB_SYS_DESC_TYPE_CALLG16 0x04
51401 +#define KDB_SYS_DESC_TYPE_TASKG 0x05
51402 +#define KDB_SYS_DESC_TYPE_INTG16 0x06
51403 +#define KDB_SYS_DESC_TYPE_TRAP16 0x07
51405 +#define KDB_SYS_DESC_TYPE_TSS 0x09
51406 +#define KDB_SYS_DESC_TYPE_TSSB 0x0b
51407 +#define KDB_SYS_DESC_TYPE_CALLG 0x0c
51408 +#define KDB_SYS_DESC_TYPE_INTG 0x0e
51409 +#define KDB_SYS_DESC_TYPE_TRAPG 0x0f
51411 +#define KDB_SEG_DESC_TYPE_CODE 0x08
51412 +#define KDB_SEG_DESC_TYPE_CODE_R 0x02
51413 +#define KDB_SEG_DESC_TYPE_DATA_W 0x02
51414 +#define KDB_SEG_DESC_TYPE_CODE_C 0x02 /* conforming */
51415 +#define KDB_SEG_DESC_TYPE_DATA_D 0x02 /* expand-down */
51416 +#define KDB_SEG_DESC_TYPE_A 0x01 /* accessed */
51418 +#define _LIMIT(d) ((unsigned long)((d)->limit << 16 | (d)->limit0))
51419 +#define KDB_SEG_DESC_LIMIT(d) ((d)->g ? ((_LIMIT(d)+1) << 12) -1 : _LIMIT(d))
51421 +static unsigned long kdb_seg_desc_base(kdb_desc_t *d)
51423 + unsigned long base = d->base2 << 24 | d->base1 << 16 | d->base0;
51424 +#ifdef CONFIG_X86_64
51425 + switch (d->type) {
51426 + case KDB_SYS_DESC_TYPE_TSS:
51427 + case KDB_SYS_DESC_TYPE_TSSB:
51428 + case KDB_SYS_DESC_TYPE_LDT:
51429 + base += (unsigned long)(((struct ldttss_desc *)d)->base3) << 32;
51436 +/* helper functions to display system registers in verbose mode */
51437 +static void display_gdtr(void)
51439 + struct desc_ptr gdtr;
51441 + __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
51442 + kdb_printf("gdtr.address = " kdb_machreg_fmt0 ", gdtr.size = 0x%x\n",
51443 + gdtr.address, gdtr.size);
51448 +static void display_ldtr(void)
51450 + struct desc_ptr gdtr;
51451 + unsigned long ldtr;
51453 + __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
51454 + __asm__ __volatile__ ("sldt %0\n\t" : "=m"(ldtr));
51455 + ldtr &= 0xfff8; /* extract the index */
51457 + kdb_printf("ldtr = " kdb_machreg_fmt0 " ", ldtr);
51459 + if (ldtr < gdtr.size) {
51460 + kdb_desc_t *ldt_desc =
51461 + (kdb_desc_t *)(gdtr.address + ldtr);
51462 + kdb_printf("base=" kdb_machreg_fmt0
51463 + ", limit=" kdb_machreg_fmt "\n",
51464 + kdb_seg_desc_base(ldt_desc),
51465 + KDB_SEG_DESC_LIMIT(ldt_desc));
51467 + kdb_printf("invalid\n");
51473 +static void display_idtr(void)
51475 + struct desc_ptr idtr;
51476 + __asm__ __volatile__ ("sidt %0\n\t" : "=m"(idtr));
51477 + kdb_printf("idtr.address = " kdb_machreg_fmt0 ", idtr.size = 0x%x\n",
51478 + idtr.address, idtr.size);
51482 +static const char *cr0_flags[] = {
51483 + "pe", "mp", "em", "ts", "et", "ne", NULL, NULL,
51484 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
51485 + "wp", NULL, "am", NULL, NULL, NULL, NULL, NULL,
51486 + NULL, NULL, NULL, NULL, NULL, "nw", "cd", "pg"};
51488 +static void display_cr0(void)
51490 + kdb_machreg_t cr0;
51492 + __asm__ (MOVLQ " %%cr0,%0\n\t":"=r"(cr0));
51493 + kdb_printf("cr0 = " kdb_machreg_fmt0, cr0);
51494 + for (i = 0; i < ARRAY_SIZE(cr0_flags); i++) {
51495 + if (test_bit(i, &cr0) && cr0_flags[i])
51496 + kdb_printf(" %s", cr0_flags[i]);
51498 + kdb_printf("\n");
51502 +static void display_cr3(void)
51504 + kdb_machreg_t cr3;
51505 + __asm__ (MOVLQ " %%cr3,%0\n\t":"=r"(cr3));
51506 + kdb_printf("cr3 = " kdb_machreg_fmt0 " ", cr3);
51508 + kdb_printf("pwt ");
51510 + kdb_printf("pcd ");
51511 + kdb_printf("%s=" kdb_machreg_fmt0 "\n",
51512 + KDB_X86_64 ? "pml4" : "pgdir", cr3 & PAGE_MASK);
51516 +static const char *cr4_flags[] = {
51517 + "vme", "pvi", "tsd", "de",
51518 + "pse", "pae", "mce", "pge",
51519 + "pce", "osfxsr" "osxmmexcpt"};
51521 +static void display_cr4(void)
51523 + kdb_machreg_t cr4;
51525 + __asm__ (MOVLQ " %%cr4,%0\n\t":"=r"(cr4));
51526 + kdb_printf("cr4 = " kdb_machreg_fmt0, cr4);
51527 + for (i = 0; i < ARRAY_SIZE(cr4_flags); i++) {
51528 + if (test_bit(i, &cr4))
51529 + kdb_printf(" %s", cr4_flags[i]);
51531 + kdb_printf("\n");
51535 +static void display_cr8(void)
51537 +#ifdef CONFIG_X86_64
51538 + kdb_machreg_t cr8;
51539 + __asm__ (MOVLQ " %%cr8,%0\n\t":"=r"(cr8));
51540 + kdb_printf("cr8 = " kdb_machreg_fmt0 "\n", cr8);
51542 +#endif /* CONFIG_X86_64 */
51545 +static char *dr_type_name[] = { "exec", "write", "io", "rw" };
51547 +static void display_dr_status(int nr, int enabled, int local, int len, int type)
51550 + kdb_printf("\tdebug register %d: not enabled\n", nr);
51554 + kdb_printf(" debug register %d: %s, len = %d, type = %s\n",
51556 + local? " local":"global",
51558 + dr_type_name[type]);
51561 +static void display_dr(void)
51563 + kdb_machreg_t dr0, dr1, dr2, dr3, dr6, dr7;
51566 + __asm__ (MOVLQ " %%db0,%0\n\t":"=r"(dr0));
51567 + __asm__ (MOVLQ " %%db1,%0\n\t":"=r"(dr1));
51568 + __asm__ (MOVLQ " %%db2,%0\n\t":"=r"(dr2));
51569 + __asm__ (MOVLQ " %%db3,%0\n\t":"=r"(dr3));
51570 + __asm__ (MOVLQ " %%db6,%0\n\t":"=r"(dr6));
51571 + __asm__ (MOVLQ " %%db7,%0\n\t":"=r"(dr7));
51573 + kdb_printf("dr0 = " kdb_machreg_fmt0 " dr1 = " kdb_machreg_fmt0
51574 + " dr2 = " kdb_machreg_fmt0 " dr3 = " kdb_machreg_fmt0 "\n",
51575 + dr0, dr1, dr2, dr3);
51576 + kdb_printf("dr6 = " kdb_machreg_fmt0 " ", dr6);
51577 + dbnr = dr6 & DR6_DR_MASK;
51590 + kdb_printf("debug register hit = %d", nr);
51591 + } else if (dr6 & DR_STEP) {
51592 + kdb_printf("single step");
51593 + } else if (dr6 & DR_SWITCH) {
51594 + kdb_printf("task switch");
51596 + kdb_printf("\n");
51598 + kdb_printf("dr7 = " kdb_machreg_fmt0 "\n", dr7);
51599 + set = DR7_L0(dr7) || DR7_G0(dr7);
51600 + display_dr_status(0, set, DR7_L0(dr7), DR7_LEN0(dr7), DR7_RW0(dr7));
51601 + set = DR7_L1(dr7) || DR7_G1(dr7);
51602 + display_dr_status(1, set, DR7_L1(dr7), DR7_LEN1(dr7), DR7_RW1(dr7));
51603 + set = DR7_L2(dr7) || DR7_G2(dr7);
51604 + display_dr_status(2, set, DR7_L2(dr7), DR7_LEN2(dr7), DR7_RW2(dr7));
51605 + set = DR7_L3(dr7) || DR7_G3(dr7);
51606 + display_dr_status(3, set, DR7_L3(dr7), DR7_LEN3(dr7), DR7_RW3(dr7));
51609 +static char *set_eflags[] = {
51610 + "carry", NULL, "parity", NULL, "adjust", NULL, "zero", "sign",
51611 + "trace", "intr-on", "dir", "overflow", NULL, NULL, "nestedtask", NULL,
51612 + "resume", "vm", "align", "vif", "vip", "id"};
51614 +static void display_eflags(unsigned long ef)
51617 + kdb_printf("eflags = " kdb_machreg_fmt0 " ", ef);
51618 + for (i = 0; i < ARRAY_SIZE(set_eflags); i++) {
51619 + if (test_bit(i, &ef) && set_eflags[i])
51620 + kdb_printf("%s ", set_eflags[i]);
51623 + iopl = (ef & 0x00003000) >> 12;
51624 + kdb_printf("iopl=%d\n", iopl);
51628 +static void display_tss(struct tss_struct *t)
51630 +#ifdef CONFIG_X86_64
51632 + kdb_printf(" rsp0 = 0x%016Lx, rsp1 = 0x%016Lx\n",
51633 + t->rsp0, t->rsp1);
51634 + kdb_printf(" rsp2 = 0x%016Lx\n", t->rsp2);
51635 + for (i = 0; i < ARRAY_SIZE(t->ist); ++i)
51636 + kdb_printf(" ist[%d] = 0x%016Lx\n",
51638 + kdb_printf(" iomap = 0x%04x\n", t->io_bitmap_base);
51639 +#else /* !CONFIG_X86_64 */
51640 + kdb_printf(" cs = %04x, eip = " kdb_machreg_fmt0 "\n",
51641 + t->x86_tss.es, t->x86_tss.eip);
51642 + kdb_printf(" ss = %04x, esp = " kdb_machreg_fmt0 "\n",
51643 + t->x86_tss.ss, t->x86_tss.esp);
51644 + kdb_printf(" ss0 = %04x, esp0 = " kdb_machreg_fmt0 "\n",
51645 + t->x86_tss.ss0, t->x86_tss.esp0);
51646 + kdb_printf(" ss1 = %04x, esp1 = " kdb_machreg_fmt0 "\n",
51647 + t->x86_tss.ss1, t->x86_tss.esp1);
51648 + kdb_printf(" ss2 = %04x, esp2 = " kdb_machreg_fmt0 "\n",
51649 + t->x86_tss.ss2, t->x86_tss.esp2);
51650 + kdb_printf(" ldt = %04x, cr3 = " kdb_machreg_fmt0 "\n",
51651 + t->x86_tss.ldt, t->x86_tss.__cr3);
51652 + kdb_printf(" ds = %04x, es = %04x fs = %04x gs = %04x\n",
51653 + t->x86_tss.ds, t->x86_tss.es, t->x86_tss.fs, t->x86_tss.gs);
51654 + kdb_printf(" eax = " kdb_machreg_fmt0 ", ebx = " kdb_machreg_fmt0
51655 + " ecx = " kdb_machreg_fmt0 " edx = " kdb_machreg_fmt0 "\n",
51656 + t->x86_tss.eax, t->x86_tss.ebx, t->x86_tss.ecx, t->x86_tss.edx);
51657 + kdb_printf(" esi = " kdb_machreg_fmt0 ", edi = " kdb_machreg_fmt0
51658 + " ebp = " kdb_machreg_fmt0 "\n",
51659 + t->x86_tss.esi, t->x86_tss.edi, t->x86_tss.ebp);
51660 + kdb_printf(" trace = %d, iomap = 0x%04x\n", t->x86_tss.trace, t->x86_tss.io_bitmap_base);
51661 +#endif /* CONFIG_X86_64 */
51664 +static char *gate_desc_types[] = {
51665 +#ifdef CONFIG_X86_64
51666 + "reserved-0", "reserved-1", "ldt", "reserved-3",
51667 + "reserved-4", "reserved-5", "reserved-6", "reserved-7",
51668 + "reserved-8", "tss-avlb", "reserved-10", "tss-busy",
51669 + "callgate", "reserved-13", "intgate", "trapgate",
51670 +#else /* CONFIG_X86_64 */
51671 + "reserved-0", "tss16-avlb", "ldt", "tss16-busy",
51672 + "callgate16", "taskgate", "intgate16", "trapgate16",
51673 + "reserved-8", "tss-avlb", "reserved-10", "tss-busy",
51674 + "callgate", "reserved-13", "intgate", "trapgate",
51675 +#endif /* CONFIG_X86_64 */
51679 +display_gate_desc(kdb_gate_desc_t *d)
51681 + kdb_printf("%-11s ", gate_desc_types[d->type]);
51683 + switch(d->type) {
51684 + case KDB_SYS_DESC_TYPE_LDT:
51685 + kdb_printf("base=");
51686 + kdb_symbol_print(kdb_seg_desc_base((kdb_desc_t *)d), NULL,
51688 + kdb_printf(" limit=" kdb_machreg_fmt " dpl=%d\n",
51689 + KDB_SEG_DESC_LIMIT((kdb_desc_t *)d), d->dpl);
51691 + case KDB_SYS_DESC_TYPE_TSS:
51692 + case KDB_SYS_DESC_TYPE_TSS16:
51693 + case KDB_SYS_DESC_TYPE_TSSB:
51694 + case KDB_SYS_DESC_TYPE_TSSB16:
51696 + struct tss_struct *tss =
51697 + (struct tss_struct *)
51698 + kdb_seg_desc_base((kdb_desc_t *)d);
51699 + kdb_printf("base=");
51700 + kdb_symbol_print((unsigned long)tss, NULL, KDB_SP_DEFAULT);
51701 + kdb_printf(" limit=" kdb_machreg_fmt " dpl=%d\n",
51702 + KDB_SEG_DESC_LIMIT((kdb_desc_t *)d), d->dpl);
51703 + display_tss(tss);
51706 + case KDB_SYS_DESC_TYPE_CALLG16:
51707 + kdb_printf("segment=0x%4.4x off=", d->segment);
51708 + kdb_symbol_print(KDB_SYS_DESC_OFFSET(d), NULL, KDB_SP_DEFAULT);
51709 + kdb_printf(" dpl=%d wc=%d\n",
51710 + d->dpl, KDB_SYS_DESC_CALLG_COUNT(d));
51712 + case KDB_SYS_DESC_TYPE_CALLG:
51713 + kdb_printf("segment=0x%4.4x off=", d->segment);
51714 + kdb_symbol_print(KDB_SYS_DESC_OFFSET(d), NULL, KDB_SP_DEFAULT);
51715 + kdb_printf(" dpl=%d\n", d->dpl);
51718 + kdb_printf("segment=0x%4.4x off=", d->segment);
51719 + if (KDB_SYS_DESC_OFFSET(d))
51720 + kdb_symbol_print(KDB_SYS_DESC_OFFSET(d), NULL,
51723 + kdb_printf(kdb_machreg_fmt0, KDB_SYS_DESC_OFFSET(d));
51724 + kdb_printf(" dpl=%d", d->dpl);
51725 +#ifdef CONFIG_X86_64
51727 + kdb_printf(" ist=%d", d->ist);
51728 +#endif /* CONFIG_X86_64 */
51729 + kdb_printf("\n");
51735 +display_seg_desc(kdb_desc_t *d)
51737 + unsigned char type = d->type;
51739 + if (type & KDB_SEG_DESC_TYPE_CODE) {
51740 + kdb_printf("%-11s base=" kdb_machreg_fmt0 " limit="
51741 + kdb_machreg_fmt " dpl=%d %c%c%c %s %s %s \n",
51743 + kdb_seg_desc_base(d), KDB_SEG_DESC_LIMIT(d),
51745 + (type & KDB_SEG_DESC_TYPE_CODE_R)?'r':'-',
51747 +#ifdef CONFIG_X86_64
51748 + d->l ? "64b" : d->d ? "32b" : "16b",
51749 +#else /* !CONFIG_X86_64 */
51750 + d->d ? "32b" : "16b",
51751 +#endif /* CONFIG_X86_64 */
51752 + (type & KDB_SEG_DESC_TYPE_A)?"ac":"",
51753 + (type & KDB_SEG_DESC_TYPE_CODE_C)?"conf":"");
51755 + kdb_printf("%-11s base=" kdb_machreg_fmt0 " limit="
51756 + kdb_machreg_fmt " dpl=%d %c%c%c %s %s %s \n",
51758 + kdb_seg_desc_base(d), KDB_SEG_DESC_LIMIT(d),
51761 + (type & KDB_SEG_DESC_TYPE_DATA_W)?'w':'-',
51763 + d->d ? "32b" : "16b",
51764 + (type & KDB_SEG_DESC_TYPE_A)?"ac":"",
51765 + (type & KDB_SEG_DESC_TYPE_DATA_D)?"down":"");
51770 +kdb_parse_two_numbers(int argc, const char **argv, int *sel, int *count,
51771 + int *last_sel, int *last_count)
51776 + return KDB_ARGCOUNT;
51778 + kdbgetintenv("MDCOUNT", count);
51781 + *sel = *last_sel;
51783 + *count = *last_count;
51785 + unsigned long val;
51788 + diag = kdbgetularg(argv[1], &val);
51794 + diag = kdbgetularg(argv[2], &val);
51797 + *count = (int) val;
51798 + *last_count = (int) val;
51799 + } else if (*last_count) {
51800 + *count = *last_count;
51809 + * This function implements the 'gdt' command.
51811 + * gdt [<selector> [<line count>]]
51814 + * argc argument count
51815 + * argv argument vector
51819 + * zero for success, a kdb diagnostic if error
51825 +kdb_gdt(int argc, const char **argv)
51828 + struct desc_ptr gdtr;
51829 + int diag, count = 8;
51831 + unsigned int max_sel;
51832 + static int last_sel = 0, last_count = 0;
51834 + diag = kdb_parse_two_numbers(argc, argv, &sel, &count,
51835 + &last_sel, &last_count);
51839 + __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
51840 + gdt = (kdb_desc_t *) gdtr.address;
51842 + max_sel = (gdtr.size + 1) / sizeof(kdb_desc_t);
51843 + if (sel >= max_sel) {
51844 + kdb_printf("Maximum selector (%d) reached\n", max_sel);
51848 + if (sel + count > max_sel)
51849 + count = max_sel - sel;
51851 + while (count--) {
51852 + kdb_desc_t *d = &gdt[sel];
51853 + kdb_printf("0x%4.4x ", sel++);
51856 + kdb_printf("not present\n");
51860 + display_seg_desc(d);
51862 + display_gate_desc((kdb_gate_desc_t *)d);
51863 + if (KDB_X86_64 && count) {
51864 + ++sel; /* this descriptor occupies two slots */
51877 + * This function implements the 'ldt' command.
51879 + * ldt [<selector> [<line count>]]
51882 + * argc argument count
51883 + * argv argument vector
51887 + * zero for success, a kdb diagnostic if error
51893 +kdb_ldt(int argc, const char **argv)
51896 + struct desc_ptr gdtr;
51897 + unsigned long ldtr = 0;
51898 + int diag, count = 8;
51899 + kdb_desc_t *ldt, *ldt_desc;
51900 + unsigned int max_sel;
51901 + static int last_sel = 0, last_count = 0;
51903 + diag = kdb_parse_two_numbers(argc, argv, &sel, &count,
51904 + &last_sel, &last_count);
51908 + if (strcmp(argv[0], "ldtp") == 0) {
51909 + kdb_printf("pid=%d, process=%s\n",
51910 + kdb_current_task->pid, kdb_current_task->comm);
51911 + if (!kdb_current_task->mm ||
51912 + !kdb_current_task->mm->context.ldt) {
51913 + kdb_printf("no special LDT for this process\n");
51916 + ldt = kdb_current_task->mm->context.ldt;
51917 + max_sel = kdb_current_task->mm->context.size;
51920 + /* sldt gives the GDT selector for the segment containing LDT */
51921 + __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
51922 + __asm__ __volatile__ ("sldt %0\n\t" : "=m"(ldtr));
51923 + ldtr &= 0xfff8; /* extract the index */
51925 + if (ldtr > gdtr.size+1) {
51926 + kdb_printf("invalid ldtr\n");
51930 + ldt_desc = (kdb_desc_t *)(gdtr.address + ldtr);
51931 + ldt = (kdb_desc_t *)kdb_seg_desc_base(ldt_desc);
51932 + max_sel = (KDB_SEG_DESC_LIMIT(ldt_desc)+1) / sizeof(kdb_desc_t);
51935 + if (sel >= max_sel) {
51936 + kdb_printf("Maximum selector (%d) reached\n", max_sel);
51940 + if (sel + count > max_sel)
51941 + count = max_sel - sel;
51943 + while (count--) {
51944 + kdb_desc_t *d = &ldt[sel];
51945 + kdb_printf("0x%4.4x ", sel++);
51948 + kdb_printf("not present\n");
51952 + display_seg_desc(d);
51954 + display_gate_desc((kdb_gate_desc_t *)d);
51955 + if (KDB_X86_64 && count) {
51956 + ++sel; /* this descriptor occupies two slots */
51969 + * This function implements the 'idt' command.
51971 + * idt [<vector> [<line count>]]
51974 + * argc argument count
51975 + * argv argument vector
51979 + * zero for success, a kdb diagnostic if error
51985 +kdb_idt(int argc, const char **argv)
51988 + struct desc_ptr idtr;
51989 + int diag, count = 8;
51990 + kdb_gate_desc_t *idt;
51991 + unsigned int max_entries;
51992 + static int last_vec = 0, last_count = 0;
51994 + diag = kdb_parse_two_numbers(argc, argv, &vec, &count,
51995 + &last_vec, &last_count);
51999 + __asm__ __volatile__ ("sidt %0\n\t" : "=m"(idtr));
52000 + idt = (kdb_gate_desc_t *)idtr.address;
52002 + max_entries = (idtr.size+1) / sizeof(kdb_gate_desc_t);
52003 + if (vec >= max_entries) {
52004 + kdb_printf("Maximum vector (%d) reached\n", max_entries);
52008 + if (vec + count > max_entries)
52009 + count = max_entries - vec;
52011 + while (count--) {
52012 + kdb_gate_desc_t *d = &idt[vec];
52013 + kdb_printf("0x%4.4x ", vec++);
52015 + kdb_printf("not present\n");
52018 +#ifndef CONFIG_X86_64
52020 + kdb_printf("invalid\n");
52023 +#endif /* CONFIG_X86_64 */
52024 + display_gate_desc(d);
52032 +#define _PAGE_PSE 0x080
52036 +get_pagetables(unsigned long addr, pgd_t **pgdir, pmd_t **pgmiddle, pte_t **pte)
52042 + if (addr > PAGE_OFFSET) {
52043 + d = pgd_offset_k(addr);
52045 + kdb_printf("pid=%d, process=%s\n", kdb_current_task->pid, kdb_current_task->comm);
52046 + d = pgd_offset(kdb_current_task->mm, addr);
52049 + if (pgd_none(*d) || pgd_bad(*d)) {
52051 + *pgmiddle = NULL;
52058 + /* if _PAGE_PSE is set, pgdir points directly to the page. */
52059 + if (pgd_val(*d) & _PAGE_PSE) {
52060 + *pgmiddle = NULL;
52065 + m = pmd_offset(d, addr);
52066 + if (pmd_none(*m) || pmd_bad(*m)) {
52067 + *pgmiddle = NULL;
52074 + t = pte_offset(m, addr);
52075 + if (pte_none(*t)) {
52081 + kdb_printf("\naddr=%08lx, pgd=%08lx, pmd=%08lx, pte=%08lx\n",
52083 + (unsigned long) pgd_val(*d),
52084 + (unsigned long) pmd_val(*m),
52085 + (unsigned long) pte_val(*t));
52090 +#define FORMAT_PGDIR(entry) \
52091 + kdb_printf("frame=%05lx %c %s %c %c %c %s %c %s %s \n",\
52092 + (entry >> PAGE_SHIFT), \
52093 + (entry & _PAGE_PRESENT)?'p':'n', \
52094 + (entry & _PAGE_RW)?"rw":"ro", \
52095 + (entry & _PAGE_USER)?'u':'s', \
52096 + (entry & _PAGE_ACCESSED)?'a':' ', \
52098 + (entry & _PAGE_PSE)?"4M":"4K", \
52099 + (entry & _PAGE_GLOBAL)?'g':' ', \
52100 + (entry & _PAGE_PWT)?"wt":"wb", \
52101 + (entry & _PAGE_PCD)?"cd":" ");
52103 +#define FORMAT_PTE(p, entry) \
52104 + kdb_printf("frame=%05lx %c%c%c %c %c %c %s %c %s %s\n", \
52105 + (entry >> PAGE_SHIFT), \
52106 + (pte_read(p))? 'r':'-', \
52107 + (pte_write(p))? 'w':'-', \
52108 + (pte_exec(p))? 'x':'-', \
52109 + (pte_dirty(p))? 'd':' ', \
52110 + (pte_young(p))? 'a':' ', \
52111 + (entry & _PAGE_USER)? 'u':'s', \
52113 + (entry & _PAGE_GLOBAL)? 'g':' ', \
52114 + (entry & _PAGE_PWT)? "wt":"wb", \
52115 + (entry & _PAGE_PCD)? "cd":" ");
52118 +display_pgdir(unsigned long addr, pgd_t *pgdir, int count)
52120 + unsigned long entry;
52122 + int index = pgdir - ((pgd_t *)(((unsigned long)pgdir) & PAGE_MASK));
52124 + count = min(count, PTRS_PER_PGD - index);
52125 + addr &= ~(PGDIR_SIZE-1);
52127 + for (i = 0; i < count; i++, pgdir++) {
52128 + entry = pgd_val(*pgdir);
52129 + kdb_printf("pgd: addr=%08lx ", addr);
52130 + if (pgd_none(*pgdir)) {
52131 + kdb_printf("pgdir not present\n");
52133 + FORMAT_PGDIR(entry);
52135 + addr += PGDIR_SIZE;
52141 +#if 0 /* for now, let's not print pgmiddle. */
52143 +display_pgmiddle(unsigned long addr, pmd_t *pgmiddle, int count)
52145 + unsigned long entry;
52147 + int index = pgmiddle - ((pmd_t *)(((unsigned long)pgmiddle) & PAGE_MASK));
52149 + count = min(count, PTRS_PER_PMD - index);
52150 + addr &= ~(PMD_SIZE-1);
52152 + for (i = 0; i < count; i++, pgmiddle++) {
52153 + entry = pmd_val(*pgmiddle);
52154 + kdb_printf("pmd: addr=%08lx ", addr);
52155 + if (pmd_none(*pgmiddle)) {
52156 + kdb_printf("pgmiddle not present\n");
52158 + FORMAT_PGDIR(entry);
52160 + addr += PMD_SIZE;
52168 +display_pte(unsigned long addr, pte_t *pte, int count)
52170 + unsigned long entry;
52172 + int index = pte - ((pte_t *)(((unsigned long)pte) & PAGE_MASK));
52174 + count = min(count, PTRS_PER_PTE - index);
52175 + addr &= PAGE_MASK;
52177 + for (i = 0; i < count; i++, pte++) {
52178 + entry = pte_val(*pte);
52179 + kdb_printf("pte: addr=%08lx ", addr);
52180 + if (pte_none(*pte)) {
52181 + kdb_printf("pte not present\n");
52182 + } else if (!pte_present(*pte)) {
52183 + kdb_printf("page swapped out. swp_offset=%08lx ", SWP_OFFSET(pte_to_swp_entry(*pte)));
52184 + kdb_printf("swp_type=%8lx", SWP_TYPE(pte_to_swp_entry(*pte)));
52186 + FORMAT_PTE(*pte, entry);
52188 + addr += PAGE_SIZE;
52197 + * This function implements the 'pte' command.
52199 + * pte <addr arg> [<line count>]
52202 + * argc argument count
52203 + * argv argument vector
52207 + * zero for success, a kdb diagnostic if error
52213 +kdb_pte(int argc, const char **argv)
52215 + static unsigned long last_addr = 0, last_count = 0;
52217 + unsigned long addr;
52223 +#ifdef CONFIG_X86_PAE
52224 + kdb_printf("This kernel is compiled with PAE support.");
52225 + return KDB_NOTIMP;
52227 + kdbgetintenv("MDCOUNT", &count);
52230 + if (last_addr == 0)
52231 + return KDB_ARGCOUNT;
52232 + addr = last_addr;
52234 + count = last_count;
52236 + kdb_machreg_t val;
52237 + int diag, nextarg = 1;
52238 + diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
52241 + if (argc > nextarg+1)
52242 + return KDB_ARGCOUNT;
52244 + if (argc >= nextarg) {
52245 + diag = kdbgetularg(argv[nextarg], &val);
52247 + count = (int) val;
52248 + last_count = count;
52249 + } else if (last_count) {
52250 + count = last_count;
52256 + * round off the addr to a page boundary.
52258 + addr &= PAGE_MASK;
52260 + get_pagetables(addr, &pgdir, &pgmiddle, &pte);
52263 + display_pgdir(addr, pgdir, 1);
52264 +#if 0 /* for now, let's not print pgmiddle. */
52266 + display_pgmiddle(addr, pgmiddle, 1);
52270 + displayed = display_pte(addr, pte, count);
52271 + addr += (displayed << PAGE_SHIFT);
52273 + last_addr = addr;
52278 + * Todo - In 2.5 the pte_offset macro in asm/pgtable.h seems to be
52279 + * renamed to pte_offset_kernel.
52282 +kdb_pte(int argc, const char **argv)
52284 + kdb_printf("not supported.");
52285 + return KDB_NOTIMP;
52292 + * This function implements the 'rdv' command.
52293 + * It displays all registers of the current processor
52294 + * included control registers in verbose mode.
52297 + * argc argument count
52298 + * argv argument vector
52302 + * zero for success, a kdb diagnostic if error
52306 + * This should have been an option to rd command say "rd v",
52307 + * but it is here as it is a non-essential x86-only command,
52308 + * that need not clutter arch/i386/kdb/kdbasupport.c.
52311 +kdb_rdv(int argc, const char **argv)
52313 + struct pt_regs *regs = get_irq_regs();
52314 + kdba_dumpregs(regs, NULL, NULL);
52315 + kdb_printf("\n");
52316 + display_eflags(regs->eflags);
52317 + kdb_printf("\n");
52321 + kdb_printf("\n");
52326 + kdb_printf("\n");
52332 +kdb_rdmsr(int argc, const char **argv)
52334 + unsigned long addr;
52337 + struct cpuinfo_x86 *c = cpu_data + smp_processor_id();
52340 + return KDB_ARGCOUNT;
52342 + if ((diag = kdbgetularg(argv[1], &addr)))
52345 + if (!cpu_has(c, X86_FEATURE_MSR))
52346 + return KDB_NOTIMP;
52348 + kdb_printf("msr(0x%lx) = ", addr);
52349 + if ((diag = rdmsr_safe(addr, &l, &h))) {
52350 + kdb_printf("error %d\n", diag);
52351 + return KDB_BADINT;
52353 + kdb_printf("0x%08x_%08x\n", h, l);
52360 +kdb_wrmsr(int argc, const char **argv)
52362 + unsigned long addr;
52363 + unsigned long l, h;
52365 + struct cpuinfo_x86 *c = cpu_data + smp_processor_id();
52368 + return KDB_ARGCOUNT;
52370 + if ((diag = kdbgetularg(argv[1], &addr))
52371 + || (diag = kdbgetularg(argv[2], &h))
52372 + || (diag = kdbgetularg(argv[3], &l)))
52375 + if (!cpu_has(c, X86_FEATURE_MSR))
52376 + return KDB_NOTIMP;
52378 + if ((diag = wrmsr_safe(addr, l, h))) {
52379 + kdb_printf("error %d\n", diag);
52380 + return KDB_BADINT;
52386 +static int __init kdbm_x86_init(void)
52388 + kdb_register("rdv", kdb_rdv, NULL, "Display registers in verbose mode", 0);
52389 + kdb_register_repeat("gdt", kdb_gdt, "<sel> [<count>]", "Display GDT", 0, KDB_REPEAT_NO_ARGS);
52390 + kdb_register_repeat("idt", kdb_idt, "<int> [<count>]", "Display IDT", 0, KDB_REPEAT_NO_ARGS);
52391 + kdb_register_repeat("ldt", kdb_ldt, "<sel> [<count>]", "Display LDT", 0, KDB_REPEAT_NO_ARGS);
52392 + kdb_register_repeat("ptex", kdb_pte, "<addr> [<count>]", "Display pagetables", 0, KDB_REPEAT_NO_ARGS);
52393 + kdb_register_repeat("ldtp", kdb_ldt, "<sel> [<count>]", "Display Process LDT", 0, KDB_REPEAT_NO_ARGS);
52394 + kdb_register("rdmsr", kdb_rdmsr, "<maddr>", "Display Model Specific Register", 0);
52395 + kdb_register("wrmsr", kdb_wrmsr, "<maddr> <h> <l>", "Modify Model Specific Register", 0);
52399 +static void __exit kdbm_x86_exit(void)
52401 + kdb_unregister("rdv");
52402 + kdb_unregister("gdt");
52403 + kdb_unregister("ldt");
52404 + kdb_unregister("idt");
52405 + kdb_unregister("ptex");
52406 + kdb_unregister("ldtp");
52407 + kdb_unregister("rdmsr");
52408 + kdb_unregister("wrmsr");
52411 +module_init(kdbm_x86_init)
52412 +module_exit(kdbm_x86_exit)
52413 diff -Nurp linux-2.6.22-590/kdb/modules/kdbm_xpc.c linux-2.6.22-600/kdb/modules/kdbm_xpc.c
52414 --- linux-2.6.22-590/kdb/modules/kdbm_xpc.c 1970-01-01 01:00:00.000000000 +0100
52415 +++ linux-2.6.22-600/kdb/modules/kdbm_xpc.c 2008-04-09 18:14:28.000000000 +0200
52418 + * This file is subject to the terms and conditions of the GNU General Public
52419 + * License. See the file "COPYING" in the main directory of this archive
52420 + * for more details.
52422 + * Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved.
52427 + * Cross Partition Communication (XPC) kdb support.
52429 + * This provides kdb commands for debugging XPC.
52432 +#include <linux/kernel.h>
52433 +#include <linux/module.h>
52434 +#include <linux/kdb.h>
52435 +#include <linux/kdbprivate.h>
52436 +#include <asm/sn/sn_sal.h>
52437 +#include <asm/sn/xpc.h>
52440 +MODULE_AUTHOR("SGI");
52441 +MODULE_DESCRIPTION("Debug XPC information");
52442 +MODULE_LICENSE("GPL");
52446 +kdbm_xpc_down(int argc, const char **argv)
52448 + if (xpc_rsvd_page == NULL) {
52449 + kdb_printf("Reserved Page has not been initialized.\n");
52451 + } else if (xpc_kdebug_force_disengage()) {
52452 + kdb_printf("Unable to force XPC disengage.\n");
52459 +kdbm_xpc_get_ascii_reason_code(enum xpc_retval reason)
52461 + switch (reason) {
52462 + case xpcSuccess: return "";
52463 + case xpcNotConnected: return "xpcNotConnected";
52464 + case xpcConnected: return "xpcConnected";
52465 + case xpcRETIRED1: return "xpcRETIRED1";
52466 + case xpcMsgReceived: return "xpcMsgReceived";
52467 + case xpcMsgDelivered: return "xpcMsgDelivered";
52468 + case xpcRETIRED2: return "xpcRETIRED2";
52469 + case xpcNoWait: return "xpcNoWait";
52470 + case xpcRetry: return "xpcRetry";
52471 + case xpcTimeout: return "xpcTimeout";
52472 + case xpcInterrupted: return "xpcInterrupted";
52473 + case xpcUnequalMsgSizes: return "xpcUnequalMsgSizes";
52474 + case xpcInvalidAddress: return "xpcInvalidAddress";
52475 + case xpcNoMemory: return "xpcNoMemory";
52476 + case xpcLackOfResources: return "xpcLackOfResources";
52477 + case xpcUnregistered: return "xpcUnregistered";
52478 + case xpcAlreadyRegistered: return "xpcAlreadyRegistered";
52479 + case xpcPartitionDown: return "xpcPartitionDown";
52480 + case xpcNotLoaded: return "xpcNotLoaded";
52481 + case xpcUnloading: return "xpcUnloading";
52482 + case xpcBadMagic: return "xpcBadMagic";
52483 + case xpcReactivating: return "xpcReactivating";
52484 + case xpcUnregistering: return "xpcUnregistering";
52485 + case xpcOtherUnregistering: return "xpcOtherUnregistering";
52486 + case xpcCloneKThread: return "xpcCloneKThread";
52487 + case xpcCloneKThreadFailed: return "xpcCloneKThreadFailed";
52488 + case xpcNoHeartbeat: return "xpcNoHeartbeat";
52489 + case xpcPioReadError: return "xpcPioReadError";
52490 + case xpcPhysAddrRegFailed: return "xpcPhysAddrRegFailed";
52491 + case xpcBteDirectoryError: return "xpcBteDirectoryError";
52492 + case xpcBtePoisonError: return "xpcBtePoisonError";
52493 + case xpcBteWriteError: return "xpcBteWriteError";
52494 + case xpcBteAccessError: return "xpcBteAccessError";
52495 + case xpcBtePWriteError: return "xpcBtePWriteError";
52496 + case xpcBtePReadError: return "xpcBtePReadError";
52497 + case xpcBteTimeOutError: return "xpcBteTimeOutError";
52498 + case xpcBteXtalkError: return "xpcBteXtalkError";
52499 + case xpcBteNotAvailable: return "xpcBteNotAvailable";
52500 + case xpcBteUnmappedError: return "xpcBteUnmappedError";
52501 + case xpcBadVersion: return "xpcBadVersion";
52502 + case xpcVarsNotSet: return "xpcVarsNotSet";
52503 + case xpcNoRsvdPageAddr: return "xpcNoRsvdPageAddr";
52504 + case xpcInvalidPartid: return "xpcInvalidPartid";
52505 + case xpcLocalPartid: return "xpcLocalPartid";
52506 + case xpcOtherGoingDown: return "xpcOtherGoingDown";
52507 + case xpcSystemGoingDown: return "xpcSystemGoingDown";
52508 + case xpcSystemHalt: return "xpcSystemHalt";
52509 + case xpcSystemReboot: return "xpcSystemReboot";
52510 + case xpcSystemPoweroff: return "xpcSystemPoweroff";
52511 + case xpcDisconnecting: return "xpcDisconnecting";
52512 + case xpcOpenCloseError: return "xpcOpenCloseError";
52513 + case xpcUnknownReason: return "xpcUnknownReason";
52514 + default: return "undefined reason code";
52520 + * Display the reserved page used by XPC.
52525 +kdbm_xpc_rsvd_page(int argc, const char **argv)
52527 + struct xpc_rsvd_page *rp = (struct xpc_rsvd_page *) xpc_rsvd_page;
52531 + return KDB_ARGCOUNT;
52534 + if (rp == NULL) {
52535 + kdb_printf("Reserved Page has not been initialized.\n");
52539 + kdb_printf("struct xpc_rsvd_page @ (0x%p):\n", (void *) rp);
52540 + kdb_printf("\tSAL_signature=0x%lx\n", rp->SAL_signature);
52541 + kdb_printf("\tSAL_version=0x%lx\n", rp->SAL_version);
52542 + kdb_printf("\tpartid=%d\n", rp->partid);
52543 + kdb_printf("\tversion=0x%x %d.%d\n", rp->version,
52544 + XPC_VERSION_MAJOR(rp->version),
52545 + XPC_VERSION_MINOR(rp->version));
52546 + kdb_printf("\tvars_pa=0x%lx\n", rp->vars_pa);
52547 + kdb_printf("\tstamp=0x%lx:0x%lx\n",
52548 + rp->stamp.tv_sec, rp->stamp.tv_nsec);
52549 + kdb_printf("\tnasids_size=%ld\n", rp->nasids_size);
52556 +kdbm_xpc_print_vars_part(struct xpc_vars_part *vars_part, partid_t partid)
52558 + kdb_printf("struct xpc_vars_part @ (0x%p) [partid=%d]:\n",
52559 + (void *) vars_part, partid);
52560 + kdb_printf("\tmagic=0x%lx ", vars_part->magic);
52561 + if (vars_part->magic != 0) {
52562 + kdb_printf("%s", (char *) &vars_part->magic);
52564 + kdb_printf("\n");
52565 + kdb_printf("\tGPs_pa=0x%lx\n", vars_part->GPs_pa);
52566 + kdb_printf("\topenclose_args_pa=0x%lx\n",
52567 + vars_part->openclose_args_pa);
52568 + kdb_printf("\tIPI_amo_pa=0x%lx\n", vars_part->IPI_amo_pa);
52569 + kdb_printf("\tIPI_nasid=0x%x\n", vars_part->IPI_nasid);
52570 + kdb_printf("\tIPI_phys_cpuid=0x%x\n", vars_part->IPI_phys_cpuid);
52571 + kdb_printf("\tnchannels=%d\n", vars_part->nchannels);
52576 + * Display XPC variables.
52578 + * xpcvars [ <partid> ]
52580 + * no partid - displays xpc_vars structure
52581 + * partid=0 - displays all initialized xpc_vars_part structures
52582 + * partid=i - displays xpc_vars_part structure for specified
52583 + * partition, if initialized
52586 +kdbm_xpc_variables(int argc, const char **argv)
52589 + unsigned long ulong_partid;
52591 + struct xpc_vars_part *vars_part;
52594 + if (xpc_rsvd_page == NULL) {
52595 + kdb_printf("Reserved Page has not been initialized.\n");
52598 + DBUG_ON(xpc_vars == NULL);
52602 + /* just display the xpc_vars structure */
52604 + kdb_printf("struct xpc_vars @ (0x%p):\n", (void *) xpc_vars);
52605 + kdb_printf("\tversion=0x%x %d.%d\n", xpc_vars->version,
52606 + XPC_VERSION_MAJOR(xpc_vars->version),
52607 + XPC_VERSION_MINOR(xpc_vars->version));
52608 + kdb_printf("\theartbeat=%ld\n", xpc_vars->heartbeat);
52609 + kdb_printf("\theartbeating_to_mask=0x%lx",
52610 + xpc_vars->heartbeating_to_mask);
52611 + for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
52612 + if (xpc_hb_allowed(partid, xpc_vars)) {
52613 + kdb_printf(" %d", partid);
52616 + kdb_printf("\n");
52617 + kdb_printf("\theartbeat_offline=0x%lx\n",
52618 + xpc_vars->heartbeat_offline);
52619 + kdb_printf("\tact_nasid=0x%x\n", xpc_vars->act_nasid);
52620 + kdb_printf("\tact_phys_cpuid=0x%x\n",
52621 + xpc_vars->act_phys_cpuid);
52622 + kdb_printf("\tvars_part_pa=0x%lx\n", xpc_vars->vars_part_pa);
52623 + kdb_printf("\tamos_page_pa=0x%lx\n", xpc_vars->amos_page_pa);
52624 + kdb_printf("\tamos_page=0x%p\n", (void *) xpc_vars->amos_page);
52627 + } else if (argc != 1) {
52628 + return KDB_ARGCOUNT;
52631 + ret = kdbgetularg(argv[1], (unsigned long *) &ulong_partid);
52635 + partid = (partid_t) ulong_partid;
52636 + if (partid < 0 || partid >= XP_MAX_PARTITIONS) {
52637 + kdb_printf("invalid partid\n");
52638 + return KDB_BADINT;
52641 + vars_part = (struct xpc_vars_part *) __va(xpc_vars->vars_part_pa);
52642 + DBUG_ON(vars_part == NULL);
52644 + if (partid == 0) {
52646 + /* display all initialized xpc_vars_part structure */
52648 + for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
52649 + if (vars_part[partid].magic == 0) {
52652 + kdbm_xpc_print_vars_part(&vars_part[partid], partid);
52657 + /* display specified xpc_vars_part structure */
52659 + if (vars_part[partid].magic != 0) {
52660 + kdbm_xpc_print_vars_part(&vars_part[partid], partid);
52662 + kdb_printf("struct xpc_vars_part for partid %d not "
52663 + "initialized\n", partid);
52672 +kdbm_xpc_print_engaged(char *string, u64 mask, int verbose)
52677 + kdb_printf("%s=0x%lx", string, mask);
52681 + while (mask != 0) {
52682 + if (mask & 1UL) {
52683 + kdb_printf(" %d", partid);
52689 + kdb_printf("\n");
52694 + * Display XPC's 'engaged partitions' and 'disengage request' AMOs.
52696 + * xpcengaged [ -v ]
52698 + * -v - verbose mode, displays partition numbers.
52701 +kdbm_xpc_engaged(int argc, const char **argv)
52709 + return KDB_ARGCOUNT;
52712 + if (strcmp(argv[nextarg], "-v") != 0) {
52713 + return KDB_ARGCOUNT;
52718 + mask = xpc_partition_engaged(-1UL);
52719 + kdbm_xpc_print_engaged("engaged partitions", mask, verbose);
52721 + mask = xpc_partition_disengage_requested(-1UL);
52722 + kdbm_xpc_print_engaged("disengage request", mask, verbose);
52729 +kdbm_xpc_print_IPI_flags_for_channel(u8 IPI_flags)
52731 + if (IPI_flags & XPC_IPI_MSGREQUEST) kdb_printf(" MSGREQUEST");
52732 + if (IPI_flags & XPC_IPI_OPENREPLY) kdb_printf(" OPENREPLY");
52733 + if (IPI_flags & XPC_IPI_OPENREQUEST) kdb_printf(" OPENREQUEST");
52734 + if (IPI_flags & XPC_IPI_CLOSEREPLY) kdb_printf(" CLOSEREPLY");
52735 + if (IPI_flags & XPC_IPI_CLOSEREQUEST) kdb_printf(" CLOSEREQUEST");
52740 +kdbm_xpc_print_IPI_flags(u64 IPI_amo)
52746 + for (ch_number = 0; ch_number < XPC_NCHANNELS; ch_number++) {
52748 + /* get the IPI flags for the specific channel */
52749 + IPI_flags = XPC_GET_IPI_FLAGS(IPI_amo, ch_number);
52750 + if (IPI_flags == 0) {
52754 + kdb_printf("\t channel_%d=0x%x", ch_number, IPI_flags);
52755 + kdbm_xpc_print_IPI_flags_for_channel(IPI_flags);
52756 + kdb_printf("\n");
52762 +kdbm_xpc_print_part(struct xpc_partition *part, partid_t partid)
52764 + kdb_printf("xpc_partitions[partid=%d] (0x%p):\n", partid,
52766 + kdb_printf("\tremote_rp_version=0x%x %d.%d\n", part->remote_rp_version,
52767 + XPC_VERSION_MAJOR(part->remote_rp_version),
52768 + XPC_VERSION_MINOR(part->remote_rp_version));
52769 + kdb_printf("\tremote_rp_stamp=0x%lx:0x%lx\n",
52770 + part->remote_rp_stamp.tv_sec, part->remote_rp_stamp.tv_nsec);
52771 + kdb_printf("\tremote_rp_pa=0x%lx\n", part->remote_rp_pa);
52772 + kdb_printf("\tremote_vars_pa=0x%lx\n", part->remote_vars_pa);
52773 + kdb_printf("\tremote_vars_part_pa=0x%lx\n", part->remote_vars_part_pa);
52774 + kdb_printf("\tlast_heartbeat=%ld\n", part->last_heartbeat);
52775 + kdb_printf("\tremote_amos_page_pa=0x%lx\n", part->remote_amos_page_pa);
52776 + kdb_printf("\tremote_act_nasid=0x%x\n", part->remote_act_nasid);
52777 + kdb_printf("\tremote_act_phys_cpuid=0x%x\n",
52778 + part->remote_act_phys_cpuid);
52779 + kdb_printf("\tact_IRQ_rcvd=%d\n", part->act_IRQ_rcvd);
52780 + kdb_printf("\tact_state=%d", part->act_state);
52781 + switch (part->act_state) {
52782 + case XPC_P_INACTIVE: kdb_printf(" INACTIVE\n"); break;
52783 + case XPC_P_ACTIVATION_REQ: kdb_printf(" ACTIVATION_REQ\n"); break;
52784 + case XPC_P_ACTIVATING: kdb_printf(" ACTIVATING\n"); break;
52785 + case XPC_P_ACTIVE: kdb_printf(" ACTIVE\n"); break;
52786 + case XPC_P_DEACTIVATING: kdb_printf(" DEACTIVATING\n"); break;
52787 + default: kdb_printf(" unknown\n");
52789 + kdb_printf("\tremote_vars_version=0x%x %d.%d\n",
52790 + part->remote_vars_version,
52791 + XPC_VERSION_MAJOR(part->remote_vars_version),
52792 + XPC_VERSION_MINOR(part->remote_vars_version));
52793 + kdb_printf("\treactivate_nasid=%d\n", part->reactivate_nasid);
52794 + kdb_printf("\treason=%d %s\n", part->reason,
52795 + kdbm_xpc_get_ascii_reason_code(part->reason));
52796 + kdb_printf("\treason_line=%d\n", part->reason_line);
52798 + kdb_printf("\tdisengage_request_timeout=0x%lx\n",
52799 + part->disengage_request_timeout);
52800 + kdb_printf("\t&disengage_request_timer=0x%p\n",
52801 + (void *) &part->disengage_request_timer);
52803 + kdb_printf("\tsetup_state=%d", part->setup_state);
52804 + switch (part->setup_state) {
52805 + case XPC_P_UNSET: kdb_printf(" UNSET\n"); break;
52806 + case XPC_P_SETUP: kdb_printf(" SETUP\n"); break;
52807 + case XPC_P_WTEARDOWN: kdb_printf(" WTEARDOWN\n"); break;
52808 + case XPC_P_TORNDOWN: kdb_printf(" TORNDOWN\n"); break;
52809 + default: kdb_printf(" unknown\n");
52811 + kdb_printf("\treferences=%d\n", atomic_read(&part->references));
52812 + kdb_printf("\tnchannels=%d\n", part->nchannels);
52813 + kdb_printf("\tnchannels_active=%d\n",
52814 + atomic_read(&part->nchannels_active));
52815 + kdb_printf("\tnchannels_engaged=%d\n",
52816 + atomic_read(&part->nchannels_engaged));
52817 + kdb_printf("\tchannels=0x%p\n", (void *) part->channels);
52818 + kdb_printf("\tlocal_GPs=0x%p\n", (void *) part->local_GPs);
52819 + kdb_printf("\tremote_GPs=0x%p\n", (void *) part->remote_GPs);
52820 + kdb_printf("\tremote_GPs_pa=0x%lx\n", part->remote_GPs_pa);
52821 + kdb_printf("\tlocal_openclose_args=0x%p\n",
52822 + (void *) part->local_openclose_args);
52823 + kdb_printf("\tremote_openclose_args=0x%p\n",
52824 + (void *) part->remote_openclose_args);
52825 + kdb_printf("\tremote_openclose_args_pa=0x%lx\n",
52826 + part->remote_openclose_args_pa);
52827 + kdb_printf("\tremote_IPI_nasid=0x%x\n", part->remote_IPI_nasid);
52828 + kdb_printf("\tremote_IPI_phys_cpuid=0x%x\n",
52829 + part->remote_IPI_phys_cpuid);
52830 + kdb_printf("\tremote_IPI_amo_va=0x%p\n",
52831 + (void *) part->remote_IPI_amo_va);
52832 + kdb_printf("\tlocal_IPI_amo_va=0x%p\n",
52833 + (void *) part->local_IPI_amo_va);
52834 + kdb_printf("\tlocal_IPI_amo=0x%lx\n", part->local_IPI_amo);
52835 + kdbm_xpc_print_IPI_flags(part->local_IPI_amo);
52836 + kdb_printf("\tIPI_owner=%s\n", part->IPI_owner);
52837 + kdb_printf("\t&dropped_IPI_timer=0x%p\n",
52838 + (void *) &part->dropped_IPI_timer);
52840 + kdb_printf("\tchannel_mgr_requests=%d\n", atomic_read(&part->
52841 + channel_mgr_requests));
52846 + * Display XPC partitions.
52848 + * xpcpart [ <vaddr> | <partid> ]
52851 +kdbm_xpc_partitions(int argc, const char **argv)
52856 + unsigned long addr;
52857 + struct xpc_partition *part;
52862 + return KDB_ARGCOUNT;
52864 + } else if (argc == 1) {
52865 + ret = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
52870 + if (addr > 0 && addr < XP_MAX_PARTITIONS) {
52871 + partid = (partid_t) addr;
52872 + part = &xpc_partitions[partid];
52874 + part = (struct xpc_partition *) addr;
52875 + partid = part - &xpc_partitions[0];
52876 + if (partid <= 0 || partid >= XP_MAX_PARTITIONS ||
52877 + part != &xpc_partitions[partid]) {
52878 + kdb_printf("invalid partition entry address\n");
52879 + return KDB_BADADDR;
52882 + kdbm_xpc_print_part(part, partid);
52885 + for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
52886 + part = &xpc_partitions[partid];
52887 + if (part->setup_state == XPC_P_UNSET &&
52888 + part->reason == 0) {
52891 + kdbm_xpc_print_part(part, partid);
52899 +kdbm_xpc_print_channel_flags(u32 flags)
52901 + kdb_printf("\tflags=0x%x", flags);
52903 + if (flags & XPC_C_WDISCONNECT) kdb_printf(" WDISCONNECT");
52904 + if (flags & XPC_C_DISCONNECTINGCALLOUT_MADE) kdb_printf(" DISCONNECTINGCALLOUT_MADE");
52905 + if (flags & XPC_C_DISCONNECTINGCALLOUT) kdb_printf(" DISCONNECTINGCALLOUT");
52906 + if (flags & XPC_C_DISCONNECTING) kdb_printf(" DISCONNECTING");
52907 + if (flags & XPC_C_DISCONNECTED) kdb_printf(" DISCONNECTED");
52909 + if (flags & XPC_C_CLOSEREQUEST) kdb_printf(" CLOSEREQUEST");
52910 + if (flags & XPC_C_RCLOSEREQUEST) kdb_printf(" RCLOSEREQUEST");
52911 + if (flags & XPC_C_CLOSEREPLY) kdb_printf(" CLOSEREPLY");
52912 + if (flags & XPC_C_RCLOSEREPLY) kdb_printf(" RCLOSEREPLY");
52914 + if (flags & XPC_C_CONNECTING) kdb_printf(" CONNECTING");
52915 + if (flags & XPC_C_CONNECTED) kdb_printf(" CONNECTED");
52916 + if (flags & XPC_C_CONNECTEDCALLOUT_MADE) kdb_printf(" CONNECTEDCALLOUT_MADE");
52917 + if (flags & XPC_C_CONNECTEDCALLOUT) kdb_printf(" CONNECTEDCALLOUT");
52918 + if (flags & XPC_C_SETUP) kdb_printf(" SETUP");
52920 + if (flags & XPC_C_OPENREQUEST) kdb_printf(" OPENREQUEST");
52921 + if (flags & XPC_C_ROPENREQUEST) kdb_printf(" ROPENREQUEST");
52922 + if (flags & XPC_C_OPENREPLY) kdb_printf(" OPENREPLY");
52923 + if (flags & XPC_C_ROPENREPLY) kdb_printf(" ROPENREPLY");
52925 + if (flags & XPC_C_WASCONNECTED) kdb_printf(" WASCONNECTED");
52927 + kdb_printf("\n");
52932 +kdbm_xpc_print_channel(struct xpc_channel *ch)
52934 + kdb_printf("channel %d (0x%p):\n", ch->number, (void *) ch);
52935 + kdb_printf("\tpartid=%d\n", ch->partid);
52937 + kdbm_xpc_print_channel_flags(ch->flags);
52939 + kdb_printf("\treason=%d %s\n", ch->reason,
52940 + kdbm_xpc_get_ascii_reason_code(ch->reason));
52941 + kdb_printf("\treason_line=%d\n", ch->reason_line);
52942 + kdb_printf("\tnumber=%d\n", ch->number);
52943 + kdb_printf("\tmsg_size=%d\n", ch->msg_size);
52944 + kdb_printf("\tlocal_nentries=%d\n", ch->local_nentries);
52945 + kdb_printf("\tremote_nentries=%d\n", ch->remote_nentries);
52946 + kdb_printf("\tlocal_msgqueue=0x%p\n", (void *) ch->local_msgqueue);
52947 + kdb_printf("\tremote_msgqueue_pa=0x%lx\n", ch->remote_msgqueue_pa);
52948 + kdb_printf("\tremote_msgqueue=0x%p\n",
52949 + (void *) ch->remote_msgqueue);
52950 + kdb_printf("\treferences=%d\n", atomic_read(&ch->references));
52951 + kdb_printf("\tn_on_msg_allocate_wq=%d\n",
52952 + atomic_read(&ch->n_on_msg_allocate_wq));
52953 + kdb_printf("\t&msg_allocate_wq=0x%p\n",
52954 + (void *) &ch->msg_allocate_wq);
52956 + kdb_printf("\tdelayed_IPI_flags=0x%x", ch->delayed_IPI_flags);
52957 + kdbm_xpc_print_IPI_flags_for_channel(ch->delayed_IPI_flags);
52958 + kdb_printf("\n");
52960 + kdb_printf("\tn_to_notify=%d\n", atomic_read(&ch->n_to_notify));
52961 + kdb_printf("\tnotify_queue=0x%p\n", (void *) ch->notify_queue);
52962 + kdb_printf("\tfunc=0x%p\n", (void *) ch->func);
52963 + kdb_printf("\tkey=0x%p\n", ch->key);
52964 + kdb_printf("\t&msg_to_pull_mutex=0x%p\n",
52965 + (void *) &ch->msg_to_pull_mutex);
52966 + kdb_printf("\t&wdisconnect_wait=0x%p\n",
52967 + (void *) &ch->wdisconnect_wait);
52968 + kdb_printf("\tlocal_GP=0x%p (%ld:%ld)\n", (void *) ch->local_GP,
52969 + ch->local_GP->get,
52970 + ch->local_GP->put);
52971 + kdb_printf("\tremote_GP=%ld:%ld\n", ch->remote_GP.get,
52972 + ch->remote_GP.put);
52973 + kdb_printf("\tw_local_GP=%ld:%ld\n", ch->w_local_GP.get,
52974 + ch->w_local_GP.put);
52975 + kdb_printf("\tw_remote_GP=%ld:%ld\n", ch->w_remote_GP.get,
52976 + ch->w_remote_GP.put);
52977 + kdb_printf("\tnext_msg_to_pull=%ld\n", ch->next_msg_to_pull);
52978 + kdb_printf("\tkthreads_assigned=%d\n",
52979 + atomic_read(&ch->kthreads_assigned));
52980 + kdb_printf("\tkthreads_assigned_limit=%d\n",
52981 + ch->kthreads_assigned_limit);
52982 + kdb_printf("\tkthreads_idle=%d\n",
52983 + atomic_read(&ch->kthreads_idle));
52984 + kdb_printf("\tkthreads_idle_limit=%d\n", ch->kthreads_idle_limit);
52985 + kdb_printf("\tkthreads_active=%d\n",
52986 + atomic_read(&ch->kthreads_active));
52987 + kdb_printf("\tkthreads_created=%d\n", ch->kthreads_created);
52988 + kdb_printf("\t&idle_wq=0x%p\n", (void *) &ch->idle_wq);
52990 + if (ch->flags & XPC_C_CONNECTED) {
52991 + kdb_printf("\n\t#of local msg queue entries available =%ld\n",
52992 + ch->local_nentries - (ch->w_local_GP.put -
52993 + ch->w_remote_GP.get));
52995 + kdb_printf("\t#of local msgs allocated !sent =%ld\n",
52996 + ch->w_local_GP.put - ch->local_GP->put);
52997 + kdb_printf("\t#of local msgs allocated sent !ACK'd =%ld\n",
52998 + ch->local_GP->put - ch->remote_GP.get);
52999 + kdb_printf("\t#of local msgs allocated sent ACK'd !notified ="
53000 + "%ld\n", ch->remote_GP.get - ch->w_remote_GP.get);
53002 + kdb_printf("\t#of remote msgs sent !pulled =%ld\n",
53003 + ch->w_remote_GP.put - ch->next_msg_to_pull);
53004 + kdb_printf("\t#of remote msgs sent !delivered =%ld\n",
53005 + ch->next_msg_to_pull - ch->w_local_GP.get);
53006 + kdb_printf("\t#of remote msgs sent delivered !received =%ld\n",
53007 + ch->w_local_GP.get - ch->local_GP->get);
53013 + * Display a XPC partition's channels.
53015 + * xpcchan <vaddr> | <partid> [ <channel> ]
53018 +kdbm_xpc_channels(int argc, const char **argv)
53023 + unsigned long addr;
53025 + struct xpc_partition *part;
53027 + struct xpc_channel *ch;
53030 + if (argc < 1 || argc > 2) {
53031 + return KDB_ARGCOUNT;
53034 + ret = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
53038 + if (addr > 0 && addr < XP_MAX_PARTITIONS) {
53039 + partid = (partid_t) addr;
53040 + part = &xpc_partitions[partid];
53041 + if (part->setup_state == XPC_P_UNSET) {
53042 + kdb_printf("partition is UNSET\n");
53045 + if (part->setup_state == XPC_P_TORNDOWN) {
53046 + kdb_printf("partition is TORNDOWN\n");
53051 + ret = kdbgetularg(argv[2],
53052 + (unsigned long *) &ch_number);
53056 + if (ch_number < 0 || ch_number >= part->nchannels) {
53057 + kdb_printf("invalid channel #\n");
53058 + return KDB_BADINT;
53060 + kdbm_xpc_print_channel(&part->channels[ch_number]);
53062 + for (ch_number = 0; ch_number < part->nchannels;
53064 + kdbm_xpc_print_channel(&part->
53065 + channels[ch_number]);
53070 + ch = (struct xpc_channel *) addr;
53072 + for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
53073 + part = &xpc_partitions[partid];
53074 + if (part->setup_state != XPC_P_UNSET &&
53075 + part->setup_state != XPC_P_TORNDOWN &&
53076 + ch >= part->channels) {
53077 + ch_number = ch - part->channels;
53078 + if (ch_number < part->nchannels &&
53079 + ch == &part->channels[ch_number]) {
53084 + if (partid == XP_MAX_PARTITIONS) {
53085 + kdb_printf("invalid channel address\n");
53086 + return KDB_BADADDR;
53088 + kdbm_xpc_print_channel(ch);
53096 +kdbm_xpc_print_local_msgqueue(struct xpc_channel *ch)
53100 + struct xpc_msg *msg = ch->local_msgqueue;
53101 + s64 w_remote_GP_get = ch->w_remote_GP.get % ch->local_nentries;
53102 + s64 remote_GP_get = ch->remote_GP.get % ch->local_nentries;
53103 + s64 local_GP_put = ch->local_GP->put % ch->local_nentries;
53104 + s64 w_local_GP_put = ch->w_local_GP.put % ch->local_nentries;
53107 + kdb_printf("local message queue (0x%p):\n\n", (void *) msg);
53109 + for (i = 0; i < ch->local_nentries; i++) {
53110 + kdb_printf("0x%p: flags=0x%x number=%ld", (void *) msg,
53111 + msg->flags, msg->number);
53115 + if (i == w_remote_GP_get) {
53116 + kdb_printf("%s w_remote_GP.get", prefix);
53119 + if (i == remote_GP_get) {
53120 + kdb_printf("%s remote_GP.get", prefix);
53123 + if (i == local_GP_put) {
53124 + kdb_printf("%s local_GP->put", prefix);
53127 + if (i == w_local_GP_put) {
53128 + kdb_printf("%s w_local_GP.put", prefix);
53130 + kdb_printf("\n");
53132 + msg = (struct xpc_msg *) ((u64) msg + ch->msg_size);
53138 +kdbm_xpc_print_remote_msgqueue(struct xpc_channel *ch)
53142 + struct xpc_msg *msg = ch->remote_msgqueue;
53143 + s64 local_GP_get = ch->local_GP->get % ch->remote_nentries;
53144 + s64 w_local_GP_get = ch->w_local_GP.get % ch->remote_nentries;
53145 + s64 next_msg_to_pull = ch->next_msg_to_pull % ch->remote_nentries;
53146 + s64 w_remote_GP_put = ch->w_remote_GP.put % ch->remote_nentries;
53147 + s64 remote_GP_put = ch->remote_GP.put % ch->remote_nentries;
53150 + kdb_printf("cached remote message queue (0x%p):\n\n", (void *) msg);
53152 + for (i = 0; i < ch->remote_nentries; i++) {
53153 + kdb_printf("0x%p: flags=0x%x number=%ld", (void *) msg,
53154 + msg->flags, msg->number);
53158 + if (i == local_GP_get) {
53159 + kdb_printf("%s local_GP->get", prefix);
53162 + if (i == w_local_GP_get) {
53163 + kdb_printf("%s w_local_GP.get", prefix);
53166 + if (i == next_msg_to_pull) {
53167 + kdb_printf("%s next_msg_to_pull", prefix);
53170 + if (i == w_remote_GP_put) {
53171 + kdb_printf("%s w_remote_GP.put", prefix);
53174 + if (i == remote_GP_put) {
53175 + kdb_printf("%s remote_GP.put", prefix);
53177 + kdb_printf("\n");
53179 + msg = (struct xpc_msg *) ((u64) msg + ch->msg_size);
53185 + * Display XPC specified message queue.
53187 + * xpcmque <partid> <channel> local|remote
53190 +kdbm_xpc_msgqueue(int argc, const char **argv)
53192 + int ret, ch_number;
53193 + unsigned long ulong_partid;
53195 + struct xpc_partition *part;
53196 + struct xpc_channel *ch;
53200 + return KDB_ARGCOUNT;
53203 + ret = kdbgetularg(argv[1], (unsigned long *) &ulong_partid);
53207 + partid = (partid_t) ulong_partid;
53208 + if (partid <= 0 || partid >= XP_MAX_PARTITIONS) {
53209 + kdb_printf("invalid partid\n");
53210 + return KDB_BADINT;
53213 + ret = kdbgetularg(argv[2], (unsigned long *) &ch_number);
53217 + if (ch_number < 0 || ch_number >= XPC_NCHANNELS) {
53218 + kdb_printf("invalid channel #\n");
53219 + return KDB_BADINT;
53222 + part = &xpc_partitions[partid];
53224 + if (part->setup_state == XPC_P_UNSET) {
53225 + kdb_printf("partition is UNSET\n");
53228 + if (part->setup_state == XPC_P_TORNDOWN) {
53229 + kdb_printf("partition is TORNDOWN\n");
53233 + if (ch_number >= part->nchannels) {
53234 + kdb_printf("unsupported channel #\n");
53235 + return KDB_BADINT;
53238 + ch = &part->channels[ch_number];
53240 + if (!(ch->flags & XPC_C_SETUP)) {
53241 + kdb_printf("message queues are not SETUP\n");
53245 + if (strcmp(argv[3], "r") == 0 || strcmp(argv[3], "remote") == 0) {
53246 + kdbm_xpc_print_remote_msgqueue(ch);
53247 + } else if (strcmp(argv[3], "l") == 0 || strcmp(argv[3], "local") == 0) {
53248 + kdbm_xpc_print_local_msgqueue(ch);
53250 + kdb_printf("unknown msg queue selected\n");
53251 + return KDB_BADINT;
53259 +kdbm_xpc_print_msg_flags(u8 flags)
53261 + kdb_printf("\tflags=0x%x", flags);
53263 + if (flags & XPC_M_INTERRUPT) kdb_printf(" INTERRUPT");
53264 + if (flags & XPC_M_READY) kdb_printf(" READY");
53265 + if (flags & XPC_M_DONE) kdb_printf(" DONE");
53267 + kdb_printf("\n");
53272 + * Display XPC message.
53277 +kdbm_xpc_msg(int argc, const char **argv)
53279 + int ret, nextarg = argc;
53281 + unsigned long addr;
53282 + struct xpc_msg *msg;
53286 + return KDB_ARGCOUNT;
53289 + ret = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
53294 + msg = (struct xpc_msg *) addr;
53295 + kdb_printf("msg (0x%p):\n", (void *) msg);
53296 + kdbm_xpc_print_msg_flags(msg->flags);
53297 + kdb_printf("\tnumber=%ld\n", msg->number);
53298 + kdb_printf("\t&payload=0x%p\n", (void *) &msg->payload);
53305 +kdbm_xpc_print_notify_queue(struct xpc_channel *ch)
53309 + struct xpc_notify *notify = ch->notify_queue;
53310 + s64 w_remote_GP_get = ch->w_remote_GP.get % ch->local_nentries;
53311 + s64 remote_GP_get = ch->remote_GP.get % ch->local_nentries;
53312 + s64 local_GP_put = ch->local_GP->put % ch->local_nentries;
53313 + s64 w_local_GP_put = ch->w_local_GP.put % ch->local_nentries;
53316 + kdb_printf("notify queue (0x%p):\n\n", (void *) notify);
53318 + for (i = 0; i < ch->local_nentries; i++) {
53319 + kdb_printf("0x%p: type=0x%x", (void *) notify, notify->type);
53321 + if (notify->type == XPC_N_CALL) {
53322 + kdb_printf(" CALL func=0x%p key=0x%p",
53323 + (void *) notify->func, notify->key);
53328 + if (i == w_remote_GP_get) {
53329 + kdb_printf("%s w_remote_GP.get", prefix);
53332 + if (i == remote_GP_get) {
53333 + kdb_printf("%s remote_GP.get", prefix);
53336 + if (i == local_GP_put) {
53337 + kdb_printf("%s local_GP->put", prefix);
53340 + if (i == w_local_GP_put) {
53341 + kdb_printf("%s w_local_GP.put", prefix);
53343 + kdb_printf("\n");
53351 + * Display XPC specified notify queue.
53353 + * xpcnque <partid> <channel>
53356 +kdbm_xpc_notify_queue(int argc, const char **argv)
53358 + int ret, ch_number;
53359 + unsigned long ulong_partid;
53361 + struct xpc_partition *part;
53362 + struct xpc_channel *ch;
53366 + return KDB_ARGCOUNT;
53369 + ret = kdbgetularg(argv[1], (unsigned long *) &ulong_partid);
53373 + partid = (partid_t) ulong_partid;
53374 + if (partid <= 0 || partid >= XP_MAX_PARTITIONS) {
53375 + kdb_printf("invalid partid\n");
53376 + return KDB_BADINT;
53379 + ret = kdbgetularg(argv[2], (unsigned long *) &ch_number);
53383 + if (ch_number < 0 || ch_number >= XPC_NCHANNELS) {
53384 + kdb_printf("invalid channel #\n");
53385 + return KDB_BADINT;
53388 + part = &xpc_partitions[partid];
53390 + if (part->setup_state == XPC_P_UNSET) {
53391 + kdb_printf("partition is UNSET\n");
53394 + if (part->setup_state == XPC_P_TORNDOWN) {
53395 + kdb_printf("partition is TORNDOWN\n");
53399 + if (ch_number >= part->nchannels) {
53400 + kdb_printf("unsupported channel #\n");
53401 + return KDB_BADINT;
53404 + ch = &part->channels[ch_number];
53406 + if (!(ch->flags & XPC_C_SETUP)) {
53407 + kdb_printf("notify queue is not SETUP\n");
53411 + kdbm_xpc_print_notify_queue(ch);
53418 +kdbm_xpc_print_users(struct xpc_registration *registration, int ch_number)
53420 + kdb_printf("xpc_registrations[channel=%d] (0x%p):\n", ch_number,
53421 + (void *) registration);
53423 + kdb_printf("\t&mutex=0x%p\n", (void *) ®istration->mutex);
53424 + kdb_printf("\tfunc=0x%p\n", (void *) registration->func);
53425 + kdb_printf("\tkey=0x%p\n", registration->key);
53426 + kdb_printf("\tnentries=%d\n", registration->nentries);
53427 + kdb_printf("\tmsg_size=%d\n", registration->msg_size);
53428 + kdb_printf("\tassigned_limit=%d\n", registration->assigned_limit);
53429 + kdb_printf("\tidle_limit=%d\n", registration->idle_limit);
53434 + * Display current XPC users who have registered via xpc_connect().
53436 + * xpcusers [ <channel> ]
53439 +kdbm_xpc_users(int argc, const char **argv)
53442 + struct xpc_registration *registration;
53447 + return KDB_ARGCOUNT;
53449 + } else if (argc == 1) {
53450 + ret = kdbgetularg(argv[1], (unsigned long *) &ch_number);
53454 + if (ch_number < 0 || ch_number >= XPC_NCHANNELS) {
53455 + kdb_printf("invalid channel #\n");
53456 + return KDB_BADINT;
53458 + registration = &xpc_registrations[ch_number];
53459 + kdbm_xpc_print_users(registration, ch_number);
53462 + for (ch_number = 0; ch_number < XPC_NCHANNELS; ch_number++) {
53463 + registration = &xpc_registrations[ch_number];
53465 + /* if !XPC_CHANNEL_REGISTERED(ch_number) */
53466 + if (registration->func == NULL) {
53469 + kdbm_xpc_print_users(registration, ch_number);
53477 +kdbm_xpc_register(void)
53479 + (void) kdb_register("xpcdown", kdbm_xpc_down, "",
53480 + "Mark this partition as being down", 0);
53481 + (void) kdb_register("xpcrp", kdbm_xpc_rsvd_page, "",
53482 + "Display XPC reserved page", 0);
53483 + (void) kdb_register("xpcvars", kdbm_xpc_variables, "[<partid>]",
53484 + "Display XPC variables", 0);
53485 + (void) kdb_register("xpcengaged", kdbm_xpc_engaged, "[-v]",
53486 + "Display XPC engaged partitions AMOs", 0);
53487 + (void) kdb_register("xpcpart", kdbm_xpc_partitions, "[<vaddr>|"
53488 + "<partid>]", "Display struct xpc_partition entries", 0);
53489 + (void) kdb_register("xpcchan", kdbm_xpc_channels, "<vaddr> | <partid> "
53490 + "[<channel>]", "Display struct xpc_channel entries", 0);
53491 + (void) kdb_register("xpcmque", kdbm_xpc_msgqueue, "<partid> <channel> "
53492 + "local|remote", "Display local or remote msg queue", 0);
53493 + (void) kdb_register("xpcmsg", kdbm_xpc_msg, "<vaddr>",
53494 + "Display struct xpc_msg", 0);
53495 + (void) kdb_register("xpcnque", kdbm_xpc_notify_queue, "<partid> "
53496 + "<channel>", "Display notify queue", 0);
53497 + (void) kdb_register("xpcusers", kdbm_xpc_users, "[ <channel> ]",
53498 + "Display struct xpc_registration entries", 0);
53503 +static void __exit
53504 +kdbm_xpc_unregister(void)
53506 + (void) kdb_unregister("xpcdown");
53507 + (void) kdb_unregister("xpcrp");
53508 + (void) kdb_unregister("xpcvars");
53509 + (void) kdb_unregister("xpcengaged");
53510 + (void) kdb_unregister("xpcpart");
53511 + (void) kdb_unregister("xpcchan");
53512 + (void) kdb_unregister("xpcmque");
53513 + (void) kdb_unregister("xpcmsg");
53514 + (void) kdb_unregister("xpcnque");
53515 + (void) kdb_unregister("xpcusers");
53519 +module_init(kdbm_xpc_register);
53520 +module_exit(kdbm_xpc_unregister);
53522 diff -Nurp linux-2.6.22-590/kdb/modules/Makefile linux-2.6.22-600/kdb/modules/Makefile
53523 --- linux-2.6.22-590/kdb/modules/Makefile 1970-01-01 01:00:00.000000000 +0100
53524 +++ linux-2.6.22-600/kdb/modules/Makefile 2008-04-09 18:14:28.000000000 +0200
53527 +# This file is subject to the terms and conditions of the GNU General Public
53528 +# License. See the file "COPYING" in the main directory of this archive
53529 +# for more details.
53531 +# Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
53534 +obj-$(CONFIG_KDB_MODULES) += kdbm_pg.o kdbm_task.o kdbm_vm.o kdbm_sched.o
53536 +obj-$(CONFIG_KDB_MODULES) += kdbm_x86.o
53538 +obj-$(CONFIG_KDB_MODULES_XP) += kdbm_xpc.o
53539 +CFLAGS_kdbm_vm.o += -I $(srctree)/drivers/scsi
53540 diff -Nurp linux-2.6.22-590/kernel/exit.c linux-2.6.22-600/kernel/exit.c
53541 --- linux-2.6.22-590/kernel/exit.c 2008-04-09 18:10:53.000000000 +0200
53542 +++ linux-2.6.22-600/kernel/exit.c 2008-04-09 18:14:28.000000000 +0200
53544 * Copyright (C) 1991, 1992 Linus Torvalds
53548 +#include <linux/kdb.h>
53550 #include <linux/mm.h>
53551 #include <linux/slab.h>
53552 #include <linux/interrupt.h>
53553 diff -Nurp linux-2.6.22-590/kernel/kallsyms.c linux-2.6.22-600/kernel/kallsyms.c
53554 --- linux-2.6.22-590/kernel/kallsyms.c 2007-07-09 01:32:17.000000000 +0200
53555 +++ linux-2.6.22-600/kernel/kallsyms.c 2008-04-09 18:14:28.000000000 +0200
53556 @@ -491,3 +491,25 @@ __initcall(kallsyms_init);
53558 EXPORT_SYMBOL(__print_symbol);
53559 EXPORT_SYMBOL_GPL(sprint_symbol);
53562 +#include <linux/kdb.h>
53563 +#include <linux/kdbprivate.h>
53565 +const char *kdb_walk_kallsyms(loff_t *pos)
53567 + static struct kallsym_iter kdb_walk_kallsyms_iter;
53569 + memset(&kdb_walk_kallsyms_iter, 0, sizeof(kdb_walk_kallsyms_iter));
53570 + reset_iter(&kdb_walk_kallsyms_iter, 0);
53573 + if (!update_iter(&kdb_walk_kallsyms_iter, *pos))
53576 + /* Some debugging symbols have no name. Ignore them. */
53577 + if (kdb_walk_kallsyms_iter.name[0])
53578 + return kdb_walk_kallsyms_iter.name;
53581 +#endif /* CONFIG_KDB */
53582 diff -Nurp linux-2.6.22-590/kernel/module.c linux-2.6.22-600/kernel/module.c
53583 --- linux-2.6.22-590/kernel/module.c 2007-07-09 01:32:17.000000000 +0200
53584 +++ linux-2.6.22-600/kernel/module.c 2008-04-09 18:14:28.000000000 +0200
53585 @@ -2176,12 +2176,23 @@ out:
53590 +#include <linux/kdb.h>
53591 +struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */
53592 +#endif /* CONFIG_KDB */
53594 int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
53595 char *name, char *module_name, int *exported)
53597 struct module *mod;
53599 + int get_lock = !KDB_IS_RUNNING();
53601 +#define get_lock 1
53604 - mutex_lock(&module_mutex);
53606 + mutex_lock(&module_mutex);
53607 list_for_each_entry(mod, &modules, list) {
53608 if (symnum < mod->num_symtab) {
53609 *value = mod->symtab[symnum].st_value;
53610 @@ -2190,12 +2201,14 @@ int module_get_kallsym(unsigned int symn
53611 KSYM_NAME_LEN + 1);
53612 strlcpy(module_name, mod->name, MODULE_NAME_LEN + 1);
53613 *exported = is_exported(name, mod);
53614 - mutex_unlock(&module_mutex);
53616 + mutex_unlock(&module_mutex);
53619 symnum -= mod->num_symtab;
53621 - mutex_unlock(&module_mutex);
53623 + mutex_unlock(&module_mutex);
53627 diff -Nurp linux-2.6.22-590/kernel/printk.c linux-2.6.22-600/kernel/printk.c
53628 --- linux-2.6.22-590/kernel/printk.c 2008-04-09 18:10:53.000000000 +0200
53629 +++ linux-2.6.22-600/kernel/printk.c 2008-04-09 18:14:28.000000000 +0200
53630 @@ -313,6 +313,20 @@ asmlinkage long sys_syslog(int type, cha
53631 return do_syslog(type, buf, len);
53635 +/* kdb dmesg command needs access to the syslog buffer. do_syslog() uses locks
53636 + * so it cannot be used during debugging. Just tell kdb where the start and
53637 + * end of the physical and logical logs are. This is equivalent to do_syslog(3).
53639 +void kdb_syslog_data(char *syslog_data[4])
53641 + syslog_data[0] = log_buf;
53642 + syslog_data[1] = log_buf + log_buf_len;
53643 + syslog_data[2] = log_buf + log_end - (logged_chars < log_buf_len ? logged_chars : log_buf_len);
53644 + syslog_data[3] = log_buf + log_end;
53646 +#endif /* CONFIG_KDB */
53649 * Call the console drivers on a range of log_buf
53651 diff -Nurp linux-2.6.22-590/kernel/sched.c linux-2.6.22-600/kernel/sched.c
53652 --- linux-2.6.22-590/kernel/sched.c 2008-04-09 18:11:16.000000000 +0200
53653 +++ linux-2.6.22-600/kernel/sched.c 2008-04-09 18:14:28.000000000 +0200
53654 @@ -7315,7 +7315,7 @@ void normalize_rt_tasks(void)
53656 #endif /* CONFIG_MAGIC_SYSRQ */
53658 -#ifdef CONFIG_IA64
53659 +#if defined(CONFIG_IA64) || defined(CONFIG_KDB)
53661 * These functions are only useful for the IA64 MCA handling.
53663 @@ -7364,3 +7364,80 @@ void (*rec_event)(void *,unsigned int);
53664 EXPORT_SYMBOL(rec_event);
53665 EXPORT_SYMBOL(in_sched_functions);
53670 +#include <linux/kdb.h>
53673 +kdb_prio(char *name, struct prio_array *array, kdb_printf_t xxx_printf)
53677 + xxx_printf(" %s nr_active:%d bitmap: 0x%lx 0x%lx 0x%lx\n",
53678 + name, array->nr_active,
53679 + array->bitmap[0], array->bitmap[1], array->bitmap[2]);
53681 + pri = sched_find_first_bit(array->bitmap);
53682 + if (pri != MAX_PRIO) {
53683 + xxx_printf(" bitmap priorities:");
53684 + while (pri != MAX_PRIO) {
53685 + xxx_printf(" %d", pri);
53687 + pri = find_next_bit(array->bitmap, MAX_PRIO, pri);
53689 + xxx_printf("\n");
53692 + for (pri = 0; pri < MAX_PRIO; pri++) {
53693 + int printed_hdr = 0;
53694 + struct list_head *head, *curr;
53696 + head = array->queue + pri;
53697 + curr = head->next;
53698 + while(curr != head) {
53699 + struct task_struct *task;
53700 + if (!printed_hdr) {
53701 + xxx_printf(" queue at priority=%d\n", pri);
53704 + task = list_entry(curr, struct task_struct, run_list);
53705 + xxx_printf(" 0x%p %d %s time_slice:%d\n",
53706 + task, task->pid, task->comm,
53707 + task->time_slice);
53708 + curr = curr->next;
53713 +/* This code must be in sched.c because struct rq is only defined in this
53714 + * source. To allow most of kdb to be modular, this code cannot call any kdb
53715 + * functions directly, any external functions that it needs must be passed in
53720 +kdb_runqueue(unsigned long cpu, kdb_printf_t xxx_printf)
53724 + rq = cpu_rq(cpu);
53726 + xxx_printf("CPU%ld lock:%s curr:0x%p(%d)(%s)",
53727 + cpu, (spin_is_locked(&rq->lock))?"LOCKED":"free",
53728 + rq->curr, rq->curr->pid, rq->curr->comm);
53729 + if (rq->curr == rq->idle)
53730 + xxx_printf(" is idle");
53731 + xxx_printf("\n ");
53733 + xxx_printf(" cpu_load:%lu %lu %lu",
53734 + rq->cpu_load[0], rq->cpu_load[1], rq->cpu_load[2]);
53736 + xxx_printf(" nr_running:%lu nr_switches:%llu\n",
53737 + rq->nr_running, rq->nr_switches);
53738 + kdb_prio("active", rq->active, xxx_printf);
53739 + kdb_prio("expired", rq->expired, xxx_printf);
53741 +EXPORT_SYMBOL(kdb_runqueue);
53743 +#endif /* CONFIG_KDB */
53744 diff -Nurp linux-2.6.22-590/kernel/signal.c linux-2.6.22-600/kernel/signal.c
53745 --- linux-2.6.22-590/kernel/signal.c 2008-04-09 18:10:53.000000000 +0200
53746 +++ linux-2.6.22-600/kernel/signal.c 2008-04-09 18:14:28.000000000 +0200
53747 @@ -2586,3 +2586,52 @@ void __init signals_init(void)
53749 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
53753 +#include <linux/kdb.h>
53755 + * kdb_send_sig_info
53757 + * Allows kdb to send signals without exposing signal internals.
53761 + * siginfo signal information
53762 + * seqno current kdb sequence number (avoid including kdbprivate.h)
53768 + * Checks if the required locks are available before calling the main
53769 + * signal code, to avoid kdb deadlocks.
53773 +kdb_send_sig_info(struct task_struct *t, struct siginfo *info, int seqno)
53775 + static struct task_struct *kdb_prev_t;
53776 + static int kdb_prev_seqno;
53778 + if (!spin_trylock(&t->sighand->siglock)) {
53779 + kdb_printf("Can't do kill command now.\n"
53780 + "The sigmask lock is held somewhere else in kernel, try again later\n");
53783 + spin_unlock(&t->sighand->siglock);
53784 + new_t = kdb_prev_t != t || kdb_prev_seqno != seqno;
53786 + kdb_prev_seqno = seqno;
53787 + if (t->state != TASK_RUNNING && new_t) {
53788 + kdb_printf("Process is not RUNNING, sending a signal from kdb risks deadlock\n"
53789 + "on the run queue locks. The signal has _not_ been sent.\n"
53790 + "Reissue the kill command if you want to risk the deadlock.\n");
53793 + sig = info->si_signo;
53794 + if (send_sig_info(sig, info, t))
53795 + kdb_printf("Fail to deliver Signal %d to process %d.\n", sig, t->pid);
53797 + kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid);
53799 +#endif /* CONFIG_KDB */
53800 diff -Nurp linux-2.6.22-590/Makefile linux-2.6.22-600/Makefile
53801 --- linux-2.6.22-590/Makefile 2008-04-09 18:11:17.000000000 +0200
53802 +++ linux-2.6.22-600/Makefile 2008-04-09 18:14:28.000000000 +0200
53803 @@ -560,6 +560,7 @@ export mod_strip_cmd
53805 ifeq ($(KBUILD_EXTMOD),)
53806 core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
53807 +core-$(CONFIG_KDB) += kdb/
53809 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
53810 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
53811 diff -Nurp linux-2.6.22-590/mm/hugetlb.c linux-2.6.22-600/mm/hugetlb.c
53812 --- linux-2.6.22-590/mm/hugetlb.c 2008-04-09 18:10:53.000000000 +0200
53813 +++ linux-2.6.22-600/mm/hugetlb.c 2008-04-09 18:14:28.000000000 +0200
53814 @@ -266,6 +266,25 @@ int hugetlb_sysctl_handler(struct ctl_ta
53816 #endif /* CONFIG_SYSCTL */
53819 +#include <linux/kdb.h>
53820 +#include <linux/kdbprivate.h>
53821 +/* Like hugetlb_report_meminfo() but using kdb_printf() */
53823 +kdb_hugetlb_report_meminfo(void)
53826 + "HugePages_Total: %5lu\n"
53827 + "HugePages_Free: %5lu\n"
53828 + "HugePages_Rsvd: %5lu\n"
53829 + "Hugepagesize: %5lu kB\n",
53833 + HPAGE_SIZE/1024);
53835 +#endif /* CONFIG_KDB */
53837 int hugetlb_report_meminfo(char *buf)
53839 return sprintf(buf,
53840 diff -Nurp linux-2.6.22-590/mm/swapfile.c linux-2.6.22-600/mm/swapfile.c
53841 --- linux-2.6.22-590/mm/swapfile.c 2008-04-09 18:10:53.000000000 +0200
53842 +++ linux-2.6.22-600/mm/swapfile.c 2008-04-09 18:14:28.000000000 +0200
53844 #include <linux/swap.h>
53845 #include <linux/vmalloc.h>
53846 #include <linux/pagemap.h>
53848 +#include <linux/kdb.h>
53849 +#include <linux/kdbprivate.h>
53850 +#endif /* CONFIG_KDB */
53851 #include <linux/namei.h>
53852 #include <linux/shm.h>
53853 #include <linux/blkdev.h>
53854 @@ -1718,6 +1722,24 @@ void si_swapinfo(struct sysinfo *val)
53855 vx_vsi_swapinfo(val);
53859 +/* Like si_swapinfo() but without the locks */
53860 +void kdb_si_swapinfo(struct sysinfo *val)
53863 + unsigned long nr_to_be_unused = 0;
53865 + for (i = 0; i < nr_swapfiles; i++) {
53866 + if (!(swap_info[i].flags & SWP_USED) ||
53867 + (swap_info[i].flags & SWP_WRITEOK))
53869 + nr_to_be_unused += swap_info[i].inuse_pages;
53871 + val->freeswap = nr_swap_pages + nr_to_be_unused;
53872 + val->totalswap = total_swap_pages + nr_to_be_unused;
53874 +#endif /* CONFIG_KDB */
53877 * Verify that a swap entry is valid and increment its swap map count.