I get a lot of questions in my private email. I much prefer if people use the forum, however. This is an *open* source project. Not only should the source code be open, but so should all discussions relating to it.
Here is one that got this morning. I repost the reply here because other people might have the same question:
> i successfully run hello nxflat module on sdcard through nsh command
> line in kernel mode,but i do not know how to debug it by use gdb.
> currently, i use jlink gdb server + gdb client + ddd graphic client to
> debug nuttx kernel and nuttx_user.elf also include some builtin
> modules, but these experiences can not help me to do it. ...
I think this should work the same as with the old uClinux systems or
with debugging kernel modules under linux. See for example:
This is how I used to do things with uClinux programs about 12 years ago:
1. Build the module with debug enabled.
2. You have to know where the program was loaded in memory. You can do this with debug output or with a printf() in your application or with GDB.
3. You have to know the offset of the text section inside of the module. Use 'readelf -S' or 'readnxflat' to find that offset.
4. Then you have to get control of the CPU: Either halt the CPU with your application running or put a breakpoint in NuttX before your application has started (if you want to single ste
p into main). I have put infinite loop in code to in order to stop them until I have a chance to break in.
Use the text section offset to calculate the load address of the module text section.
5. The you run GDB:
- Start GDB
- Connect to the GDB server. You should be able to use the J-Link GDB server
- Load the symbol file. Here is the only trick. Since the code was relocated into memory, the addresses in the symbol will all be wrong by an offset. Fortunately, the GDB symbol-file command accepts a text address argument:
gdb> add-symbol-file nuttx 0xXXXXXXXX
Where 0xXXXXXXXX is the address of the text section in memory.
I have not tried that in years so that procedure might require some updates.
> ... i almost
> remember that the ecos os's gdb stub which built in the flash rom of
> arm cpu together with itself seems to do this.
> do you have a plan to implement a gdb stub or gdb server in nuttx?
No. But that would be a great project if someone wants to contribute it. GPL would be okay in this case.
Posted by: spudarnia-/E1597aS9LQAvxtiuMwx3w@public.gmane.org