[bash]int Func()In the function getPtr(), the idx is OK and in the return of getPtr(), the rax register is OK (value is 0x9d65f9a0). And in the assignment, it performs
{
int idx = 0;
struct myStruct * ptr = NULL;
... /* somewhere modify idx */
ptr = getPtr(idx);
...
}
struct myStruct* getPtr(int idx)
{
/* S_ptrTbl is of type struct myStruct** */
if (S_ptrTbl) {
return S_ptrTbl[idx];
}
return NULL;
}
[/bash]
[bash]mov %eax, -0x30(%rbp)And then %rax is 0xffffffff9d65f9a0 which is an invalid memory address.
mov -0x30(%rbp), %eax
movslq %eax, %rax[/bash]
Link Copied
[cpp]extern struct myStruct* getPtr(int); [/cpp]You could use the Intel debugger instead of GDB, or the DDD front-end for GDB. At the GDB prompt, try "help p" and it will tell you, among other things that to display the contents of %eax the command is "p $eax".
For more complete information about compiler optimizations, see our Optimization Notice.