If you are an Windows, and using FpDebug in Lazarus you want to use -gw3
If you use gdb for some reason, you likely want -gw2 -godwarfsets (though some versions of gdb may be ok with -gw3 especially if you use fpc fixes or trunk)
If you are on Linux, the same applies. However, if you use -gw3 you may be forced to use this for all/any package and project that has debug info, otherwise you may get linker errors, when building your project. Equally on Linux if you use -gw2 then you may need to use that every where else. Actually the dependency exists in one direction only, and I am not sure which one. (Using just -g is translated by the compiler to either -gw2 or -gw3 / depends...).
Also, write and writeln are compiler intrinsics. They aren't functions You can't step into them, but you will be able to step into some of the functions from which the compiler builds them. However, what you actually want to step in is the "format" function. And that will work.