Question

I recently downloaded MI library and executed / read some examples code. In all the examples that I saw the implementation was via a separate program like below:

Main Program
Interact with GDB
exec another program
Gather  Debug info of the another program

My question is how can we invoke / implement GDB within current thread/program itself i.e. attach this self-execution process.

Était-ce utile?

La solution

how can we invoke / implement GDB MI within current thread/program itself i.e. attach this self-execution/ running process to GDB and then tell it to execute step by step

You can't.

Think about it: the very first thing GDB will do after attaching is stop your program, and wait for instructions on what to do next. At that point your program should send GDB the continue command, except it can't because it has been stopped.

Now, if your program is multi-threaded, and you ask GDB to execute in non-stop mode, and you carefully arrange things such that your thread that performs GDB interaction itself is never stopped, then perhaps this could work. I doubt it will work reliably though.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top