First time I did some debugging at the assembly level, so it may be not correct what I found out but here are my results:
how "sa" is set at assembly level:
395 double sa = center.angleTo(sp);
0x80cc2a9 <+0x10a9> lea 0x6c0(%esp),%edx
0x80cc2b0 <+0x10b0> lea 0x4c0(%esp),%ecx
0x80cc2b7 <+0x10b7> mov %edx,0x4(%esp)
0x80cc2bb <+0x10bb> mov %ecx,(%esp)
0x80cc319 <+0x1119> call 0x81152c0 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc325 <+0x1125> fstpl 0x70(%esp)
396 if(ellipse != NULL) sa=ellipse->getEllipseAngle(sp);
0x80cc31e <+0x111e> mov 0x84(%esp),%ebp
395 double sa = center.angleTo(sp);
0x80cc2a9 <+0x10a9> lea 0x6c0(%esp),%edx
0x80cc2b0 <+0x10b0> lea 0x4c0(%esp),%ecx
0x80cc2b7 <+0x10b7> mov %edx,0x4(%esp)
0x80cc2bb <+0x10bb> mov %ecx,(%esp)
0x80cc319 <+0x1119> call 0x81152c0 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc325 <+0x1125> fstpl 0x70(%esp)
396 if(ellipse != NULL) sa=ellipse->getEllipseAngle(sp);
0x80cc31e <+0x111e> mov 0x84(%esp),%ebp
To copy to clipboard, switch view to plain text mode
how "a" is set at assembly level:
418 a = center.angleTo(*v);
0x80cc630 <+0x1430> mov 0x824(%esp),%eax
0x80cc637 <+0x1437> lea 0x824(%esp),%ebx
0x80cc63e <+0x143e> mov %ebx,0x38(%esp)
0x80cc642 <+0x1442> lea 0x81c(%esp),%ebx
0x80cc649 <+0x1449> mov %ebx,0x30(%esp)
0x80cc64d <+0x144d> mov %eax,0x4(%esp)
0x80cc651 <+0x1451> lea 0x4b0(%esp),%eax
0x80cc658 <+0x1458> mov %eax,(%esp)
0x80cc65b <+0x145b> call 0x8115280 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc665 <+0x1465> fld %st(0)
418 a = center.angleTo(*v);
0x80cc630 <+0x1430> mov 0x824(%esp),%eax
0x80cc637 <+0x1437> lea 0x824(%esp),%ebx
0x80cc63e <+0x143e> mov %ebx,0x38(%esp)
0x80cc642 <+0x1442> lea 0x81c(%esp),%ebx
0x80cc649 <+0x1449> mov %ebx,0x30(%esp)
0x80cc64d <+0x144d> mov %eax,0x4(%esp)
0x80cc651 <+0x1451> lea 0x4b0(%esp),%eax
0x80cc658 <+0x1458> mov %eax,(%esp)
0x80cc65b <+0x145b> call 0x8115280 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc665 <+0x1465> fld %st(0)
To copy to clipboard, switch view to plain text mode
When the Debug line is added to "fix" this behaviour the assembly looks like this:
418 a = center.angleTo(*v);
0x80cc648 <+0x1448> mov 0x834(%esp),%eax
0x80cc64f <+0x144f> lea 0x834(%esp),%ebx
0x80cc656 <+0x1456> mov %ebx,0x40(%esp)
0x80cc65a <+0x145a> lea 0x82c(%esp),%ebx
0x80cc661 <+0x1461> mov %ebx,0x38(%esp)
0x80cc665 <+0x1465> mov %eax,0x4(%esp)
0x80cc669 <+0x1469> lea 0x4c0(%esp),%eax
0x80cc670 <+0x1470> mov %eax,(%esp)
0x80cc673 <+0x1473> call 0x81152c0 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc67d <+0x147d> fstl 0x68(%esp)
418 a = center.angleTo(*v);
0x80cc648 <+0x1448> mov 0x834(%esp),%eax
0x80cc64f <+0x144f> lea 0x834(%esp),%ebx
0x80cc656 <+0x1456> mov %ebx,0x40(%esp)
0x80cc65a <+0x145a> lea 0x82c(%esp),%ebx
0x80cc661 <+0x1461> mov %ebx,0x38(%esp)
0x80cc665 <+0x1465> mov %eax,0x4(%esp)
0x80cc669 <+0x1469> lea 0x4c0(%esp),%eax
0x80cc670 <+0x1470> mov %eax,(%esp)
0x80cc673 <+0x1473> call 0x81152c0 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc67d <+0x147d> fstl 0x68(%esp)
To copy to clipboard, switch view to plain text mode
Setting "a" as volatile will also fix the weird behaviour:
418 a = center.angleTo(*v);
0x80cc638 <+0x1438> mov 0x834(%esp),%eax
0x80cc63f <+0x143f> lea 0x834(%esp),%ebx
0x80cc646 <+0x1446> mov %ebx,0x38(%esp)
0x80cc64a <+0x144a> lea 0x82c(%esp),%ebx
0x80cc651 <+0x1451> mov %ebx,0x30(%esp)
0x80cc655 <+0x1455> mov %eax,0x4(%esp)
0x80cc659 <+0x1459> lea 0x4b8(%esp),%eax
0x80cc660 <+0x1460> mov %eax,(%esp)
0x80cc663 <+0x1463> call 0x8115290 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc66d <+0x146d> fstpl 0x800(%esp)
418 a = center.angleTo(*v);
0x80cc638 <+0x1438> mov 0x834(%esp),%eax
0x80cc63f <+0x143f> lea 0x834(%esp),%ebx
0x80cc646 <+0x1446> mov %ebx,0x38(%esp)
0x80cc64a <+0x144a> lea 0x82c(%esp),%ebx
0x80cc651 <+0x1451> mov %ebx,0x30(%esp)
0x80cc655 <+0x1455> mov %eax,0x4(%esp)
0x80cc659 <+0x1459> lea 0x4b8(%esp),%eax
0x80cc660 <+0x1460> mov %eax,(%esp)
0x80cc663 <+0x1463> call 0x8115290 <RS_Vector::angleTo(RS_Vector const&) const>
0x80cc66d <+0x146d> fstpl 0x800(%esp)
To copy to clipboard, switch view to plain text mode
So (from a perspectiv of a novice assembly debugger) it looks like the commands "fstpl" and "fstl" works. Whereas "fld" will cause the weird behaviour.
Can someone tell if I can view a variable (in QtCreator) wich is "optimized out" without changing the code?
For variables that are not "optimized out" I do "Right click on the variable->Open Memory Editor->Open Memory View at Object's Address".
I can't use this for variables which are "optimized out".
Bookmarks