Calling convention ?

Sysprogs forums Forums VisualGDB Calling convention ?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9576
    Otatiaro
    Participant

    Hello,

    I’m porting my RTOS from Atollic to VisualGDB and I face an issue.
    I use SVC to call OS features, and use the stack R0, R1, R2 and R3 to pass parameters.

    The ISR Handler has a few lines of asm code to get the stack pointer and the SVC parameter and pass it to the C++ function that will do the actual job.
    Calling this C++ function from ASM, I rely on the calling convention to get the correct parameters (by convention, first param in R0, then R1, then R2, return value in R0).
    Just before the C++ function is called I can see in the registers I have the correct values, but when I step into the C++ function, the debugger tells me the parameters are totally messed up, obviously not taking values from R0, R1 and R2, but from other registers or stack.

    Is this normal behavior (it was working fine on Atollic, which is using GCC ARM too …), and if so is there a way to force the compiler to take the parameters from the registers ?

    Thomas.

    #9588
    support
    Keymaster

    Hi,

    VisualGDB does not change the way gcc handles the calling convention, so this problem may be caused by different optimization settings or inaccurate debug information generation. We would advise adding some clearly traceable lines to your code like this:

    static volatile int var;
    var = arg_1;

    Then try switching to the Disassembly view to understand where exactly does the compiler take the value that is stored into ‘var’.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.