Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program received signal SIGTRAP, Trace/breakpoint trap

Tags:

c

embedded

gdb

arm

I'm debugging a piece of (embedded) software. I've set a breakpoint on a function, and for some reason, once I've reached that breakpoint and continue I always come back to the function (which is an initialisation function which should only be called once). When I remove the breakpoint, and continue, GDB tells me:

Program received signal SIGTRAP, Trace/breakpoint trap.

Since I was working with breakpoints, I'm assuming I fell in a "breakpoint trap". What is a breakpoint trap?

like image 477
Randomblue Avatar asked Mar 21 '12 17:03

Randomblue


People also ask

What is a breakpoint trap?

Breakpoint trap just means the processor has hit a breakpoint. There are two possibilities for why this is happening. Most likely, your initialization code is being hit because your CPU is resetting and hitting the breakpoint again.

What is Sigtrap signal?

SIGTRAP. The SIGTRAP signal is sent to a process when an exception (or trap) occurs: a condition that a debugger has requested to be informed of — for example, when a particular function is executed, or when a particular variable changes value. SIGURG.


2 Answers

Breakpoint trap just means the processor has hit a breakpoint. There are two possibilities for why this is happening. Most likely, your initialization code is being hit because your CPU is resetting and hitting the breakpoint again. The other possibility would be that the code where you set the breakpoint is actually run in places other than initialization. Sometimes with aggressive compiler optimization it can be hard to tell exactly which code your breakpoint maps to and which execution paths can get there.

like image 195
TJD Avatar answered Oct 02 '22 08:10

TJD


The other possibility i can think of is:

1.Your process is running more than one thread.

For eg - 2 say x & y.

2.Thread y hits the break point but you have attached gdb to thread x.

This case is a Trace/breakpoint trap.

like image 27
b1tchacked Avatar answered Oct 02 '22 07:10

b1tchacked