Is there a way for a program to know if it's executed under the simulator and not on an actual CPU?
Save yourself lots of grief and continued nonsense responses. Invest in a ulink.
Invest in a ulink.
For those who don't read: "I cannot use any of the debug adapters due to the specifics of our device".
You have never told us what that specifics are.
Neither have you told us exactly what peripherial simulation you are missing.
But anyway - you haven't given one single reason why it would be a problem to program a specific memory cell by the debugger script - the script that is unique in that it is only used when you debug your code. Of course with the disadvantage that you then release a real program with mirror functionality that gets activated by the state of that memory cell potentially making havoc of a real, live, installation.
By the way - the normal setup is that you don't need to do anything extra to get the tools to recompile your code when you switch target and wants to start debugging. So it's a minimum number of steps to switch target and then have a go at debugging.
... you haven't given one single reason why it would be a problem to program a specific memory cell by the debugger script ...
Well, because it wouldn't be a problem! It's sad if you have the impression that I'm rejecting this method out of hand. Actually, this is a good method, arguably better than mine. I just need some time to think which one I'll be using...