arch/alpha/lib/stacktrace.c

Source file repositories/reference/linux-study-clean/arch/alpha/lib/stacktrace.c

File Facts

System
Linux kernel
Corpus path
arch/alpha/lib/stacktrace.c
Extension
.c
Size
2682 bytes
Lines
104
Domain
Architecture Layer
Bucket
arch/alpha
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (STK_PUSH_MATCH(*pro_pc)) {
			reg = (*pro_pc & MEM_REG) >> 21;
			value = *(unsigned long *)(sp + (*pro_pc & MEM_OFF));
			if (reg == 26)
				ret_pc = (instr *)value;
			printk("\t\t%s / 0x%016lx\n", reg_name[reg], value);
		}
	return ret_pc;
}

static instr *
seek_prologue(instr * pc)
{
	while (!STK_ALLOC_MATCH(*pc))
		--pc;
	while (!BB_END(*(pc - 1)))
		--pc;
	return pc;
}

static long
stack_increment(instr * prologue_pc)
{
	while (!STK_ALLOC_MATCH(*prologue_pc))
		++prologue_pc;

	/* Count the bytes allocated. */
	if ((*prologue_pc & STK_ALLOC_1M) == STK_ALLOC_1M)
		return -(((long)(*prologue_pc) << 48) >> 48);
	else
		return (*prologue_pc >> 13) & 0xff;
}

void
stacktrace(void)
{
	instr * ret_pc;
	instr * prologue = (instr *)stacktrace;
	unsigned char *sp = (unsigned char *)current_stack_pointer;

	printk("\tstack trace:\n");
	do {
		ret_pc = display_stored_regs(prologue, sp);
		sp += stack_increment(prologue);
		prologue = seek_prologue(ret_pc);
	} while (IS_KERNEL_TEXT(ret_pc));
}

Annotation

Implementation Notes