This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

infinite Break Points

Greetings,

               sir/Madam the hardware break points use internal FPB comparators so that the address we update there are internally comare with program counter if value == program counter then automatically the core will be halted and ready to debug the internal registers.

coming to the software break point this will use "BKPT" instrruction so that when ever the address match with program counter user has to execute __ASM("BKPT"); which will case the target break and enter into halt so that user can further access the debug registers.

my doubt was how should i continuously check the program counter continuously so that i could break the target when ever address i supplied was match.

Correct me if i was wrong.

Thanks and Regards.

Harshan.

  • Hi Harshan,

    If I understand your question correctly, you are asking how a software breakpoint is detected and what mechanism causes the execution of the BKPT instruction. With a software breakpoint, the debugger changes the program memory to replace the breakpointed instruction with BKPT. The debugger records what the original instruction was so that it can be restored when the breakpoint is removed.

    I hope that answers your question.

    Chris

  • Hello Harshan,

    I agree fully with Chris.

    Basically the BKPT instruction is not written by assembler program.

    A debugger will replace the break address instruction for the BKPT and the debugger should recover the original instruction instead of the BKPT before returning the BKPT handler.

    Best regards,

    Yasuhiko Koumoto.

  • Thanks for Reply,

                              Actually i am implementing serial wire debugger, i want to include break point functionality to my customized debugger, in hardware breakpoints they are limited to 6. after browsing on internet i found that we can set unlimited software break-points. but how could i break the target, i mean the process i need to follow in order to break the Target, in "joseph yiu" book i found the information regarding hardware break-point not much about software break point. can you please suggest me the process/example reference so that how could i add this software breakpoint feature to my custom debugger ??

  • In order to set a software breakpoint, your debugger must edit the code memory to replace the target instruction with a BKPT instruction. You must obviously then replace the original instruction in order to continue execution and when removing the breakpoint. Obviously, this only works when the code is executing from writeable memory.

    Hope this helps.

    Chris

  • Hello

    It seems to me your question "how should i continuously check the program counter continuously so that i could break the target when ever address i supplied was match" may have some assumptions about the use of software breakpoints. The debugger does not continuously check the program counter...

    The user debugging her code will set a breakpoint somewhere in her code in a way allowed by the debugger (for example, in DS-5 see Setting or deleting an execution breakpoint and Working with breakpoints and watchpoints).

    For SW breakpoints, the debugger will then replace the assembly instruction at the location of the breakpoint with the BKPT assembly instruction so that when the user runs her code and this BKPT is executed the core enters debug mode and halts (stops execution).

    So the question is then: how does the debugger know when the BKPT has been executed? The common approach is to poll the Debug Halting Control and Status Register (DHCSR). The DHCSR is typically accessed by a debugger through the DAP, which is the block connected to your serial wire debug interface. In particular, the S_HALT, bit[17] in the DHCSR indicates whether the processor is in Debug state

    (refer to the ARM®v7-M Architecture Reference Manual):

    0 In Non-debug state.

    1 In Debug state.

    Hope this helps, and pardon my ramblings if I misunderstood the question.

  • Thanks for reply,

                             if i understand clearly above, let say if i want to break the perticular address location on the target then i have to redirect that address to BKPT assembly instruction, The point is how could i redirect that address to BKPT assembly Instruction let say my target is stm32f4xx and i want to break at address 0x08000228. where my customized debugger  follows serial wire debug protocol now what are the steps i should have to be follow in order to break the stm32f4xx at address 0x08000228, i hope the question is very clear??

    Thanks and Regards.

    Harshan

  • Greetings,,

    Let me first explain some essential points

    • the address 0x08000228 falls in rom region (normally a flash memory is used to store your code and read only data there)
      • normally you would only read from that region.. and in order to write to it you would need to program it (usually done in blocks not in bytes)
      • that is why there is a feature called FPB (flash patch and breakpoint unit) (which allows you to compare PC address and halt the processor but it has a limited number of breakpoint coparators + you don't want to use this solution )
    • Now what you could do.. is run the code from SRAM region.. (of course requires (custom linker script, using bootloader or copying code from flash to SRAM, ajusting VTOR *vector table offset register* .. etc)
      • now this way you can you save the instruction in the adress you want to break at.. then replace it with bkpt and after the processor halts replace the original instruction back
      • I guess there is already made plugins for eclipse which allow you to choose to run your code from Flash or ram (not sure though don't take my words) ( Features | GNU ARM Eclipse ) ,, I'v not used other toolchains and IDEs but I guess you can choose to run the code from SRAM or flash there as well
    • of course you need to refer to (Chapter 14 of jyiu book for more details if you are doing it using a customized debugger for more information about the steps and registers involved)

    hope this helped..

    Regards..

    Mustafa S.

  • Thanks for Reply,

                              In Hardware Break Point after setting the first break point the core was halted successfully but when i tried to run the target it won't hit the second break point until i clear the first break point. what might be the issue??

    Thanks and Regards.

    Harshan_Behra