Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a software breakpoint on an ARM processor?

Tags:

How do I do the equivalent of an x86 software interrupt:

asm( "int $3" ) 

on an ARM processor (specifically a Cortex A8) to generate an event that will break execution under gdb?

like image 786
engie Avatar asked Jul 05 '12 13:07

engie


People also ask

How do you set a breakpoint in a program?

Set breakpoints in source code To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.

What command do you use to set a breakpoint?

Setting breakpoints. Breakpoints are set with the break command (abbreviated b ). The debugger convenience variable `$bpnum' records the number of the breakpoint you've set most recently; see section Convenience variables, for a discussion of what you can do with convenience variables.

What is arm breakpoint?

Software breakpoints stop your program when execution reaches a specific address. Software breakpoints are implemented by the debugger replacing the instruction at the breakpoint address with a special instruction.

How is breakpoint implemented?

Software breakpoints, on the other hand, are implemented by your debugger. They work by patching the code you are trying to execute with an instruction that triggers a debug event in some fashion.

How software and hardware breakpoints are implemented?

Software breakpoints put an instruction in RAM that is executed like a TRAP when your program reaches that address. While hardware breakpoints use a register of the CPU to implement the breakpoint itself. That is why the hardware breakpoints are much faster.

What is one way to set a breakpoint in main?

To set breakpoints, type "break [filename]:[linenumber]". For example, if you wanted to set a breakpoint at line 55 of main. cpp, you would type "break main. cpp:55".

What does setting a breakpoint do?

In software development, a breakpoint is an intentional stopping or pausing place in a program, put in place for debugging purposes. It is also sometimes simply referred to as a pause.


1 Answers

Using arm-none-eabi-gdb.exe cross compiler, this works great for me (thanks to Igor's answer):

__asm__("BKPT"); 
like image 136
benathon Avatar answered Oct 30 '22 10:10

benathon