简体   繁体   English

在调试步骤中异常运行

[英]Unregular running in debugging steps

I have a makefile project in Eclipse and when I debug the program the order of running steps is not regular. 我在Eclipse中有一个makefile项目,并且在调试程序时,运行步骤的顺序不规则。 As an example in the following function, the commands will be run in this order: 1,6,1,6,1,... and it is supposed to be 6,7,8,..... 作为以下功能的示例,命令将按以下顺序运行:1,6,1,6,1,...假定为6,7,8,.....

1    int  get_region(int x, int y, int level, int &region_x, int &region_y, int min_x,int min_y,int max_x,int max_y)
    {
2       int X_distance = max_x - min_x;
3       int Y_distance = max_y - min_y;
4       int steps_x = X_distance / (pow(2,level)) + 1; 
5       int steps_y = Y_distance / (pow(2,level)) + 1;

6       region_x =  (x - min_x) / steps_x;
7       region_y =  (y - min_y) / steps_y;

8       cout << "region_x = " << region_x << "  x = "<< x << endl;
9       cout << "region_y = " << region_y << "  y = "<< y << endl;

10      cout << "****************** get_region function is called  **************"<<endl;

11      return 0;
    }

That's normal behavior when your code is compiled with optimizations enabled. 在启用优化功能的情况下编译代码时,这是正常现象。 The compiler rearranges your code to get better performance out of it. 编译器会重新排列您的代码,以获得更好的性能。

Compile with optimizations turned off to make the debugging easier. 在关闭优化的情况下进行编译可简化调试过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM