Raghuveer Reddy wrote: > Hi All, > > I have a query regarding the break points in debuggers. > > How does the debuggers implement break point and get the register values and > stack data? > > I guess they use TRAP interrupt, but i am unable to guess the complete > process involved. > > Anybody has a good article/link which explains this? > > Thanks > Raghuveer >
Hi Raghuveer, The process works like this: When the user sets breakpoint at some line, the debugger inserts an instruction at that line, which will cause an interrupt/trap. This trap's handler hands over control to gdb which can now access the values in the registers and stack. When the debugger gets the 'next', 'step' or 'continue' instruction, it replaces the original instruction at that point, single steps, then puts back the trap at that point and then moves further. Upon recieving 'clear breakpoints' it replaces back the original instructions and removes the instructions that cause the interrupt. I dont remember where I read this. Will post a link or reference book if I find one. Namita

