User forums > Using Code::Blocks

Breakpoints Not Breaking on Flow Control or Assignment Statements

(1/2) > >>

Thoth:
Hello People,

I am using Code::Blocks version:
Name                   : Code::Blocks
Version                : svn-r13046
SDK Version            : 2.23.0

When I set a breakpoint on an if statement, the code stops on a statement within the block, not on the if statement as I expect. Also, when I set a breakpoint on an assignment statement the code stops on the next non-assignment statement. It looks like the debugger will not stop on any flow control statement, but I have not fully checked this.
Did something change in the last several versions?

I prefer to have programs break on flow control statements so I can evaluate what is going to happen. More importantly, I expect the program to halt wherever I have a breakpoint, regardless of the instruction.

I have enabled debugging symbols and tried variations of optimizations. I have also set both target options as well as project options.
-Og; Optimize debugging executable (compile speed, execution speed and better debugging)
-g; Produce debugging symbols
-O1; Linker output optimization (level 1)

Always breaks on statement below with '--->'.
Never stops on if statement, the line in the if block.
Never stops on the DevicesCount assignment statement.

--- Code: --- if (oDevices.find(0) != oDevices.end()) {
CmdRez = oDevices.at(0);
}

if (oDevices.size() > 1)
{
std::map<uint8_t, std::map<uint16_t, std::vector<uint8_t>>>::const_iterator ItorDevices;
std::map<uint16_t, std::vector<uint8_t>> oADevice;
std::map<uint16_t, std::vector<uint8_t>> TempMap;
std::vector<uint8_t> DevicesVector;
uint8_t DeviceCount = 0;

// ADC_LibUSBDevices
---> ResultVector.push_back(((ADC_LibUSBDevices >> 8) & 0xFF));

--- End code ---

While researching another issue I thought I saw a post about current versions of Code::Blocks no longer stopping on flow control. However, I was not able to locate whatever it was I saw.

What else can I try? I want to have the program break on flow control and assignment statements.


=thoth=

ollydbg:

--- Quote ---I have enabled debugging symbols and tried variations of optimizations.
--- End quote ---

My suggestion: if you want to debug the code, it is recommended that you do not have optimization option in your compiler option, I mean -O0 option is needed.

Thoth:
Hello ollydbg,

I have tried -O0.

The program still does not break on if statements (or other flow control statements) and still skips assignment statements.




=thoth=

ollydbg:

--- Quote from: Thoth on September 25, 2024, 07:25:36 pm ---Hello ollydbg,

I have tried -O0.

The program still does not break on if statements (or other flow control statements) and still skips assignment statements.




=thoth=

--- End quote ---

I think you may need to create a minimal program, and share it here. So others can test and reproduce it.

But from my point of view, this is mainly a compiler or debugger issue.

stahta01:

--- Quote from: ollydbg on September 26, 2024, 01:49:00 am ---
--- Quote from: Thoth on September 25, 2024, 07:25:36 pm ---Hello ollydbg,

I have tried -O0.

The program still does not break on if statements (or other flow control statements) and still skips assignment statements.




=thoth=

--- End quote ---

I think you may need to create a minimal program, and share it here. So others can test and reproduce it.

But from my point of view, this is mainly a compiler or debugger issue.

--- End quote ---

Posting a full bull log might show the problem.

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version