Program received signal SIGTRAP, Trace/breakpoint trap
Solution 1
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.
Solution 2
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.
Solution 3
I got this problem running linux project in Visual studio 2015 and debugging remotely. My solution is project_properties -> Configuration properties -> Debugging -> Debugging mode and change the value from "gdbserver" to "gdb"
Randomblue
Updated on April 30, 2021Comments
-
Randomblue about 3 years
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, andcontinue
, 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?
-
Shiplu Mokaddim about 12 yearsAdded a more verbose title. It'll help the other user
-
Kortuk about 12 yearsThis is also the type of question you can post on the electronics SE.
-
Pavan Manjunath about 12 years@Kortuk In what way this GDB Qn related to electronics? :-o
-
Pavan Manjunath about 12 yearsType
info breakpoints
and make sure all breakpoints are deleted. -
Kortuk about 12 years@PavanManjunath, the embedded got me, and when I dont know a program like GDB, I dont spend too much time worrying about the product, I just watch anything tagged embedded and drop comments occasionally, we do support embedded work. We are probably primarily embedded system developers, although many like myself mean lower end microcontrollers. This is a question that fits on either site, but SO has many more people browsing it, so some advantage to posting here. Electronics is the Electrical Engineering site, used to be Electronics Design, but trademark issues.
-
Pavan Manjunath about 12 years
-
Robin Kuzmin almost 7 yearsSee my answer here: stackoverflow.com/a/44707500/6362941 (search for "The following helped me:").
-
-
Pavan Manjunath about 12 yearsIf the CPU resets, would GDB be still alive and attached to the user's executable?
-
TJD about 12 years@PavanManjunath, yes it's possible for CPU to reset and then hit the breakpoint without disturbing the GDB session.
-
Dean about 11 yearsThis is completely dependant on the microcontroller/microprocessor used.
-
Damian Nadales over 8 yearsThis is a common symptom when using unit test frameworks that fork the tests cases. Good to know!
-
Admin over 4 yearsWe have been struggling with this problem for quite a few hours in our BMS with an STM MCU and disconnecting the battery (after reading this answer) solved the problem. :)
-
m4l490n over 3 yearsIn some systems, the execution stops at the entry point instead of going directly to main when a debug session is started. So if you see this it may mean that your system crashed and it went to the code entry point.