Skip to main content
Adrian Adamson
Senior
January 26, 2020
Question

Debugger stuck on random line

  • January 26, 2020
  • 17 replies
  • 7205 views

The debugger is getting stuck on a random line about 350 lines into main(). There is nothing particular about this line of source code except its location, because if I comment out that line it just stops on the next one, and if I add a line it stops earlier. When the debugger is not active, the source runs just fine without stopping in that area. I have deleted all breakpoints and watchpoints. I have set the optimizations to "off". When the debugger is stuck on that line, its status is "running."

This is my first time debugging this project after converting from TrueStudio. I may need to switch back if I can't find anything else to try.

Any suggestions?

17 replies

Adrian Adamson
Senior
May 23, 2020

Thanks for looking that up for me. I have had this problem with all breakpoints disabled. This last round started after I accidentally inserted too many breakpoints once. After trying different builds, different projects, re-generating code from CubeMX, and changing parts of my source code, I still had the problem, though the phantom breakpoint would move around to different places. It even popped up when trying to debug a different project that was working trouble-free before this. Then I gave up for the day, flew to a different state, and when I started working the next day the problem was gone. I didn't change anything that I know of.

I wish I knew where breakpoints are stored so I can delete that and re-generate. There was a stack overflow comments about a .markers file, but I haven't been able to find that.

waclawek.jan
Super User
May 23, 2020

Humm.

> Then I gave up for the day, flew to a different state, and when I started working the next day the problem was gone.

I wonder if you can just do this every time the problem pops up... :D

JW

Adrian Adamson
Senior
May 23, 2020

This problem is so strange. Every time it happens I lose about a half day of productivity and then some combination of banging my head against the computer and how I part my hair that day makes the problem go away.

To be continued, I'm sure...

bully
Senior
July 21, 2021

Hello,

I've just landed in the same boat. CubeIDE has chosen particular source code line that it will stop in, regardless of breakpoints setting.

I can run the code without stopping only with "Skip All Breakpoints" setting, but I cannot stop anywhere else... Not usable.

Are we on ST forum? Can anyone from ST elaborate on those hidden breakpoints ? I too remember that this is probably related

to setting more breakpoints at some point... I'm on Cortex m7.

I also have other problem too, that my chip is recognized as not-original and I must erase it each time before programming.

It seems that CubeIDE is not the tool to be used for development, more for showcase...

Regards.

HCour.1
Associate II
March 1, 2023

I got stuck with this same problem today - After trying to add too many breakpoints.

The fix was:

  • Disconnect the ST-LINK debugger,
  • Remove power from the board
  • Then restart everything.

I suspect there is a breakpoint register somewhere in the core that the debugger "forgets" about, and it needs a power cycle to clear that register.

JLope.11
Associate III
July 31, 2024

It worked for me: Made Clean and compile again

Adrian Adamson
Senior
November 6, 2025

It's Baa-aaack.

Power cycling my prototype didn't help.  Rolling back the code to the previous commit that I had been troubleshooting fine didn't help.   Going back one more commit also didn't help.

I decided to copy the project into a new project within my workspace.  First it got to the start of main but then terminated the session when I tried to reset.    Without changing anything, I tried again and now the console says "lost connection" and I'm getting a dialog box saying "Failed to Enable Live Expressions"

After a re-start of the IDE, I re-started the debug session, and this time after it stopped at home, I hit continue, and then watched it stop at a random spot in the code a few hundred lines down.   There are no breakpoints enabled.

I tried to reset and there was no response.   Then I tried continue and the debugger shut down.

Next I'm going to try copying my project into a brand new workspace

 

Adrian Adamson
Senior
November 7, 2025

 I made a new workspace, and started a new project from the .ioc file. Generating bare code from that allowed debugging.

 Then I copied my code from Core and the USB and BLE folders, re-installed eGIT, and compiled my code.

 

Now I started a debugging session, and it started on on main ok, but then when I reset again, it put the breakpoint further down in my code where I had no breakpoint.   Clicking continue killed the debug session.

 

I decided to try again, after rebuilding code from the .ioc.  I'm getting the same thing, where it starts out o.k., breaking on the first statement in main.   But then I hit continue and it breaks about 50 lines down, where I don't have any breakpoint.  I click reset again, and it takes me to that same spot.  I hit continue, and the debugging session is killed again with "GdbSession, Lost target connection, Exiting..."

 

Adrian Adamson
Senior
November 7, 2025

I'm starting over with the new workspace to see at what point things start to go wrong.

I quit the IDE and deleted everything in the workspace folder except the .ioc file.  That includes the .metadata folder.  Then I made a new project from the .ioc file.

I generated code, and it compiles.  

I made a new debug configuration for the debug build and started a debug session.   It starts at the right place.  I can add breakpoints and get rid of them and all debugging is working.

Next I modified the FLASH.ld file to accommodate OTA, using examdiffpro to copy the relelvant parts from my working file on another program.

I did a clean and refresh and re-built.

Now I'm getting the "Break at address "0x800277e" with no debug information available, or outside of program code." message.  

I'm using CubeProg to make sure that my OTA application is still installed correctly.  I bet it's not.  I did a full chip erase, and checked the stack.  It was 1.19.   I think I want the 1.20 version, so I tried to program that from the repository.   I got a bunch of errors.  Next I tried to re-program the FUS with 1.20, and got a data read failure.  Next I tried a full chip erase again and got a failure there too, with the message to check flash protection.   It disconnected. so I re-connected and was able to read the regular flash memory.  Back to the firmware upgrade services, and it's reading fine.  Read FUS infos gives FUS version 1.2.0.0 and stack version 1.22.0.2.  I started the stack successfully and disconnected.

Back to the IDE.  Now it halted correctly at the start of Main.  But when I reset, it goes into the weeds, with "Break at address  "0x8000b80" with no debug information available, or outside of program code."

I added "set $pc=Reset_Handler" to my reset configuration, and now it seems to halt in the right place when I click reset.  However, when I continue, it goes off into the weeds after trying to start USB, after "HAL_PCD_Start().  I have a project that works with USB and BLE together, but I don't know what the key to success is.    Based on what I have seen, it looks like the code generated from the .ioc, when it includes USB, is not compatible with the shifted start position necessary for OTA.  I'll try re-generating code from the .ioc again.  It's still getting stuck at USB init.

Here's where I may need to make a support ticket because this is all just autogenerated code that's not working with the mods needed for OTA.