"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
I am new to VC++/MFC but have C++ background. I am using addpage() of CPropertySheet class to add new tabs. My problem is that on click of a radiobutton control all tab pages should be disable except one.
The problem is the breaking the debugger doesn't stop the system clocks on the PC which means you get a backlog and out of sequence queue of things to happen when you release the debug. So often your debugging does not look like the system when running which can be more than a little frustrating
If you're familiar with Visual Studio debugging options they include a Task window, Thread window, and a window to view Parallel stacks. All these windows support various flags and the Parallel stacks shows a nice visual diagram of the execution environment. There's also the Tracepoint option if you want a breakpoint that outputs state information but doesn't halt execution.
I don't really see the issue with out of order execution. That should be something addressed in your code with barriers/fences, locks, semaphores, mutexes, or whatever else you use.
Thanks The visual studio thread window I know has the ability to freeze a thread Regardless I'll down load the Extension
Let me explain the nature of the problem
I'm writting a debugger for another platform The way I Interrupt the program and show the user the code is by overlaying the instruction which causes a interrupt and allows me to get control I quickly put back the instruction that was overlayed However the interrupt gives me control This all fine when the "Debugged" program is single thread However in a multi thread program in which other programs use he same code I get a operation exception The way I coded this was the as soon as I overlay the instruction I do a Restevent which cause an event to be non- signaled this will cause the other programs to Wait or WaitForSingleEvent until I have chance to put the instruction back and then I do a SetEvent to let execution of the program to the other threads trying to execute it
Something is obviously not working out right in this timing
In Visual Sudio I can observe how QUICKLY the windows dispatcher switches from thread to thread
The other threads won't stop until they hit a lock point. So let me imagine they are in the section of code you overlayed. They will see your overlay (which is an interrupt opcode I guess .. you transposed the real opcode out to a hold memory somewhere). However interrupts will be disabled because you are in the IRQ routine already so it then continues thru to next opcode.
I can imagine if that is the scheme you end up with two equally bad situations 1.) the other threads pull an illegal opcode if your transpose isn't the same length as the replaced opcode 2.) they pass thru the overlay missing the held opcode (they saw the interrupt request which was ignored). So anything could happen the thread missed an entire opcode.
If that is what you are doing there is no fix, you either can't have the threads going thru the same code or you need to stop the threads immediately the other threads even advancing one opcode can be fatal much less allowing them to run to next lock point.
This goes back to what I was getting at originally you need to stop the system totally in some schemes. Some processors like Arm and many microcontrollers can do that under system control for hardware debugging. The Raspberry PI which uses an ARM6/7/8 could do that for example. I fear your current schema needs a full hardware debugging setup if I understand it correctly.
Edit: Assuming above is correct I gave this a bit of thought and there is possibly a way to do this on a normal non stepable processor. You have the stacks of the threads and that contains the Program Counter for each thread. So overlay the other threads as well this time with a relative branch instruction to there current position ... get it ... will deadloop them to exactly where they are ... meeting the requirement they don't move even one opcode forward You don't need the event stuff at all it's just a repeat of what you do to the active thread in the interrupt overlaying a different instruction into non active threads. Just make sure you put back the opcodes in reverse order (incase two threads are in the exact same place) from within an interrupt when you want to release it back.
I overlay two bytes of code (causing it to pause) right before I overlay the code I do a ResetEvent which will cause a manual Event to be NON-signaled the threads right behind this will stop on the WaitForSingleObject
I have code to determine the Work unit executing code in CSA (common storage) it is only for that code that I do a ResetEvent and then memcpy
Once the emulated code that I overlayed (cuasing it to interrupt and pause)
I put back the legal opcode via memcpy right after I do a SetEvent for the other workunits executing the common storage to proceed (as it is now okay) and bypass the overlaying logic
I will paste the relevant code shortly as it is late (have to get to sleep)
I wanted to give you a feel (of what I doing) as you have been so verrrrrry helpful
Make sure you are using manual reset events there is a trap for young players with Auto-Reset Events
Read the documentation SetEvent function (Windows)[^] Quote => The state of an auto-reset event object remains signaled until a single waiting thread is released, at which time the system automatically sets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled.
/* this block of code checks if the address where the code is executing is within the address looking to be traced and is the address space correct the GET_WU function checks the the task or thread within the address space so GET_WU returns a 64 bit value 32 bits for a address space 32 for the task this is UNIQUE */
/* the next piece of code checks after the user has examined the code and I have restored the correct instruction I want to let it execute and not over lay stop ia is the instruction address */ // Hercmd is a from end Windows MFC/C++ I have written to display the information
// this should oly happens if hercmd hit <enter> if(regs->psw.ia.D == sysblk.debug_ia.D)
wu_ptr.D = ARCH_DEP(GET_WU)(regs);
if(wu_ptr.D == sysblk.debug_wu.D)
sprintf(buf,"CPU%4.4X: inst being executed=%s At address %8X\n",buf1,regs->psw.ia.D);
/* this is the code where I check if other threads are execting the same code and the address or instruction has been overlayed to genarate a pause so I WaitForSingleObject */