arch/powerpc/kernel/kgdb.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kernel/kgdb.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kernel/kgdb.c- Extension
.c- Size
- 14836 bytes
- Lines
- 496
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/kgdb.hlinux/smp.hlinux/signal.hlinux/ptrace.hlinux/kdebug.hasm/current.hasm/processor.hasm/machdep.hasm/debug.hasm/text-patching.hlinux/slab.hasm/inst.h
Detected Declarations
function computeSignalfunction kgdb_skipexceptionfunction kgdb_debugger_ipifunction kgdb_roundup_cpusfunction kgdb_debuggerfunction kgdb_handle_breakpointfunction kgdb_singlestepfunction kgdb_iabr_matchfunction kgdb_break_matchfunction sleeping_thread_to_gdb_regsfunction dbg_set_regfunction kgdb_arch_set_pcfunction kgdb_arch_handle_exceptionfunction kgdb_arch_set_breakpointfunction kgdb_arch_remove_breakpointfunction kgdb_not_implementedfunction kgdb_arch_initfunction kgdb_arch_exit
Annotated Snippet
if (remcom_in_buffer[0] == 's') {
#ifdef CONFIG_PPC_ADV_DEBUG_REGS
mtspr(SPRN_DBCR0,
mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
regs_set_return_msr(linux_regs, linux_regs->msr | MSR_DE);
#else
regs_set_return_msr(linux_regs, linux_regs->msr | MSR_SE);
#endif
atomic_set(&kgdb_cpu_doing_single_step,
raw_smp_processor_id());
}
return 0;
}
return -1;
}
int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
{
u32 instr, *addr = (u32 *)bpt->bpt_addr;
int err;
err = get_kernel_nofault(instr, addr);
if (err)
return err;
err = patch_instruction(addr, ppc_inst(BREAK_INSTR));
if (err)
return -EFAULT;
*(u32 *)bpt->saved_instr = instr;
return 0;
}
int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
{
int err;
unsigned int instr = *(unsigned int *)bpt->saved_instr;
u32 *addr = (u32 *)bpt->bpt_addr;
err = patch_instruction(addr, ppc_inst(instr));
if (err)
return -EFAULT;
return 0;
}
/*
* Global data
*/
const struct kgdb_arch arch_kgdb_ops;
static int kgdb_not_implemented(struct pt_regs *regs)
{
return 0;
}
static void *old__debugger_ipi;
static void *old__debugger;
static void *old__debugger_bpt;
static void *old__debugger_sstep;
static void *old__debugger_iabr_match;
static void *old__debugger_break_match;
static void *old__debugger_fault_handler;
int kgdb_arch_init(void)
{
old__debugger_ipi = __debugger_ipi;
old__debugger = __debugger;
old__debugger_bpt = __debugger_bpt;
old__debugger_sstep = __debugger_sstep;
old__debugger_iabr_match = __debugger_iabr_match;
old__debugger_break_match = __debugger_break_match;
old__debugger_fault_handler = __debugger_fault_handler;
__debugger_ipi = kgdb_debugger_ipi;
__debugger = kgdb_debugger;
__debugger_bpt = kgdb_handle_breakpoint;
__debugger_sstep = kgdb_singlestep;
__debugger_iabr_match = kgdb_iabr_match;
__debugger_break_match = kgdb_break_match;
__debugger_fault_handler = kgdb_not_implemented;
return 0;
}
void kgdb_arch_exit(void)
{
__debugger_ipi = old__debugger_ipi;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kgdb.h`, `linux/smp.h`, `linux/signal.h`, `linux/ptrace.h`, `linux/kdebug.h`, `asm/current.h`, `asm/processor.h`.
- Detected declarations: `function computeSignal`, `function kgdb_skipexception`, `function kgdb_debugger_ipi`, `function kgdb_roundup_cpus`, `function kgdb_debugger`, `function kgdb_handle_breakpoint`, `function kgdb_singlestep`, `function kgdb_iabr_match`, `function kgdb_break_match`, `function sleeping_thread_to_gdb_regs`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.