PMunch/nimcr

New idea: Apply compile/run as debugging mode if spawned by gdb

Opened this issue · 4 comments

0xACE commented

Hey, I just had an idea:

There are times where I debug my code with gdb.

Everytime I do it I have to go and change the compilation flags.

I was considering having nimcr detect if the process was spawned by gdb and have it recompile with -g to ensure debugging information is included in the executable.

What do you think?

0xACE commented

Actually nevermind, I just realised nimcr will get spawned by gdb and not the actual executable (unless some trickery can be done).

If you think it is possible do set it up to my liking let me know.

I'll leave this issue open for at least one day in case any other stragglers have any brilliant ideas.

Feel free to close it if you want to.

What happens in GDB when another process is started with the linux exec? According to the documentation that "replaces the current process image with a new process image" so I'm guessing it would work? If it does then this should be perfectly doable.

0xACE commented

I wrote that idea right before going away, so I didn't think it through.

Yes, the plan was to utilize exec. But then I realised: gdb would need to know where to get the symbol table and I think it is read when gdb loads the program. Since the file gdb is executing isn't the same as the file that will be running the symbols shouldn't be found, unless gdb is capable of reading symbol table of a execed program...

Maybe the appropriate approach would be having a gdb function load *.nim files differently...

I think it boils down to me being premature with the post button, I didn't think this through.

I'll tinker with this, but I'm busy until the middle of june.

Close it if you wish, other than that I'll be thinking / working with this in the background and post my findings at a later point.

Well it is able to run things from dynamic libraries, so it might work for exec as well, bit depending on how exec actually works (haven't really looked into this at all)..