Author Topic: Debugger question  (Read 2447 times)

Offline VeeDub

  • Single posting newcomer
  • *
  • Posts: 8
Debugger question
« on: August 07, 2020, 12:41:38 am »
Hello,

I am using CodeBlocks v20.03

on RedHat 4.8.5-39

GCC is version 4.8.5

For a certain record, the following if statement should evaluate as true.
Code
if ( 
                       (tail->i_local_port == Device_Activity_record->i_local_port) && \
                       (strcmp(tail->c_remote_ip_address,Device_Activity_record->c_remote_ip_address) == 0) && \
                       (tail->i_remote_port == Device_Activity_record->i_remote_port) && \
                       (strcmp(tail->c_protocol,Device_Activity_record->c_protocol) == 0) && \
                       (strcmp(tail->c_type,Device_Activity_record->c_type) == 0) && \
                       (strcmp(tail->c_content,Device_Activity_record->c_content) == 0)
                       )
                    {
                        //do actions
                    }
However for some reason this is not happening.

I have placed watch statements on all the variables, and they're identical as expected.

Is there a way using the debugger interactively that I can identify which condition/s are not being evaluated as true, or is my only option to add a bunch of extra debugging code along the lines of
Code
if (tail->i_local_port == Device_Activity_record->i_local_port)
{
printf("Test true\n");
}
else
{
printf("Test false\n");
}
Thanks

VW

Offline VeeDub

  • Single posting newcomer
  • *
  • Posts: 8
Re: Debugger question
« Reply #1 on: August 07, 2020, 03:08:19 am »
I've figured out this issue.

Essentially a logic flaw in an earlier block of code.

This if statement was part of a while block, and when this if statement was being evaluated, a condition in the earlier while block had changed which resulted in the while loop being exited and as a result the if statement not being executed

In short, user error, as usual