jrtc27 wrote:

> I got on a side track wondering why not all registers are saved in the pcb. 
> From what I've read, some registers are saved in the memory of the process 
> itself, and the rest are in the pcb.

Like setjmp/longjmp, context switching is a call into the cpu_switch function, 
and so only saves the call-preserved registers (with a bit of an asterisk to 
include registers that would normally be constant within a thread but change 
between threads). Call-clobbered registers, if needed by anyone up the call 
stack, will already be saved/restored by the compiler just like setjmp/longjmp, 
so it would be a bug for any code to rely on them being saved in struct pcb by 
cpu_switch. Contrast with struct trapframe, which saves the entire state 
(specifically, the subset that the kernel might clobber; on architectures like 
AArch64 with banked registers the EL0 registers can be left alone and instead 
handled as part of cpu_switch, optimising for the case that a trap does not 
result in context switching to a different thread) as traps can occur at any 
point during execution, not just function call boundaries.

https://github.com/llvm/llvm-project/pull/180669
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to