views:

356

answers:

2

i have written a c program to which i pass in a script like code and it executes it and prints the results for me. some thing like if i send

for i in 1 to 10
print i

it'd create and run code which would essentially print values from 1 to 10. however i wanted to integrate step wise running of the code for which i added a functionality of adding a breakpoint as BP in the script which i pass to the program. so when ever BP is encountered it runs and waits for user to type the continue command "CNT".

Now i've developed a small ide for writing scripts and running it on my program. However i'm having trouble in providing the debugging support through the IDE. i want to implement something like step each line of code or run whole process (like F5, after breakpoint is hit).

for i in 1 to 10
{
    print i
    BP
}

So the program would stop after every line and wait for user to type CNT. However i want to be able to run the whole program after 1st break point is hit.

I was looking for some way in c# through which i could control the execution of the external exe program which i'm attaching. In that way i could send command like run the program for next 1 line or next 5 lines, etc.. Any way, without modifying the underlying exe?

A: 

Perhaps you could try to take a look at this previous question: http://stackoverflow.com/questions/216819/how-does-a-debugger-work

The links provided in the (currently) most up-voted answer will give you a basic understanding of how a debugger works on the Windows platform, and how to implement your own.

driis
A: 

The answer to it may be many and it depends upon the implementation. Iv've added a functionality in my program to print the line number whenever a breakpoint is reached. This way i was able to control the execution.

Anirudh Goel