Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Hi. During my OS design I encountered a problem with GDB remote debugging. When I try to continue execution of stopped kernel after remote connection to it (either by next, step, continue or any other command) the GDB tries to set breakpoint on the image entry point. The problem is that my OS image is loaded at low physical addresses (probably the most OS'es do that) and after that is remapped on highest virtual addresses. After the paging is enabled the temporal identity mapping in the lowest virtual addresses is invalidated and the original entry point becomes inaccessible. So the GDB cannot debug the kernel when I use Qemu built-in debugger:
0x200000 - is my OS loading address and entry point address.
For the OS-builtin debugger I use temporal workaround: when someone tries to read or write from boot-code range I translate these addresses to higher memory where the boot-code also is accessible. This works but in some cases I'm not able to use my built-in debugger (e.g. when the debugger itself needs to be debugged) and I need to use Qemu debugger. Probably GDB could have some option to not insert this breakpoint which still is not used. I searched for a such option but nothing found. May be somebody had similar problem and knows the solution? Thanks in advance.
Hi,
I have successfully solved the problem. I will describe the solution for the case someone will have such problem. Firstly, I have not found any way to tell GDB to not create breakpoint on program entry point. So I just made him think that my entry point is located at relocated high addresses. All I needed was just slightly modify linker script and entry point code. Here is a fragment of my linker script:
LOAD_ADDRESS - is low physical loading address and KERNEL_ADDRESS is high virtual relocation address which are defined in makefile. start.o file is produced from start.S file which contains in its text section just several instructions to jump in C++ initialization code: