arch/mips/kernel/kgdb.c
Source file repositories/reference/linux-study-clean/arch/mips/kernel/kgdb.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/kernel/kgdb.c- Extension
.c- Size
- 11315 bytes
- Lines
- 395
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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/ptrace.hlinux/kgdb.hlinux/kdebug.hlinux/sched.hlinux/smp.hasm/inst.hasm/fpu.hasm/cacheflush.hasm/processor.hasm/sigcontext.hasm/irq_regs.h
Detected Declarations
function dbg_set_regfunction arch_kgdb_breakpointfunction compute_signalfunction regs_to_gdb_regsfunction kgdb_arch_set_pcfunction kgdb_mips_notifyfunction kgdb_ll_trapfunction kgdb_arch_handle_exceptionfunction kgdb_arch_initfunction kgdb_arch_exit
Annotated Snippet
if (regno == 70) {
/* Process the fcr31/fsr (register 70) */
memcpy((void *)¤t->thread.fpu.fcr31, mem,
dbg_reg_def[regno].size);
goto out_save;
} else if (regno == 71) {
/* Ignore the fir (register 71) */
goto out_save;
}
fp_reg = dbg_reg_def[regno].offset;
memcpy((void *)¤t->thread.fpu.fpr[fp_reg], mem,
dbg_reg_def[regno].size);
out_save:
restore_fp(current);
}
return 0;
}
char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
{
int fp_reg;
if (regno >= DBG_MAX_REG_NUM || regno < 0)
return NULL;
if (dbg_reg_def[regno].offset != -1 && regno < 38) {
/* First 38 registers */
memcpy(mem, (void *)regs + dbg_reg_def[regno].offset,
dbg_reg_def[regno].size);
} else if (current && dbg_reg_def[regno].offset != -1 && regno < 72) {
/* FP registers 38 -> 69 */
if (!(regs->cp0_status & ST0_CU1))
goto out;
save_fp(current);
if (regno == 70) {
/* Process the fcr31/fsr (register 70) */
memcpy(mem, (void *)¤t->thread.fpu.fcr31,
dbg_reg_def[regno].size);
goto out;
} else if (regno == 71) {
/* Ignore the fir (register 71) */
memset(mem, 0, dbg_reg_def[regno].size);
goto out;
}
fp_reg = dbg_reg_def[regno].offset;
memcpy(mem, (void *)¤t->thread.fpu.fpr[fp_reg],
dbg_reg_def[regno].size);
}
out:
return dbg_reg_def[regno].name;
}
void arch_kgdb_breakpoint(void)
{
__asm__ __volatile__(
".globl breakinst\n\t"
".set\tnoreorder\n\t"
"nop\n"
"breakinst:\tbreak\n\t"
"nop\n\t"
".set\treorder");
}
static int compute_signal(int tt)
{
struct hard_trap_info *ht;
for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
if (ht->tt == tt)
return ht->signo;
return SIGHUP; /* default for things we don't know about */
}
/*
* Similar to regs_to_gdb_regs() except that process is sleeping and so
* we may not be able to get all the info.
*/
void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
{
int reg;
#if (KGDB_GDB_REG_SIZE == 32)
u32 *ptr = (u32 *)gdb_regs;
#else
u64 *ptr = (u64 *)gdb_regs;
#endif
Annotation
- Immediate include surface: `linux/ptrace.h`, `linux/kgdb.h`, `linux/kdebug.h`, `linux/sched.h`, `linux/smp.h`, `asm/inst.h`, `asm/fpu.h`, `asm/cacheflush.h`.
- Detected declarations: `function dbg_set_reg`, `function arch_kgdb_breakpoint`, `function compute_signal`, `function regs_to_gdb_regs`, `function kgdb_arch_set_pc`, `function kgdb_mips_notify`, `function kgdb_ll_trap`, `function kgdb_arch_handle_exception`, `function kgdb_arch_init`, `function kgdb_arch_exit`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.