I want to know the PC(program counter) during Linux kernel booting. But I have no idea of printing PC. Should I use assembler code ? Please make me get the idea of using c-code..
- posted
19 years ago
I want to know the PC(program counter) during Linux kernel booting. But I have no idea of printing PC. Should I use assembler code ? Please make me get the idea of using c-code..
El dia del senyor de Dimarts 14 Setembre 2004 08:01, al grup de news comp.os.linux.embedded, en JoohyeonPark va escriure:
Alternative 1: use a pc emulator such as bochs / embedded machine emulator from your developement machine.
Alternative 2: exec the kernel from within gdb
Alternative 3: write a wrapper around the boot process, depending on your environement.
For x86 systems, you can install interrupt handler 3, then proceed in single step each instruction. The ISR (interrupt service routine) can give you the PC (with any other registrer you want). To get the PC, grab it from the stack.
For other systems, you may need to find a suitable interrupt (check the processor databook to check if there's a single step interrupt / instruction ) and do the same.
If there isn't such instruction / operation mode, you can use a NMI/INT, using the NMI/INT ISR as main control for the debugger, and letting just the computer to execute one instruction before the next interrupt (usually by leaving the interrupt pin aserted continually).
Ideally, you should do remote debugging using an unused communications port, because if you insert printk/printf commands in the ISR you could be tampering with the machine hardware status that the kernel expects.
Beware of unsuspected side effects, such as timing problems with drivers, and so on.
-- -------------------- Albert Gonzalez
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.