I am testing some functions on a FreeRTOS windows simulator environment, which is moved to cmake project with VS Code rather than Visual Studio.
Look at below screen snipshot (break at "if(!buf)"), here are some highlights:
- generate the cmake project by "cmake -S . -B build"
- pvPortMalloc returned: Console.exe!0x00007ff753cb6a98
- buf: 0x0000000053cb6a98
- CPU: RAX 0000000053CB6A98
After "buf = (char *)pvPortMalloc(100 * 30);", variable "buf" should have the return value of "pvPortMalloc()". But base on the debug infomation, "buf" only has the low 32 bit value and the high 32 bits have been set to '0".
The issue disappear if we generate the project with:
- cmake -S . -A Win32 -B build.
Same issue if generate project with:
- cmake -S . -A x64 -B build
Check your code if you missed out function prototype (somestruct* func1(somestruct* mystruct);).in func2.c.
By default all return values are int. So if a prototype is missing for function then compiler treats the return value as 32-bit and generates code for 32-bit return value. Thats when your upper 4 bytes gets truncated.